Statement
Type or paste an SQL statement into the Statement field. If the Statement field already contains an SQL statement, you can edit it (even if the SQL statement was created using the SQL Wizard).
The AME does not check the format of the SQL statement for validity. If the format is invalid, a run time error occurs when the macro runtime processes the SQLQuery action.
You can spread the SQL statement over several lines or write it
all on one line. Figure 1 and Figure 2 show the same SQL statement written over
several lines and written as one line. Either way is correct.
Figure 1. SQL statement
written on several lines
SELECT
*
FROM
SQLTEST.EX01
WHERE
(
( SQLTEST.EX01.DESCRIPT is not null )
)
Figure 2. Same
SQL statement written on one line
SELECT * FROM SQLTEST.EX01 WHERE((SQLTEST.EX01.DESCRIPT is not null))
Remember that if you are using the advanced macro format you must
enclose the SQL statement in single quotes and follow the rules for
special characters. Below, Figure 3 and Figure 4 show the same SQL statement written for the
basic macro format and for the advanced macro format:
Figure 3. SQL statement written for the
basic macro format
select * from hodtest.ex01 where
((hodtest.ex01.descript='Edit Products'))
Figure 4. Same
SQL statement written for the advanced macro format
'select * from hodtest.ex01 where
((hodtest.ex01.descript=\'Edit Products\'))'
You can use either upper case or lower case for reserved words
(such as select) and database names and fields (such as hodtest.ex01.descript),
but you must use exact case for matching strings (such as 'Edit
Products'). Thus the two SQL statements in Figure 5 are equivalent:
Figure 5. Example of equivalent
upper case and lower case
select * from hodtest.ex01 where
((hodtest.ex01.descript='Edit Products'))
SELECT * FROM HODTEST.EX01 WHERE
((HODTEST.EX01.DESCRIPT='Edit Products'))