DEFINE is just a replacement of Strings and VARIABLE actually crates a bind variable -
SQL>DEFINE X='DEFINE X HERE';
SQL> BEGIN :X:='SET X HERE'; END;
/
SQL> SELECT :X,'&X' FROM DUAL ;
old 1: SELECT :X,'&X' FROM DUAL
new 1: SELECT :X,'DEFINE THE X HERE' FROM DUAL
:X 'DEFINETHEXHERE'
----------- -----------------
SET X HERE DEFINE THE X HERE
&X simply replace the String, see below, we have omitted the single quotes around &X and it errors out, because it simply replaces &X with string which SQL cannot parse.
SQL> SELECT &X , :X FROM DUAL ;
old 1: SELECT &X , :X FROM DUAL
new 1: SELECT DEFINE THE X HERE , :X FROM DUAL
SELECT DEFINE THE X HERE , :X FROM DUAL
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected
SQL>DEFINE X='DEFINE X HERE';
SQL> BEGIN :X:='SET X HERE'; END;
/
SQL> SELECT :X,'&X' FROM DUAL ;
old 1: SELECT :X,'&X' FROM DUAL
new 1: SELECT :X,'DEFINE THE X HERE' FROM DUAL
:X 'DEFINETHEXHERE'
----------- -----------------
SET X HERE DEFINE THE X HERE
&X simply replace the String, see below, we have omitted the single quotes around &X and it errors out, because it simply replaces &X with string which SQL cannot parse.
SQL> SELECT &X , :X FROM DUAL ;
old 1: SELECT &X , :X FROM DUAL
new 1: SELECT DEFINE THE X HERE , :X FROM DUAL
SELECT DEFINE THE X HERE , :X FROM DUAL
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected
No comments:
Post a Comment