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 imported or was created using the SQL Wizard).

The Macro Editor 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.

If you are unfamiliar with SQL statements, it is a very good idea to build the statement and test it in a Database On-Demand session, and then copy and paste the statement into the Statement field. Then you can be sure that the syntax and content of your SQL statement are correct.

You can spread the SQL statement over several lines (as it appears on the Review tab of a Database On-Demand session) 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
   ZIETEST.EX01
WHERE
   (
      ( ZIETEST.EX01.DESCRIPT is not null )
   )
Figure 2. Same SQL statement written on one line
SELECT * FROM ZIETEST.EX01 WHERE((ZIETEST.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 (see The basic macro format versus the advanced macro format). 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 zietest.ex01 where
      ((zietest.ex01.descript='Edit Products'))
Figure 4. Same SQL statement written for the advanced macro format
'select * from zietest.ex01 where
      ((zietest.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 zietest.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 zietest.ex01 where
      ((zietest.ex01.descript='Edit Products'))
SELECT * FROM ZIETEST.EX01 WHERE
      ((ZIETEST.EX01.DESCRIPT='Edit Products'))