Migration from Sybase to Oracle - Pro*C DECLARE STATEMENT

From: Renato Fabiano <renatofabiano_at_hotmail.com>
Date: 27 Dec 2001 07:25:09 -0800
Message-ID: <2358ca76.0112270725.2e8e5fc3_at_posting.google.com>


Does exist a way to encapsulated embedded SQL statements in a C library? This library executes database cursor operations. Then it need to return a opaque variable referencing the original SQL statements in order to be used by client programs between different library routine calls.

Client modules don't need to know details about embedded SQL nor need to be preprocessed by Pro*C.

Actually, I'm migration a C library that was previously developed using Sybase Anywhere to Oracle Server.

This library has functions like:
LibSQLOpenCursor(), LibSQLPrepareCursor, LibSQLFetchCursor, LibSQLCloseCursor() and so on.

The function LibSQLOpenCursor declares (Sybase syntax): EXEC SQL DECLARE a_sql_statement_number id_sql_command; And 'id_sql_command' is used at OPEN CURSOR statement and then is returned to caller; it is passed as a parameter to the other functions too.
All embedded SQL commands like PREPARE and DECLARE CURSOR are encapsulated into LibSQL.sqc (or .pc) program that uses 'id_sql_command' to reference the original statement.

A similar declaration in Pro*C could be: EXEC SQL DECLARE my_statement STATEMENT; Then, 'my_statement' can be used with PREPARE, DECLARE CURSOR, etc.

Although, 'id_sql_command' is a 'short int' host variable that can be passed as a parameter, but 'my_statement' is only a reference used internally by the Pro*C precompiler and I can't use it as a function parameter.

Thanks in advance,

Renato Fabiano. Received on Thu Dec 27 2001 - 16:25:09 CET

Original text of this message