[Pdx-pm] (OT) SQL style question

Austin Schutz tex at off.org
Thu Jan 13 15:33:10 PST 2005

On Thu, Jan 13, 2005 at 03:19:53PM -0800, Randall Lucas wrote:
> > Quoting column names and using periods as separators:
> I recommend against this, even if all your target database platforms 
> support escaped identifier names with periods in them.  For one thing, 
> Class::DBI (and/or at least some of its related modules) doesn't play 
> nice with quoted names.  I got a good ways into an implementation that 
> worked with all of my own software, using odd but escaped names on 
> Postgres, but found myself in a world of hurt when trying to use a 
> number of automation tools for SQL.
> If you have the luxury, ban leading, trailing, and double underscores in 
> all db identifiers except for the prefixed names.  That should preserve 
> uniqueness of __ so that you can do a s/__/\./g to change names back.

	This is pretty unrelated, but it reminded me of something truly
obvious I "discovered" recently.
	Perl let's you use qq{}; as a double quoting mechanism. That's
really handy for code like:

  $statement = qq{
    SELECT $table."bar.baz" FROM $table where "bar.baz" LIKE 'STUFF%'

	where you have both single and double quotes in the mix. Also
makes it easy to maintain indentation without too much ugliness, as opposed
to constructs like

  $statement = <<'  EOF'
    SELECT ...

	One of those features in perl that I always knew about but never
considered using until fairly recently. Well, I did say it was obvious. :-)


More information about the Pdx-pm-list mailing list