0

Why the following query have different behavior according with syntax

SYNTAX 1

sqlplus -silent $conn <<EOF
select 'aman' from dual;
EXIT;
EOF

SYNTAX 2

resultset2=`sqlplus -silent $conn <<EOF
select 'aman' from dual;
EXIT;
EOF 
`

SYNTAX 3

resultset2=$(sqlplus -silent  $conn<<EOF
select 'aman' from dual;
EXIT;
EOF
)

Syntax 1 and 2 are working fine but syntax 3 gives me error

ORA-00904: "aman": invalid identifier
AmanS
  • 1,490
  • 2
  • 13
  • 22
  • @RC. please explain why the syntax 3 gives me error? – AmanS May 20 '15 at 06:25
  • It doesn't, unless your particular shell is doing something very weird. You'd only see that error if you'd used double quotes instead of single quotes in the third example. Are these all exact cut-and-paste from your actual shell scripts, or have you retyped them, or edited them? – Alex Poole May 20 '15 at 07:41
  • @AlexPoole they are copy-and-pasted from script and there is one more point that when i enable shell log(set -x) then i see that my shell is converting 'aman' to "aman" – AmanS May 20 '15 at 08:04
  • OK, then which shell and version are you using? – Alex Poole May 20 '15 at 08:06
  • @AlexPoole Shell is Ksh and version sorry i don't know – AmanS May 20 '15 at 08:19
  • version mayb Ultrix 4.0, 4.5 – AmanS May 20 '15 at 08:26
  • 1
    Looks like a ksh88 issue then; you can verify with `ksh --version`. Two workarounds in the duplicate question; or use a different shell (or version); or use the syntax2 approach with backticks, of course. – Alex Poole May 20 '15 at 08:31

0 Answers0