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 DataStream ObjectsHow You Can Specify the QueryWhen creating an SQLSelect object, you must first specify the query, whichinvolves:• Creating the SQLSelect object• Providing an SQL query• Providing specifications for at least one target field or variable for eachcolumn selectedExcept for building the where clause, you might set up the query in an initializeblock.The following code from the initialize block declares the necessary variablesand assigns the query text to the selectstring variable:initialize () =declaress = SQLSelect;selectstring = varchar(200) not null;wclause = varchar(60) not null;...enddeclarebeginselectstring = 'select acctno, cphone, cname,caddr, ccity,'+ ' cstate, czip, cdistrict, cstatus,cacctbal' +' from customer';Because the ss SQLSelect object is declared without specifying default null, itis created at the same time that it is declared. If your application may neverneed the SQLSelect object, declare it with default null and later, when theSQLSelect object is required, explicitly create it using the Create method. Forexamples of using the Create method, see Creating Dynamic Frames (seepage 363).In addition to declaring necessary variables and providing the query text,specifying the query requires assigning the value in each database column toan SQLSelect target.Each column's value must be assigned to the SQLSelect's Columns attribute,which is an array of the QueryCol system class. The Columns attribute mustcontain at least one row for each column to be retrieved from the database.The syntax for assigning a column value to an SQLSelect target is:sqlselect_name.Columns[n].Targets[m].Expression = field_name | var_name | valueWorking with a Database 167

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

Saved successfully!

Ooh no, something went wrong!