Specifying a schema with a placeholder is kind of like specifying a table with a placeholder. It'll throw all the DB's precise access planning out the window if it changes. As long as the prepare is being re-done anyway, it may as well have you do it.

In other words, the schema really is part of the table name. So treat it as such. Just think of it that there is no schema, but every table name must have a dot in it. There is a default prefix available, but it's still there, even if you don't say it.

So, one solution is:

my $tbl_foo = 'FOO'; # rely on current schema, or my $tbl_foo = 'BAZ.FOO'; # explicit, or my $sch = 'BAZ'; my $tbl_foo = "$sch.FOO"; # make it easier to change +a bunch of schemas at the same time
This latter solution is analogous to what I do with DB2::db where I have a base class that returns its schema, and the table classes simply derive off the appropriate base class, making it pretty easy to both change the name of a schema and to change which schema a particular table is in. Not that I need it very often.


In reply to Re: DB2 / Multiple schemas in a query or command by Tanktalus
in thread DB2 / Multiple schemas in a query or command by talexb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.