Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Query with values prepended by ampersand - works in Oracle but not in MySQL?

In MySQL, the statement below works:

mysql>insert into emp1(empno,empname,empsal,empcity) values (100,'vinay',10000,'USA');**

mysql> select * from emp1;
+-------+---------+--------+---------+
| empno | empname | empsal | empcity |
+-------+---------+--------+---------+
|   100 | vinay   |  10000 | USA     |
+-------+---------+--------+---------+

In Oracle, the statement below works:

mysql> insert into emp1 values(&empno,'&empname',&empsal,'&empcity');**

But this doesn't work in MySQL - why can't the values be prepended by &?

like image 863
Vinay Guru Avatar asked Jul 04 '15 06:07

Vinay Guru


2 Answers

Am assuming the ampersands are for SQL*Plus substitution variables.

These are supported by Oracle but not by MySQL.

like image 79
Steve Chambers Avatar answered Sep 19 '22 12:09

Steve Chambers


Similar code for MySQL is like this:

SET @empno = 100, @empname = 'vinay', @empsal = 10000, @empcity = 'USA'; 
insert into emp1 values(@empno,@empname,@empsal,@empcity);

Note the @, no ' in the INSERT values, etc.

If you are translating between different DBMS systems, you should plan on significant rewriting. This is just one of hundreds of differences between Oracle and MySQL.

like image 38
Rick James Avatar answered Sep 22 '22 12:09

Rick James