Set Schema programmatically?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jeffb
    New Member
    • Feb 2007
    • 4

    Set Schema programmatically?

    Is there any way to set the "current schema" programmaticall y (C++, if it matters)? I've tried both "SQL_ATTR_CLISC HEMA" and "SQL_ATTR_CURRE NT_SCHEMA" via "SQLSetConnectA ttr()" to no avail (I've verified that the chosen schema was properly set via "SQLGetConnectA ttr"() as well). The schema would "set", but it never seemed to affect any queies (I set it to something invalid, but could still query the tables as if the schema was correct).

    I could prepend the schema name to every table reference in every SQL statement in our application, but obviously, I'd prefer to avoid that.

    It seems that the schema name is the same as the user name, and I'd like to be able to change that within the application, but nothing seems to affect it.

    Just to be clear, I'm looking for a way to perform "set schema XXX" from within our application.

    Thanks very much for your time and any info...
  • skchonghk
    New Member
    • Jan 2007
    • 6

    #2
    Your guess is right. Execute this SQL statement before any others:

    set schema XXXXXX, where XXXXX is the schema name.

    However, if the new schema and the old schema have objects of the same name, it will take the original schema as default. So prefixing the object name in SQL statement should be a better approach actually.

    Adrian

    Comment

    • jeffb
      New Member
      • Feb 2007
      • 4

      #3
      Thanks for the reply, but I can't find the equivalent function call for "set schema XXX". The "set schema" command is a command-line way of doing it - I need a way of doing it from within our application (I think DB2 calls it a CLI (Call level interface)). I.E.: Something along the lines of SQLSetConnectAt tr(), but which affects the current schema.

      Thanks....

      Comment

      • jeffb
        New Member
        • Feb 2007
        • 4

        #4
        bump. Any ideas, anyone?

        TIA.

        Comment

        Working...