DBMS_SQL Question
From: Monique M Morris <mmorris_at_usc.edu>
Date: 1996/08/14
Message-ID: <32128022.9BE_at_usc.edu>#1/1
Date: 1996/08/14
Message-ID: <32128022.9BE_at_usc.edu>#1/1
Hi all,
I have two questions regarding DBMS_SQL.
- Is it possible to manipulate a table's ROWID, that is to do the following and if so, how should V_ROWID be defined (ROWID?, CHAR(18)? , VARCHAR2(18)?, other?)
V_string := 'SELECT custid, rowid from CUST where custid > :x';
dbms_sql.parse(curs, v_string, DBMS_SQL.V7);
dbms_sql.bind_variable(curs, '':x', p_inputid);
dbms_sql.define_Column(curs, 1, v_custid);
dbms_sql.define_Column(curs, 2, v_rowid);
dummy := dbms_sql.execute(curs);
LOOP
if dbms_sql.fetch_rows(curs) = 0 then
exit;
end if;
dbms_Sql.column_value(curs,1, v_custid);
dbms_sql.column_value(curs,2, v_rowid);
...
END LOOP;
dbms_sql.close_cursor(curs);
The complete procedure works when I take all references to the
V_ROWID out... with V_ROWID in, I get an ORA-01001 (invalid cursor) even
though I can create a static cursor with ROWID without a problem.
2) The second question relates to BIND_VARIABLE. I am able to successfully bind
within the WHERE clause but not the tablename itself.
For example:
v_string := 'SELECT custid from :TAB where custid > :X';
dbms_sql.parse(curs, v_string, DBMS_SQL.V7);
dbms_Sql.bind_variable(curs, ':TAB', p_tab);
dbms_sql.bind_variable(Curs, ':X', v_inputid);
dbms_sql.execute(Curs);
This method will eventually give me an ORA-00903 (invalid table name) however
when I construct the string using concatenation it works just fine. All
examples I have seen use concatenation like
v_string := 'SELECT custid from '||p_tab||' where custid > :X'
and I am wondering if there is an Oracle reason for this. It seems the SGA
would be more efficiently used if I could use a bind variable (or is this
getting to the heart of the problem?)
-- Monique M Morris Sr Oracle Applications Developer Childrens Hospital Los AngelesReceived on Wed Aug 14 1996 - 00:00:00 CEST
