Previous Topic Next topic Print topic


ASSOCIATE LOCATORS Examples

The statements in the following examples are assumed to be in COBOL programs.

Use result set locator variables LOC1 and LOC2 to get the result set locator values for the two result sets returned by stored procedure P1. Assume that the stored procedure is called with a one-part name from current server SITE2.

 EXEC SQL CONNECT TO SITE2;  
 EXEC SQL CALL P1; 
 EXEC SQL ASSOCIATE RESULT SET LOCATORS (:LOC1, :LOC2) 
          WITH PROCEDURE P1;

Repeat the scenario above, but use a two-part name to specify an explicit schema name for the stored procedure to ensure that stored procedure P1 in schema MYSCHEMA is used.

 EXEC SQL CONNECT TO SITE2;  
 EXEC SQL CALL MYSCHEMA.P1; 
 EXEC SQL ASSOCIATE RESULT SET LOCATORS (:LOC1, :LOC2) 
          WITH PROCEDURE MYSCHEMA.P1;

Use result set locator variables LOC1 and LOC2 to get the result set locator values for the two result sets that are returned by the stored procedure named by host variable HV1. Assume that host variable HV1 contains the value SITE2.MYSCHEMA.P1 and the stored procedure is called with a three-part name.

 EXEC SQL CALL SITE2.MYSCHEMA.P1; 
 EXEC SQL ASSOCIATE LOCATORS (:LOC1, :LOC2) 
          WITH PROCEDURE :HV1;

The preceding example would be invalid if host variable HV1 had contained the value MYSCHEMA.P1, a two-part name. For the example to be valid with that two-part name in host variable HV1, the current server must be the same as the location name that is specified on the CALL statement as the following statements demonstrate. This is the only condition under which the names do not have to be specified the same way and a three-part name on the CALL statement can be used with a two-part name on the ASSOCIATE LOCATORS statement.

 EXEC SQL CONNECT TO SITE2; 
 EXEC SQL CALL SITE2.MYSCHEMA.P1; 
 EXEC SQL ASSOCIATE LOCATORS (:LOC1, :LOC2) 
          WITH PROCEDURE :HV1;
Previous Topic Next topic Print topic