Following the instructions in SOL26041 but want to know how to add the pl/sql initialize statements to the Pro*C/C++ pre-compiler since the compiler only accepts SQL statements and not pl/sql.
This is the portion I need to add to the pre-compilation code:
DECLARE
id varchar2(255);
BEGIN
id := DBMS_DEBUG.INITIALIZE('TOAD_EXAMPLE');
DBMS_DEBUG.DEBUG_ON;
END;
The Pro*C/C++ Pre compiler treats a PL/SQL block like a single embedded SQL statement. So, you can place a PL/SQL block anywhere in a program that you can place a SQL statement.
To embed a PL/SQL block in your Pro*C/C++ program, simply bracket the PL/SQL block with the keywords EXEC SQL EXECUTE and END-EXEC as follows:
EXEC SQL EXECUTE
DECLARE
...
BEGIN
...
END;
END-EXEC;
The keyword END-EXEC must be followed by a semicolon.
After writing your program, you pre compile the source file in the usual way.
When the program contains embedded PL/SQL, you must use the SQLCHECK=SEMANTICS command-line option, since the PL/SQL must be parsed by the Oracle Server. SQLCHECK=SEMANTICS requires the USERID option also, to connect to a server.
So the above example should look like this:
EXEC SQL EXECUTE
declare
id varchar2(255);
begin
id := DBMS_DEBUG.INITIALIZE('TOAD_EXAMPLE');
DBMS_DEBUG.DEBUG_ON;
END;
END-EXEC;