Home > Database > Mysql Tutorial > body text

Oracle事务处理多条sql语句

WBOY
Release: 2016-06-07 17:04:43
Original
1249 people have browsed it

问题,执行一段代码反回一个字符串,这个串中就是要执行我多条SQL语句。怎样让它在ORACLE中通过呢。想来想去想到了动态SQL,EXEC

问题,执行一段代码反回一个字符串,这个串中就是要执行我多条SQL语句。怎样让它在Oracle中通过呢。想来想去想到了动态SQL,EXECUTE IMMEDIATE 这是一个解析和执行标准SQL语句的语法。只要在这条字符串中格式化一下我们要执行的语句就可以了,比如这条要执行的多条SQL的字符串为:

delete tableA where Aid=1;update tableB where Bid=2;insert into tableC values(id,3,4);

像这样的SQL语句想一起执行是不可以的,,只要加点格式化就OK了,

要这样:BEGIN EXECUTE IMMEDIATE 'delete tableA where Aid=1';EXECUTE IMMEDIATE 'update tableB where Bid=2';EXECUTE IMMEDIATE 'insert into tableC values(id,3,4)';END;

注意,一定要写好格式,比如END后的分号。这样就可以在ORACLE中执行这个字符串了。

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!