Products Downloads


French version


 


ADELIA

VADELIA

SADELIA

WADELIA

EADELIA

(I/B)

(I/B) (S)

(B) (S)

(I/B) (S)

(B) (S)


Warning: In the case of ADELIA programs, this instruction is only compatible with the RPG generator.


Section for use

All


Syntax

OPEN_SQL_C CursorName WithParameters


WithParameters

None | WITH SeriesVarId



Description

This instruction opens the cursor CursorName.


You must open a cursor declared with the CURSOR instruction before being able to read it.


The parameter WITH is only authorised if the cursor is dynamic (dynamic query associated with an alphanumeric variable and not with an SQL statement): corresponding to SQL USING, it indicates the host variables which will substitute the "?" contained in the query variable. The advantage over directly putting the parameter values in the dynamically constructed query is that it simplifies the code writing, but it also ensures better execution performance if the cursor is executed several times with different substitution values.


After this instruction has been run, it is possible to test the SQL return code with the *SQLCODE reserved word.


Example

* Declaration of a cursor in the DECL PGM section (Visual Adelia syntax):

CURSOR CURS_CUST_COUNTRY CUSTOMER *COND(CCUST_COUNTRY = :ZCOUNT_NAME)


* Cursor is opened, matching records are read and inserted

* into the graphical list CUST_LST

CLEAR_LST CUST_LST:LIST

OPEN_SQL_C CURS_CUST_COUNTRY

READ_NX_SQL_C CURS_CUST_COUNTRY

DO_WHILE *SQLCODE = *NORMAL

PRESENT CUSTOMER

INSERT_ELT CUST_LST:LIST

READ_NX_SQL_C CURS_CUST_COUNTRY

REDO

CLOSE_SQL_C CURS_CUST_COUNTRY


* Dynamic cursor with use of WITH

DYN_CURS:QUERY CURSOR

QUERY = 'select CNOM_CLI from COMMERCIAL.CLIENTS where CCITY = ?'

WCITY 'PARIS' ??

OPEN_SQL_C DYN_CURS WITH WCITY


↑ Top of page

  • Aucune étiquette