Does DB2 CLI support parameters markers in SQL that needs to be executed from a bash script [AIX] -
does db2 -x
or db2 -f filename.sql
options support use of parameter markers? calling sql statement bash script. cannot find optios far , think have use string concatenation in bash , pass sql db2 -x
not neat.
the db2 clp not support using parameter markers.
however, when running db2 non-interactively (i.e., shell), can substitute shell variables:
$ v=4 $ db2 "select count(*) syscat.tables card = ${v}"
because using shell substitution you'll need handle adding single quotes around strings (... tabschema = '${tabschema}' ...
), , if strings have single quotes becomes more complicated.
you can use method in shell scripts in loops:
#!/bin/ksh db2 connect sample v in 1 2 3 4 5 ; db2 "insert t1 (c1) values (${v})" done db2 terminate
this not if you're trying use parameter markers avoid recompiling sql statement every time it's executed, if you're looking want think using perl dbi, ruby/ibm_db, etc.
Comments
Post a Comment