kostafey / ejc-sql

Emacs SQL client uses Clojure JDBC.
279 stars 29 forks source link

multiple statements error #129

Closed sincebyte closed 4 years ago

sincebyte commented 4 years ago

I just use the multiple statements. An error appears , and it showes that "Error: ORA-00911: invalid character." But if I execute a single statement which does not contain ';' . Nothing wrong appears. Is this a bug? How to fix it ?

kostafey commented 4 years ago

@vanniuner, what is your database type? Could you also provide an example query you are trying to execute?

sincebyte commented 4 years ago

The database type is oracle. And the execute sql is the following

/
update JS_YF set F_DD='3063795' WHERE F_PKEY='2020030300003';
update JS_YF set F_SD='jxss' WHERE F_PKEY='2020031800001';
/

The output note: Error: ORA-00933: SQL command not properly ended Besides, I tried to use the insert command ,but it did not work .

However, I can execute by using the below

/
update JS_YF set F_DD='3063795' WHERE F_PKEY='2020030300003'
/
kostafey commented 4 years ago

First of all, please update with the lastest commit. Since you use :separator "/" in your database connection configuration you can't use ; as transaction delimiter, because you expect it as a part of SQL syntax. E.g. for Oracle databases symbol ; used in stored procedures code definitions. If you want to pass many statements (they will be executed as separate transactions) by a single command and obtain a list of results, you should provide the delimiter explicitly. E.g.

delimiter $$
update JS_YF set F_DD='3063795' where F_PKEY='2020030300003'$$
update JS_YF set F_SD='jxss' where F_PKEY='2020031800001'$$
/
select * from update JS_YF

or even like this:

delimiter ;
update JS_YF set F_DD='3063795' where F_PKEY='2020030300003';
update JS_YF set F_SD='jxss' where F_PKEY='2020031800001';
/
select * from update JS_YF
sincebyte commented 4 years ago

I try to execute multi statements, but it still reports an error even I use the delimiter ; or $$, like what you show to me. I use elpa install it , the version is: elpa/ejc-sql-20200308.1421

kostafey commented 4 years ago

The actual version at this moment is ejc-sql 20200325.1455 (https://melpa.org/#/ejc-sql), so please update it. Furthermore, please note, GNU Emacs 26.3 (or latest version) is required.

sincebyte commented 4 years ago

I appreciate your reply. I try it ,and it succeeds.