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 DataStream ObjectsContinuing our example, the following code provides the name of each targetfield to the Expression attribute and sets the IsSelectTarget attribute to TRUEfor each column:/* Fill in the Expression and IsSelectTarget for** every column to be retrieved. */ss.Columns[1].Targets[1].Expression ='customer.acctno';ss.Columns[2].Targets[1].Expression ='customer.cphone';ss.Columns[3].Targets[1].Expression ='customer.cname';ss.Columns[4].Targets[1].Expression ='customer.caddr';...for i = 1 to ss.Columns.LastRow doss.Columns[i].Targets[1].IsSelectTarget = TRUE;endfor;end;The where clause can be specified to select a subset of rows from the table.The following code illustrates getting either all accounts or only accounts thatare closed (cstatus = 0):if (get_all_accounts = TRUE) then/*** Fetch all customers*/wclause = ' order by cname';elseendif;/*** Fetch customers whose accounts are closed.*/wclause = ' where cstatus = 0 order by name';The text of an SQLSelect object's query is stored in its Query attribute. Thedata type of the Query attribute is StringObject. You can load the Queryattribute directly with the text of a select statement or create the text fromvariables that contain pieces of the select statement.The following statement sets the value of the Query attribute from its twovarchar variables, selectstring and wclause:ss.Query.Value = selectstring + wclause;Although the complete select statement is assigned to the Query's Valueattribute, the actual data retrieval occurs only when you invoke DataStream'sOpen method.Working with a Database 169

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

Saved successfully!

Ooh no, something went wrong!