获取oracle查询结果问题

mythad 2009-06-20 08:34:40
今天用了一下oracle,写了个语句不知道怎么获取结果,各位帮忙看看:
string strCommand = "
begin declare t number(6); begin insert into DepartmentAnnounce(id,Title,Content) values(Departmentannounce_Sequence.nextval,:Title); select Departmentannounce_Sequence.currval into t from dual; end;end;";

那个into t是后加上去的,不太明白为什么一定要这个into clause?
本以为这样可以返回结果:
con = new OracleConnection(connectionString);
con.Open();
OracleCommand command = new OracleCommand(context, con);
add(command);//一个委托,用于添加参数的
return command.ExecuteOracleScalar();
可是结果为0.
各位看看哪里有问题呢?应该怎样做才能得到那个值(t)?谢谢了!
...全文
61 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
qldsrx 2009-06-20
  • 打赏
  • 举报
回复
你要获取那个t?那你得自己写一个Oracle存储过程,让那个t成为输出参数即可。Oracle的事务处理中是无法返回任何结果集的,带事务的过程必须使用存储过程才可以返回想要的内容,通过输出型参数。

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧