2

Here is may problem : I have inline sqlplus call in my bash file and I would like to pass it a parameter

this code is what I'm trying

c_id=`sqlplus -S $login/$password  $id << EOF
    set pagesize 0
    set verify off
    set head off
    set feedback off
    SELECT id from bdd.table where ID not in (select id from bdd.TMP_table) and id > &1 and ROWNUM <= 1000 order by id;
    exit;
    EOF`

how can I use my $id parameter in my where statement (&1)?

1 Answer 1

8

Just change &1 to $id. For example:

id=101
c_id=`sqlplus -S $login/$password  << EOF
    set pagesize 0
    set verify off
    set head off
    set feedback off
    SELECT id from bdd.table where ID not in (select id from bdd.TMP_table) and id > $id and ROWNUM <= 1000 order by id;
    exit;
    EOF`

Bash will perform parameter substitution. $id will be substituted with the actual value of the parameter i.e. 101 in this case, before sqlplus runs.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you it was that ! I realised it's what I did at the beging but i had mistakes on my loop...
@Shellter : I would to do this but it requires 15 points of reputation to me to enable this action :s I will do this later so ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.