passing variables command line - from Windows VSQL client

my runnQuery.bat file contents
vsql -U user -w pwd -h host-p 5433  -v numvar=3 -f runSQL.sql

runSQL.sql contents
\o sqlOutput
select * from table where a=:numVar;

vsql:runSQL.sql:3: ERROR 4856:  Syntax error at or near ":" at character 48
vsql:runSQL.sql:3: LINE 1: select * from omniture_new.dynamic_sql where a=:numVar;
vsql:runSQL.sql:3:                                                        ^

This works well in UNIX but i am not able to get this working in Windows. Can someone please suggest any ideas? 

Also, how do i pass in multiple variables to the same SQL file?


  • Options

    Hello Srivatsan,

    What is the content of your "runnQuerypassArgs.bat?"

    I tested a batch file that is very similar to yours, and it worked fine.

    Here is my .bat file:

    "C:\Program Files\Vertica Systems\bin\vsql" -U dbadmin -w password -h xx.xx.xx.xx -d gr_test2 -v var1=5 -f c:\data\bat\test.sql

    and here is my test.sql file:

    select * from public.n where i = :var1;

    I also tried to pass 'var1' as an argument like this:

    "C:\Program Files\Vertica Systems\bin\vsql" -U dbadmin -w password -h -d gr_test2 -v var1=%1 -f c:\data\bat\test.sql

    then call the batch file from command prompt:

    myvsql 5

    and it worked fine too.

    Since the .sql file doesn't take any parameter, I haven't found a way to pass multiple argument to it.


Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file