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 StatementsTo fetch the values from all eight columns in the same order specified in theselect statement, use the following statement:fetch cust_cursor into :acctno, :cphone,:cname, :caddr, :ccity, :cdistrict,:cstatus, :cacctbal;Because the variables in the fetch statement match the number, data type,and order of specification of the select statement's expressions, you need notspecify column names. The fetch statement puts the retrieved values (one rowat time) into the specified variables.Similarly, if you fetch a subset that begins with the first column returned bythe select, continues in the order listed in the select, and stops before all arelisted, it is not necessary to specify column names. For example, the followingstatement fetches the first, second, and third columns (acctno, cphone,cname) returned by the select:fetch cust_cursor into :acctno, :cphone, :cname;However, whenever you fetch column values out of order (that is, do not startwith the first selected column and continue in the order of the select), youmust identify the column. For example, to fetch only the customer's name andstatus using the example open statement, specify the column names:fetch cust_cursor into :cname=cname,:cstatus=cstatus;How You Can Update or Delete a RowWhether you fetch all or some of the selected column values, the variablesthat receive the column values and their associated columns must havecompatible data types.For more information about the open and fetch cursor statements, see theLanguage Reference <strong>Guide</strong> online help.After you have fetched a row, you can update values in the row or delete therow if the cursor was opened to allow for updates and deletes. There areversions of the update and a delete 4GL statement specifically for use withcursors.Working with a Database 161

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

Saved successfully!

Ooh no, something went wrong!