Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Get bind variables name from SQL string or cursor

jariolaDec 16 2011 — edited Dec 19 2011
Hi,

Is there way get bind variables name from SQL string or cursor?

Example
DECLARE
  l_sql VARCHAR2(2000);
  desctab DBMS_SQL.DESC_TAB;
  curid   PLS_INTEGER;
BEGIN

  l_sql := 'SELECT * FROM emp WHERE mgr = :X and deptno = :Y';

  curid := dbms_sql.open_cursor;
  dbms_sql.parse(curid, l_sql, dbms_sql.NATIVE);
  ....
END;
What I mean with SQL string:
I like get using some function from above code variable l_sql all bind variables.
In this case function should return e.g array where is :X and :Y

Return bind variable names from cursor I mean same but instead string I pass cursor number.

Is there sucks ready function or can some share custom code for this purpose?

Thanks advance

Regards,
Jari

http://dbswh.webhop.net/dbswh/f?p=BLOG:HOME:0Regards,

Edited by: jarola on Dec 19, 2011 2:44 AM

I did find there is undocumented function wwv_flow_utilities.get_binds in APEX packages that do what I want.
Example usage
set serveroutput on
DECLARE
  binds DBMS_SQL.varchar2_table;
BEGIN
  binds := wwv_flow_utilities.get_binds('select :P1_TEST from dual');
  FOR i IN 1 .. binds.count
  LOOP
    dbms_output.put_line(binds(i));
  END LOOP;
END;
/

anonymous block completed
:P1_TEST
But I would not like use these undocumented functions as those might change or not exists in future APEX versions.
Is there any documented function or custom function that do same as wwv_flow_utilities.get_binds?
This post has been answered by Billy Verreynne on Dec 19 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 16 2012
Added on Dec 16 2011
5 comments
1,373 views