I want to prevent SQL from deleting comment statements on the c file created by pro*c precompilation

Asked 2 years ago, Updated 2 years ago, 88 views

pro*c is used to develop a business application that handles Oracle databases, but if you write the SQL portion embedded with comments (bound by /* to */) in the pc file and precompile it.

For example, write the following SQL statement in a pc file and

EXEC SQL AT:psz_dbname SELECT NAME FROM EMPLOYEE/*SQL-ID:selEmployee*/;

The precompiled and created c file will contain the following SQL:

sqlstm.stmt="SELECT NAME FROM EMPLOYEE";

Therefore, when the execution module compiled from this pc file is run and the above SQL is issued, the v$sqltext table is registered as follows:

SQL_TEXT
- - - - - - - - - -
SELECT NAME FROM EMPLOYEE;

However, the customer would like to register as follows so that they can quickly find the desired SQL in v$sqltext with a large amount of SQL being issued.

SQL_TEXT
- - - - - - - - - -
SELECT NAME FROM EMPLOYEE /* SQL-ID: selEmployee*/;

In this way, you can uniquely identify the SQL by searching for it in selEmployee.

Therefore, I really want to prevent SQL statements embedded with comments in the pc file from being deleted from the corresponding SQL statements in the c file created by precompilation, but I don't know how to do that.

I'm in big trouble.
If anyone knows, I would like to ask you to teach me
Thank you for your cooperation.

c sql oracle

2022-09-29 20:28

1 Answers

Why not write SQL comments in ANSI format?
The C preprocessor does not recognize this format as a comment, so we thought it would not be deleted.
※ As there is no environment, we have not been able to verify the behavior of this method.

EXEC SQL SELECT NAME FROM EMPLOYEE -- SQL-ID: selEmployee
;


2022-09-29 20:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.