10.07.2015 Views

Programming Guide - Actian

Programming Guide - Actian

Programming Guide - Actian

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

How You Can Access a Database with Standard SQL StatementsExample—Singleton SelectThe following example represents a singleton select. Given an account number,it selects information about a customer from a table that contains customerinformation:declarecname = varchar(100) not null;cphone = varchar(10) not null;enddeclare{.../***/Given an account number, get customer information*/select cname as :cname,cphone as :cphonefrom customerwhere acctnum = :account_number;...}Example—Select LoopSuppose that cust is a class with attributes that correspond to columns in thecustomer table. The following select loop extracts information from thecustomer table and stores it in an array of cust objects:declarecust_arrienddeclare{...= array of cust;= integer not null;i = 1;select acctnum as cust_arr[I].accnt,cname as cust_arr[I].name,cphone as cust_arr[I].phone}fromorder by{};...customercnamei = i + 1;How You Can Select Data into Reference or Array VariablesRegardless of whether you retrieve one row or multiple rows, when youretrieve data into a reference or array variable, the select statement must seethe individual attributes of the variable rather than the variable as a whole.150 <strong>Programming</strong> <strong>Guide</strong>

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

Saved successfully!

Ooh no, something went wrong!