skip to main content

Embedded SQL Statements : SELECT

SELECT
The SELECT statement returns values from tables.
General format
EXEC SQL [AT Database]
  SELECT Select-Options [ INTO Host-Variable, ... ] FROM From-Options 
                        [ WHERE Search-Condition  ]  [Options]
Syntax rules
1.
Host variables used in Search-Condition and Select-Options, if any, are replaced by question marks (?) and then passed to the driver without further check.
2.
General rules
1.
When WHERE is specified, only rows matching Search-Condition are returned.
2.
When Search-Condition is not specified, all rows are returned.
3.
When Host-Variable is a host variable declared as a group-item, the runtime can use all subordinate items as separate values instead of using the group-item as a single value. To enable this feature, compile with the -cghv option.
4.
5.
Database identifies the active connection that will execute the query and must be previously defined using a Format 4 DECLARE statement.
Examples
Select customer name for a given customer code
move spaces to ws-cust-name
move 2020   to ws-cust-code
exec sql
     select customer_name into :ws-cust-name
       from customers

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left