Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2013
    Toronto, Canada

    Question Unanswered: how to pass in linux environment var in db2 query?

    how do we pass in $USER in a SELECt stmt:

    ie. SELECT "col1" from "$USER"."TABLE1" ?

    I've to take already generated queries from a different id and rerun it in other ids ...I'd rather not change the schema each time since the schema is bascially the userid in linux..
    thank you

    I'm on db2_v105fp4 ..

  2. #2
    Join Date
    Apr 2012
    Provided Answers: 27
    Depends on the context (i.e. the toolset you are using).
    For plain SQL, many situations let you omit the schema qualifier immediately (and just use implicit schema name for the db connection, or use SET SCHEMA xxx before running the SQL).
    For scripted SQL (for example in shell scripting, or for databases that have many schema qualifiers for use in a single query) use shell features to expand $USER according to your requirements - this is the shell doing the work (not anything in DB2).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts