x.509
x.509

Reputation: 2235

Question related to DBMS_SQL.PARSE

I have a query like

queryStr := 'SELECT col1, col2, col3, col4 FROM Table1 WHERE date_created >= ';

and then i see the following statement

DBMS_SQL.PARSE (cursor_handle, queryStr || ':date', DBMS_SQL.NATIVE);
DBMS_SQL.BIND_VARIABLE (cursor_handle, 'date', dateVariable);

Now my question is, how come dbms_sql.parse is using the variable :date since there is no :date placeholder in the query i.e. queryStr?

Upvotes: 2

Views: 2549

Answers (1)

Vincent Malgrat
Vincent Malgrat

Reputation: 67802

your code is equivalent to this:

DBMS_SQL.PARSE (cursor_handle,
                'SELECT col1, col2, col3, col4 
                   FROM Table1 
                  WHERE date_created >= :date', 
                DBMS_SQL.NATIVE);
DBMS_SQL.BIND_VARIABLE (cursor_handle, 'date', dateVariable);

A query is parsed in the first statement. This statement has a bind variable (:date). The value of this bind variable is given in the second statement.

Upvotes: 3

Related Questions