100求解OracleCommand.ExecuteNoQuery的问题

Magicwords 2009-03-09 03:40:32
OracleCommand.ExecuteNoQuery这个方法不能一次执行多条语句吗?SQL Server的怎么可以,,?

比如

alter table B add constraint pk_a primary key(ID);
create sequence seq_B;
create or replace trigger trig_B
before insert on B
for each row
begin
select seq_B.nextval into:new.id from dual;
end;

这些语句一起放到sqlText变量里,然后传给OracleCommand.ExecuteNoQuery一次性执行,,,居然提示说无法识别的字符,一条一条的执行就可以,在oracle自带的那个工具中也不能一起执行多条?我试了下,提示说一次只能执行一条

另外,建好触发器后,执行时提示说trig_B无效

请达人指点下
...全文
118 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
周公 2009-03-09
  • 打赏
  • 举报
回复
SQL中通常会跟一个GO关键字。
周公 2009-03-09
  • 打赏
  • 举报
回复
alter table B add constraint pk_a primary key(ID); 
create sequence seq_B; //每次都要执行这条语句?不是吧?应该让这条语句立即执行
create or replace trigger trig_B
before insert on B
for each row
begin
select seq_B.nextval into:new.id from dual;
end;


PLSQL语句逻辑有问题吧?
Magicwords 2009-03-09
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 hbxtlhx 的回复:]
begin
sql1;
sql2;
...
end;
[/Quote]


我这样的时候还是有错
begin
create table simon_example
(
id number(4) not null primary key,
name varchar2(25)
);
end;

提示错误为
ORA-06550:第2行,第1列;
PLS-00103:出现符号"Create"在需要下列之一时:
。。。
。。
这是什么原因啊,?

select 也不行,
北京的雾霾天 2009-03-09
  • 打赏
  • 举报
回复
begin
sql1;
sql2;
...
end;
晓轩 2009-03-09
  • 打赏
  • 举报
回复
或者使用另一种方法begin end参看
http://www.cnblogs.com/janisbone/articles/1285246.html
晓轩 2009-03-09
  • 打赏
  • 举报
回复
参看
http://starlianhaidong.blog.163.com/blog/static/29059067200882635048803/

16,553

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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