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 StatementsHow You Can Use the Select Statement GenericallyYou can use a standard select statement when you do not know the databasetable until runtime, provided you know the column names. Assume, forexample, that you have several identically structured tables—po91, po92, andpo93—that store purchase order information. You can write a single selectstatement to access all the purchase order tables as follows:1. Use a variable to reference the table name.You must notify the DBMS to interpret the variable representing the tablename by preceding the variable with a leading colon (:).2. Supply the table name at runtime.The following statement selects data from table tblname into known fields onthe form. The actual table name is substituted at runtime.select ponum as :field1, podate as :field2,vendorname as :field3from :tblname;If you also do not know the names of the columns until runtime, you can builda valid select statement using the execute immediate statement. However, youmust know the name and data type of the variables that are to receive thedata. If you do not have the necessary information about the target variables,create an SQLSelect object or a query object to build the retrieval statementdynamically.For more information about dynamic query creation, see How You Can Accessa Database with DataStream Objects (see page 165) and How You Can UseQuery Objects (see page 177). For more information about the executeimmediate statement, see the Language Reference <strong>Guide</strong> online help.Errors Originating in Called 3GL ProceduresMany OpenROAD applications call 3GL procedures. If the 4GL calls anEmbedded SQL routine that does not switch sessions, the status from the lastquery issued by the Embedded 3GL routine is available to 4GL. After the 3GLroutine returns control to the 4GL, the 4GL can send a user event to astandard error-handling procedure to process the error.Working with a Database 151

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

Saved successfully!

Ooh no, something went wrong!