Getting Variable from sqlplus
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I am trying to get a value from sqlplus like below. However, it does not echo what I want. Here is my script:
#!/bin/ksh
OLDEST_PARTITION='sqlplus / as sysdba << EOF
select PARTITION_NAME
from dba_tab_partitions
where table_name='AUD$' and PARTITION_NAME not like '%FIRST%' and rownum<2
order by PARTITION_NAME asc;
EOF'
echo $OLDEST_PARTITION
And the result is this:
sqlplus / as sysdba << EOF select PARTITION_NAME from dba_tab_partitions where table_name=AUD and PARTITION_NAME not like %FIRST% and rownum<2 order by PARTITION_NAME asc; EOF
shell-script scripting
add a comment |Â
up vote
0
down vote
favorite
I am trying to get a value from sqlplus like below. However, it does not echo what I want. Here is my script:
#!/bin/ksh
OLDEST_PARTITION='sqlplus / as sysdba << EOF
select PARTITION_NAME
from dba_tab_partitions
where table_name='AUD$' and PARTITION_NAME not like '%FIRST%' and rownum<2
order by PARTITION_NAME asc;
EOF'
echo $OLDEST_PARTITION
And the result is this:
sqlplus / as sysdba << EOF select PARTITION_NAME from dba_tab_partitions where table_name=AUD and PARTITION_NAME not like %FIRST% and rownum<2 order by PARTITION_NAME asc; EOF
shell-script scripting
1
The first and last single-quote should be a backquote`
â meuh
Aug 1 '16 at 12:06
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to get a value from sqlplus like below. However, it does not echo what I want. Here is my script:
#!/bin/ksh
OLDEST_PARTITION='sqlplus / as sysdba << EOF
select PARTITION_NAME
from dba_tab_partitions
where table_name='AUD$' and PARTITION_NAME not like '%FIRST%' and rownum<2
order by PARTITION_NAME asc;
EOF'
echo $OLDEST_PARTITION
And the result is this:
sqlplus / as sysdba << EOF select PARTITION_NAME from dba_tab_partitions where table_name=AUD and PARTITION_NAME not like %FIRST% and rownum<2 order by PARTITION_NAME asc; EOF
shell-script scripting
I am trying to get a value from sqlplus like below. However, it does not echo what I want. Here is my script:
#!/bin/ksh
OLDEST_PARTITION='sqlplus / as sysdba << EOF
select PARTITION_NAME
from dba_tab_partitions
where table_name='AUD$' and PARTITION_NAME not like '%FIRST%' and rownum<2
order by PARTITION_NAME asc;
EOF'
echo $OLDEST_PARTITION
And the result is this:
sqlplus / as sysdba << EOF select PARTITION_NAME from dba_tab_partitions where table_name=AUD and PARTITION_NAME not like %FIRST% and rownum<2 order by PARTITION_NAME asc; EOF
shell-script scripting
shell-script scripting
edited Aug 2 '16 at 3:50
Jeff Schaller
33.1k849111
33.1k849111
asked Aug 1 '16 at 7:57
john true
1083
1083
1
The first and last single-quote should be a backquote`
â meuh
Aug 1 '16 at 12:06
add a comment |Â
1
The first and last single-quote should be a backquote`
â meuh
Aug 1 '16 at 12:06
1
1
The first and last single-quote should be a backquote
`
â meuh
Aug 1 '16 at 12:06
The first and last single-quote should be a backquote
`
â meuh
Aug 1 '16 at 12:06
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
As meuh pointed out, unless you copy/pasted the script incorrectly, you have single-quote marks where you need to have backticks. Changing them makes the script into:
#!/bin/ksh
OLDEST_PARTITION=`sqlplus / as sysdba << EOF
select PARTITION_NAME
from dba_tab_partitions
where table_name='AUD$' and PARTITION_NAME not like '%FIRST%' and rownum<2
order by PARTITION_NAME asc;
EOF
`
echo "$OLDEST_PARTITION"
I took care to keep the EOF
on its own line, and also quote the OLDEST_PARTITION variable.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
As meuh pointed out, unless you copy/pasted the script incorrectly, you have single-quote marks where you need to have backticks. Changing them makes the script into:
#!/bin/ksh
OLDEST_PARTITION=`sqlplus / as sysdba << EOF
select PARTITION_NAME
from dba_tab_partitions
where table_name='AUD$' and PARTITION_NAME not like '%FIRST%' and rownum<2
order by PARTITION_NAME asc;
EOF
`
echo "$OLDEST_PARTITION"
I took care to keep the EOF
on its own line, and also quote the OLDEST_PARTITION variable.
add a comment |Â
up vote
0
down vote
As meuh pointed out, unless you copy/pasted the script incorrectly, you have single-quote marks where you need to have backticks. Changing them makes the script into:
#!/bin/ksh
OLDEST_PARTITION=`sqlplus / as sysdba << EOF
select PARTITION_NAME
from dba_tab_partitions
where table_name='AUD$' and PARTITION_NAME not like '%FIRST%' and rownum<2
order by PARTITION_NAME asc;
EOF
`
echo "$OLDEST_PARTITION"
I took care to keep the EOF
on its own line, and also quote the OLDEST_PARTITION variable.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
As meuh pointed out, unless you copy/pasted the script incorrectly, you have single-quote marks where you need to have backticks. Changing them makes the script into:
#!/bin/ksh
OLDEST_PARTITION=`sqlplus / as sysdba << EOF
select PARTITION_NAME
from dba_tab_partitions
where table_name='AUD$' and PARTITION_NAME not like '%FIRST%' and rownum<2
order by PARTITION_NAME asc;
EOF
`
echo "$OLDEST_PARTITION"
I took care to keep the EOF
on its own line, and also quote the OLDEST_PARTITION variable.
As meuh pointed out, unless you copy/pasted the script incorrectly, you have single-quote marks where you need to have backticks. Changing them makes the script into:
#!/bin/ksh
OLDEST_PARTITION=`sqlplus / as sysdba << EOF
select PARTITION_NAME
from dba_tab_partitions
where table_name='AUD$' and PARTITION_NAME not like '%FIRST%' and rownum<2
order by PARTITION_NAME asc;
EOF
`
echo "$OLDEST_PARTITION"
I took care to keep the EOF
on its own line, and also quote the OLDEST_PARTITION variable.
edited Apr 13 '17 at 12:36
Communityâ¦
1
1
answered Aug 2 '16 at 3:52
Jeff Schaller
33.1k849111
33.1k849111
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f299545%2fgetting-variable-from-sqlplus%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
The first and last single-quote should be a backquote
`
â meuh
Aug 1 '16 at 12:06