I’m looking to do a simple select statement to get back all the data from a table in oracle. Due to the nature of the ongoing project, the tables are constantly being updated and changed so I don’t have any solid designs.
I’m looking for a simple statement. This is all I need it to do.
Select * from myVariable
After searching I got this to compile
create or replace procedure "GET_TABLEINFO" (o_rc OUT sys_refcursor, inTableName IN varchar2) AS
BEGIN
execute immediate
'SELECT * FROM '||inTableName
using inTableName;
END;
but when I try to add it to a data table:
using (OracleConnection cn = new OracleConnection(connectionString))
{
OracleDataAdapter da = new OracleDataAdapter();
OracleCommand cmd = new OracleCommand();
cmd.Connection = cn;
cmd.InitialLONGFetchSize = 1000;
cmd.CommandText = "GET_TABLEINFO";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("o_rc", OracleDbType.RefCursor, ParameterDirection.Output);
cmd.Parameters.Add("inTable", OracleDbType.Varchar2, 60, inTableName, ParameterDirection.Input);
da.SelectCommand = cmd;
da.Fill(dt);
I get this
Edit:
I’m not sure how to set the cursor (first time using oracle, usually use SQLSERVER). The procedure should be simple. I pass in the table name, and I need to get the data from that table. Nothing fancy, no where clauses etc.
ORA-01006: bind variable does not exist ORA-06512: at
“ODS_DEV.GET_TABLEINFO”, line 4 ORA-06512: at line 1
1 Answer