PHP oci_execute 用于多条语句 [英] PHP oci_execute for Multiple Statements

查看:29
本文介绍了PHP oci_execute 用于多条语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 PHP 上的单个 oci_execute() 调用中发出多个 INSERT 语句.问题是我收到此错误:

I'm trying to issue multiple INSERT statements within a single oci_execute() call on PHP. The problem is that I get this error:

ORA-00911: invalid character

我猜它是每个语句之后的 ;.

I'm guessing it's the ; after each statement.

现在,我的问题是如何制作多个可以在 oci_execute() 中工作的 INSERT 语句?

So now, my question is how do I make multiple INSERT statements that would work within oci_execute()?

这是我目前的查询:

INSERT INTO tbl (id, name) VALUES(1, 'John');
INSERT INTO tbl (id, name) VALUES(2, 'Martha');
INSERT INTO tbl (id, name) VALUES(3, 'Richard')

编辑:

请注意,我的查询末尾没有 ; 因为我使用的是 SQL 语句.

Note that there is no ; at the end of my query because I'm using SQL statements.

推荐答案

只需将所有语句包装到匿名 PL/SQL 块中即可:

Just wrap all statement into anonymous PL/SQL block:

BEGIN
    INSERT INTO tbl (id, name) VALUES(1, 'John');
    INSERT INTO tbl (id, name) VALUES(2, 'Martha');
    INSERT INTO tbl (id, name) VALUES(3, 'Richard');    
END;

Oracle 不支持批量命令.匿名 PL/SQL 块作为单个命令执行.

Oracle doesn't support batch of commands. Anonymous PL/SQL block is executed as single command.

这篇关于PHP oci_execute 用于多条语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆