skip to main content

Embedded SQL Statements : OPEN

OPEN
The OPEN statement executes the SELECT statement the cursor refers to and positions the cursor immediately before the first row returned.
General format
EXEC SQL [AT Database]
  OPEN { Cursor-Name } [ USING Host-Variable, ... ] [ INTO Host-Variable, ... ]
Syntax rules
1.
Cursor-Name is a Nonnumeric Literal, as defined in the Definitions section of the Preface of this document.
2.
Host-Var must be USAGE HANDLE
3.
General rules
1.
Cursor-Name must be previously defined by a DECLARE statement.
Examples
Declare, open and fetch a cursor
exec sql 
   declare cust_cur  cursor for select * from customers
exec sql 
   open cust_cur
end-exec     
perform until 1 = 2
   exec 
      sql fetch next cust_cur into :ws-cust-code, :ws-cust-name
   end-exec
   display "code: " ws-cust-code " name: " ws-cust-name
   if sqlcode = 100
      exit perform
   end-if
exec sql 
   close cust_cur

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left