Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2014-11-21 18:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (114 votes), past polls