Database Engines:odbc

Executing stored procedures Professional

Stored procedures can be created and deleted by ODBCDBE through the SQL CMD command:

#include "sqlcmd.ch" 
PROC MAIN 
   // first connect, then: 
   SQL CMD (MemoRead("mybatch.sql")) 
RETURN 

The file mybatch.sql can contain any valid SQL-statement including CREAE PROCEDURE, like:

CREATE PROCEDURE testproc 
 AS 
 BEGIN 
  INSERT INTO orders VALUES (1, 'AX19292',222) 
  SELECT * FROM customers 
  SELECT * FROM orders 
 END 

A stored procedure is executed either by constructing an SQL statement, or by using the EXECSP command. The result is returned in a workarea.

USE ("EXECUTE testproc;") NEW ALIAS testproc 
// or 
EXECSP "testproc" 

The EXECSP-command takes care of returning user-defined errors of the stored procedure as runtime errors.

Feedback

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.