Discussions

Expand all | Collapse all

How to use Bind Variable in SQL Query

  • 1.  How to use Bind Variable in SQL Query

    Posted 16 days ago
    How to use BIND Variable in OMNISQL

    EX.
    SELECT NAME FROM USER_MAST WHERE EMP_ID=&D;
    #General


  • 2.  RE: How to use Bind Variable in SQL Query

    Posted 16 days ago
    Hi @Sumit Srivastava,

    If you are asking something similar to variable in Oracle's sql*plus, where when you run a script the tool will ask for the content of variables , there isn't.

    If you want  to run a script substituting something similar to variables​ you can with a bash script like that

    echo "select count() from flights where dest_state='###state###';" | sed "s/###state###/CA/g" | omnisql -t -p HyperInteractive
    User admin connected to database omnisci
    EXPR$0
    72088465
    1 rows returned.
    Execution time: 24 ms, Total time: 24 ms

    Don't worry about performance, the omnisci optimizer is able to identify what is a bind varable and reuse the plan.

    Of course you can do the same also with a more complex sql script.