BEGIN-EXECUTE

Syntax

BEGIN-EXECUTE [CONNECTION=uq_txt_lit] [ON-ERROR=procedure[(arg1[,argi]...)]] [RSV=num_var] [STATUS=list_var|num_var|txt_var] [SCHEMA=txt_lit|txt_var] [PROCEDURE=txt_lit|txt_var [PARAMETERS=(arg1[IN|INOUT|NULL[,argi[IN|INOUT]]...]])] |COMMAND=txt_lit|txt_var |GETDATA=txt_lit|txt_var] [BEGIN-SELECT[BEFORE=sqr_procedure[(arg1[,argi]...]])]] [AFTER=sqr_procedure[(arg1[,argi]...]])]]] col-name type=char|text|number|date[edit-mask] [on-break]... FROM ROWSETS=({m,-n,n-m,m-|all}) |FROM PARAMETER=txt_lit|txt_var END-SELECT] END-EXECUTE

Description

Begins a new construct. In a BEGIN-EXECUTE paragraph, the syntax of BEGIN-SELECT varies as shown in the following syntax:

Parameters

Parameter Description

CONNECTION

Identifies a name previously specified with the DECLARE-CONNECTION construct. If you do not specify a name, SQR Server uses the default connection. The default connection is defined by the command-line entries for datasource (DSN), username (USER), and password (PASSWORD). Name is not case-sensitive.

ON-ERROR

Declares the procedure to run if an error occurs.

RSV

Row Set Variable. A global SQR variable containing the row set being retrieved.

STATUS

Identifies a list or scalar variable that receives the status of the stored procedure.

SCHEMA

Identifies the location in the datasource of the object being queried.

PROCEDURE

The name of the datasource-stored procedure to be run. The name may include spaces. If the datasource is SAP R/3, this procedure is a BAPI.

PARAMETER_LIST

Scalar variables, list variables, or both of the form list_var | num_lit | txt_lit | txt_var | num_var | any_col. If you do not specify the keywords IN or INOUT, the default value is IN. Specify all parameters in order; leaving any parameters unnamed causes a syntax error. To ignore a parameter, fill its position with the keyword NULL. This results in a null value for that parameter position.

COMMAND

A text string that you pass to the datasource without modification by SQR. This string can include embedded SQR variables.

BEFORE/AFTER

Names an SQR procedure to be run before or after the row set. The procedure is not performed unless at least one row is returned from the specified row sets.

FROM ROWSET

Special case addition to the BEGIN-SELECT syntax. Available for use with all datasource types, including SAP R/3 and JDBC. Names the row sets from which to retrieve the column variables. If you specify more than one row set, use identical column name/type signatures. Row set numbers must be sequential from left to right within the parentheses, and they must not overlap as in this example: (1–3, 2–4). Numeric literals or #variables are allowed.

FROM PARAMETER

Special case addition to the BEGIN-SELECT syntax. Available only for SAP R/3 datasources. Use only with the PROCEDURE keyword. This argument names an output parameter containing one or more rows from which the column variables are to be retrieved.

PROPERTIES = (txt_var | strlit = txt_var | strlit | num_var | num_lit | any_col, … )

Specifies a set of keyword-value pairs that represent modifications to be made to the properties of the datasource (specified by the CONNECTION = statement). An arbitrary number of such pairs can be specified.

Note:

This is a similar concept to the PARAMETERS = statement in DECLARE-CONNECTION, with the minor difference that the properties specified here alter the flow of returned information, as opposed to just setting login properties. Can be used in conjunction with any data-access model (Procedure, Command, Getdata). An application of this statement would be in the MDB setting, where it might be used to specify such things as Level, Generation, or Include-Column, for example, PROPERTIES = ( 'SetColumn' = 5 )

Example

The following example illustrates the BEGIN-EXECUTE command:

begin-setup
   declare-variable 
      date $when_ordered 
      text $ship_method
      integer #theRow
      integer #theStatus
      integer #howMany
   end-declare
end-setup

input #howMany type=integer 
input $pword
let %parm1 = list($when_ordered, $ship_method, #howMany)

declare-connection SAPR3
user=scott 
parameters=clientno=5;node=starfish;
end-declare

alter-connection 
   name=SAPR3
   password=$pword

Begin-Execute 
   connection=SAPR3 
      rsv=#theRow 
         status=#theStatus
            on-error=it_failed(#theStatus)
            procedure='CreditHistory version 5'
                parameters=(%parm1,'recalculate')

   print 'proc ran OK, status is ' (+1,1)
   print #theStatus (,+5) edit 999

Begin-Select before=do_eject after=cleanup
city &col=char (1,1) on-break level=1 after=city-tot
keyval type=number (1,+1) 
rcvd type=date (0,+2)
from Rowsets=(1)
End-Select

End-Execute

See EXECUTE