10.07.2015 Views

Programming Guide - Actian

Programming Guide - Actian

Programming Guide - Actian

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

How You Can Access a Database with Standard SQL StatementsHow You Can Declare a CursorBefore you can open a cursor, you must create the CursorObject object for thenew cursor by declaring a global or local reference variable of typeCursorObject. The syntax is:cursor_var_name = CursorObjectFor example, the following code line declares a reference variable namedcust_cursor that points to a cursor object:cust_cursor = CursorObject;How You Can Open and Position a CursorYou can use the open statement to perform the following operations:• Open a cursor in the database, specifying whether:– The cursor can update or delete rows that are fetched– Updates should be deferred or direct• Associate a select statement with the cursor and position the cursorimmediately before the first row in the select statement's result table• Set the cursor's State attribute to CS_OPENTo access the rows in the result table, use the fetch statement. This statementperforms the following tasks:• Advances the cursor one row in the result table• Places the values in the indicated columns into the specified variables• Sets the cursor's State and RowCount attributesEach execution of a fetch statement fetches one row of the result table. Thesyntax lets you retrieve the values from every column in the result table orfrom some subset of the columns.If you fetch all of the retrieved values in the order specified in the selectstatement, you do not need to name the columns in the fetch statement.For example, assume you issued the following open statement to retrieve thevalues in eight columns from the customer table:open cust_cursor for select acctno, cphone,cname, caddr, ccity, cdistrict, cstatus,cacctbalfrom customer for direct update of acctno,cphone, cname, caddr, ccity, cdistrict,cstatus, cacctbal;160 <strong>Programming</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!