Command SQL Professional
Executes an SQL statement
SQL <statement> [VIA <session>]
or
SQL <statement> INTO <variable> [VIA <session>]
or
SQL CMD <statement> [VIA <session>]
 The command SQL executes an SQL statement. Depending on which one of the various forms has been used, a workarea is open after execution to fetch the results.
// This example shows how to use the various 
// forms of the SQL command. 
#include "sqlcmd.ch" 
PROCEDURE main(cDsn) 
LOCAL x, oSession 
LOCAL cSqlCmd 
     CREATE CONNECTION INTO oSession DATASOURCE (cDsn) 
     // execute an SELECT statement 
     // and show results 
     SQL "SELECT * FROM customer WHERE custId > 1000" 
     LIST ALL 
     CLOSE 
     // get the sum of orders into the variable x 
     SQL "SELECT SUM(price) FROM orders WHERE order_id = 1000" INTO x 
     ? "Total of order 1000:", x 
     // execute an SQL statement on the server 
     // which does not return any results 
     SQL CMD "SET LANGUAGE 'Italiano'" 
     // check if the command had any effect 
     SQL "SELECT @@LANGID AS 'Language ID'" INTO x 
     ? "Language-Id:", x 
     // declare long SQL statements in TEXT-blocks 
     // and store it into a variable 
     TEXT INTO cSqlCmd 
         SELECT @@CONNECTIONS AS 'Login Attempts', 
               GETDATE() AS 'Today''s Date and Time' 
     ENDTEXT 
     // submit command using a variable holding 
     // the SQL statement 
     SQL (cSqlCmd) 
     LIST ALL 
     CLOSE 
RETURN 
PROCEDURE DbeSys 
   DbeLoad( "ODBCDBE" ) 
   DbeSetDefault( "ODBCDBE" ) 
RETURN 
    If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.