Executing Stored Procedures

How to:

In addition to making data available using metadata, a server can run commands that execute on the remote server. A typical command executes a procedure residing on the remote server, but CREATE and DROP commands can also be executed.

While the original configuration of remote servers will add explicit ENGINE EDA SET CONNECTION_ATTRIBUTES node lines to the selected profile, the sever also looks at the its communication file first to form the list of available target nodes. The result (unlike other adapter engines) is that the default remote node is not typically the first ENGINE EDA SET CONNECTION_ATTRIBUTES node line encountered in the profile.

There are two command options for setting which connection is used, as well as commands for testing connection status and passing alternate ID/password information. Additionally, the amper variables &EDASERVER and &EDAUSER will be populated with the current connection target node and ID.

Syntax: How to Set the Connection for the Next Request

Issue the following command:

SQL EDA SET SERVER node

where:

node

Is a valid configured node.

Syntax: How to Set the Connection for the Remainder of the Session

Issue the following command:

SQL EDA SET DEFAULT_CONNECTION node

where:

node

Is a valid configured node.

Alternately, you can use the following syntax:

REMOTE DEST = node

Syntax: How to Test Connection Status

Issue the following command:

SQL EDA PING node

where:

node

Is a valid configured node.

A connection that is not in a "ready" state, will display an appropriate FOC error message and set &RETCODE and &FOCERRNUM which can in turn be used in Dialogue Manager syntax to direct the execution as needed for the application (that is, -GOTO EXIT or use an alternate node).

Syntax: How to Use Alternate ID and Password Combinations With SET CONNECTION_ATTRIBUTES

Issue the following command:

SQL EDA SET CONNECTION_ATTRIBUTES node/id,password

where:

node

Is a valid configured node.

id

Is a valid ID on the remote server.

password

Is a valid password for the ID.

It is important to remember that setting a connection does not make it the default connection so, typically, this command needs to be used with a SET SERVER or SET DEFAULT_CONNECTION command.

Syntax: How to Use Alternate ID and Password Combinations With REMOTE USER and REMOTE PASS

Enter the following commands, where the ID and password apply to the current default remote connection.

REMOTE USER = id  
REMOTE PASS = password

where:

id

Is a valid user ID on the remote server.

password

Is a valid password for the ID.

Syntax: How to Check Available Servers

SQL EDA ? SERVERS

Syntax: How to Execute a Stored Procedure Using Remote Execution

You can execute stored procedures by issuing the command:

SQL EDA EX rpcname parm1, parm2, ...
END

where:

rpcname

Is a procedure on the server.

parm1, parm2,...

Are character strings sent to the server (they are the same as parameters you can pass on the execution line of a FOCEXEC).

Syntax: How to Execute Locally Stored Commands on a Remote Connection

You can execute locally stored commands on a remote connection using the following syntax:

-REMOTE BEGIN   
command1  
command2  
command3
...
-REMOTE END

where:

command1, command2, command3 ...

Are any number of commands or lines within a procedure (for example, the lines within a TABLE FILE ... END request).

The default remote connection is the target node where the code executes. Use SET DEFAULT_CONNECTION or REMOTE DEST to change the execution destination.

Any amper variables within the commands are resolved locally before shipment to the remote connection for execution.

Direct Dialogue Manager dash commands (for example, -SET, -IF, -GOTO) and amper variables that are expected to be resolved on the remote machine are not allowed because they are resolved first by Dialogue Manager on the local machine. You can use Dialogue Manager commands and variables indirectly by delaying resolution using a technique where the commands are hidden in local amper variables as in this example:

-SET &GOWHERE = 'STEP1' ; 
-SET &DASHGOTO = '-GOTO' ;
-SET &DASHSTEP1 = '-STEP' ;
-SET &DASHSTEP2 = '-STEP2' ;
-SET &DASHSTART = '-START' ;
-SET &DASHEND = '-END' ;
-REMOTE BEGIN
&DASHSTART
&DASHGOTO &GOWHERE
&DASHSTEP1
...
&DASHGOTO END
&DASHSTEP2
&DASHEND
-REMOTE END

Syntax: How to Query Adapter Settings

To view the current adapter parameter settings, issue the command:

SQL EDA ?

The output is:

(FOC1450) CURRENT EDA INTERFACE SETTINGS ARE :
(FOC1446) DEFAULT DBSPACE IS                  -  : IBIEDA
(FOC1449) CURRENT SQLID IS                    -  : USER1
(FOC1444) AUTOCLOSE OPTION IS                 -  : ON FIN
(FOC1496) AUTODISCONNECT OPTION IS            -  : ON FIN
(FOC1499) AUTOCOMMIT OPTION IS                -  : ON COMMAND
(FOC1441) WRITE FUNCTIONALITY IS              -  : OFF
(FOC1445) OPTIMIZATION OPTION IS              -  : ON
(FOC1484) SQL ERROR MESSAGE TYPE IS           -  : DBMS
(FOC1552) INTERFACE DEFAULT DATE TYPE         -  : NEW

WebFOCUS

Feedback