PHP oci_execute for Multiple Statements

帅比萌擦擦* 提交于 2020-08-05 05:35:20

问题


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.

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

Here's my query so far:

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

EDIT:

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


回答1:


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 doesn't support batch of commands. Anonymous PL/SQL block is executed as single command.



来源:https://stackoverflow.com/questions/33945939/php-oci-execute-for-multiple-statements

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!