Search This Blog

Tuesday, December 29, 2009

Using SQL Definitions with SQLExec

There are times when SQLExec is the appropriate function to use. If you only need a single row,use SQLExec, which can only SELECT a single row of data. If your SQL statement retrieves more than one row of data, SQLExec outputs only the first row to its output variables and discards subsequent rows. This can improve single-operation performance.

However, you don't have to hardcode your SQL statement. SQLExec is enhanced to accept the SQL definitions, and the new meta-SQL, so you can reuse your SQL statements.

For example, consider the following statement:

SQLExec("Update %Table(:1) set %UpdatePairs(:1) where %KeyEqual(:2)", &REC,&FIELD);

If you have created a SQL definition with this SQL statement and named it MYUPDATE, you

can use it with SQLExec as follows:

SQLExec(SQL.MYUPDATE, &REC, &FIELD);

1 comment:

  1. AnonymousJune 11, 2014

    consider that you dont use any metasql commands inside a SQL definition. Therefore you just intend to write a query just like writing in a sqlexec("").

    Now will there be a performance difference between sql definition and sqlexec?

    ReplyDelete