开发者

Fetching multiple recordset using Oracledatareader - c# [closed]

开发者 https://www.devze.com 2023-02-18 00:08 出处:网络
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time,or an extraordinarily narrow situation that is not generally applic
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 11 years ago.

The sql variable may contain more than sql statement ... i am getting error (Invalid character) while executing the command cmd.ExecuteReader() ....

Psuedo:

....
string sql = @"SELECT * FROM table1 WHERE col1=:p1;" +
"SELECT MAX (col3) FROM table2  WHERE col2 = :p2 "
cmd = DBConnection.GetCommand(); // Get the connection
cmd.CommandText = sql;
cmd.Parameters.Clear();
cmd.Parameters.Add(":p1", "Somevalue1");
cmd.Parameters.Add(":p2", "somevalue2");
OracleDataReader re开发者_如何学Cader = cmd.ExecuteReader(); //Error: Invalid Character

if (reader.HasRows)
{
 reader.Read();
........
}

reader.NextResult();

.....


AFAIK Oracle does not allow the execution of multiple SQL statements in this fashion. You can sometimes get around it by wrapping the SQL statements in a PL/SQL anonymous block, e.g. "BEGIN SELECT ...; SELECT...; END;", but then you need to use an INTO clause on the SELECTs with bind variables as the targets in order to access the query results in the calling code.

0

精彩评论

暂无评论...
验证码 换一张
取 消