Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^3: DBI - Table names & placeholders

by Anonymous Monk
on Dec 03, 2012 at 16:40 UTC ( #1006910=note: print w/ replies, xml ) Need Help??

in reply to Re^2: DBI - Table names & placeholders
in thread DBI - Table names & placeholders

I solved this problem when I had to deal a few dozen tables all with the same format and function each named by a client number determined from input data. The trick is to use a synonym. Write code for one table using a false table name. Then create a synonym named with your false name. Then alter the synonym to point to the table you need to use when you need to and reuse the bulk of your code. If the term 'synonym' is not familiar, consider it an alias or a symbolyc link with its own name that represents another object (table?) that may have another name. I don't know the performance impact of this method but I suspect altering a synonym is pretty cheap next to recompiling your insert statements. Hope this helps.

Comment on Re^3: DBI - Table names & placeholders
Re^4: DBI - Table names & placeholders
by erix (Vicar) on Dec 03, 2012 at 17:19 UTC

    Alas, neither MySQL nor PostgreSQL (the 2 systems the OP mentions) support CREATE SYNONYM.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1006910]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2014-08-23 00:32 GMT
Find Nodes?
    Voting Booth?

    The best computer themed movie is:

    Results (168 votes), past polls