AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / Conectores Nativos/Accesos Nativos / Conector Nativo SAP ASE
  • Overview
  • How to?
  • Steps
  • Remarks
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
SAP ASE Native Connector (Sybase): Run the same stored procedure multiple times
Conectores NativosDisponible solo con este tipo de conexión
Overview
In some cases, it may be useful to execute the same stored procedure multiple times by changing one or more parameters.
Several solutions can be implemented:
  1. Execute the query directly (with HExecuteSQLQuery) as many times as necessary and change the desired parameter(s) each time.
  2. Prepare the query to be executed (with HPrepareSQLQuery) as well as the different parameters to be changed. Then, execute the query as many times as necessary with HExecuteSQLQuery. This second solution is much faster and optimizes the query result traversal time (in the case of a SELECT query).
This help page explains how this second solution can be implemented.
How to?

Steps

To prepare and execute a query multiple times:
  1. Declare a data source. This data source will contain the result of the SQL query.
  2. Declare the types of query variables.
    The variables are retrieved in the type specified in WLanguage. The variables are text variables by default.
    Therefore, conversions may occur between the native type of the database and the WLanguage type, causing unexpected rounding or formatting errors (Date transformed into string for example).
    Therefore, we advise you to specify the WLanguage types of the variables with great care before running the query. To do so:
    • by initializing the value of the variable (simple types: integer, string, float).
    • specify the expected type with the Type property (not supported in this version).

      The name of these variables must correspond to the name of the parameters of this procedure on Sybase.
      Note: In some cases, the server does not accept implicit conversion.. A conversion error is displayed. In this case, you must initialize the type by defining any ordinary value in the selected type.
      For example, to define a numeric type, use MyQuery.Parameter=0.
  3. Prepare the query with HPrepareSQLQuery.
  4. Specify the value of the different parameters to take into account and run the query with HExecuteSQLQuery. Only the name of the data source that corresponds to the query must be specified.
This last step must be repeated as many times as necessary.

Remarks

  • HPrepareSQLQuery must be used with:
    • the connection name,
    • the hQueryWithoutCorrection constant
  • The declared variables must be identical to the ones used. Otherwise, a WLanguage error occurs.
  • In the call to the stored procedure, you must use the syntax specific to the database used, including for the syntax of parameters. For Sybase, the parameters are specified with the following syntax: @ParamName.
    Warning: the "@" character must be followed by at least one letter (the @1 syntax is forbidden)..
    The same parameter can be used several times. In this case, the corresponding variable will be reused.
  • The return value of the stored procedure is returned in a variable automatically defined by the Native Sybase Connector. This variable is named RETURN_VALUE.
  • To execute a query without enabling the bind option, use the hNoBind constant in HExecuteSQLQuery.
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 30/09/2024

Señalar un error o enviar una sugerencia | Ayuda local