Up Prev Next
From: rhall at CORPNY dot FBC dot COM (Roger Hall)
Subject: Re: Transactions
Date: Aug 27 1999 7:21PM
> So far, so good...
> > ($sql = <<"SQL") =~ s/^\s+@@@ ?//gm;
> > @@@ -- begin transaction
> > @@@ select * from master..syslogins
> > @@@ if \@\@error != 0
> > @@@ begin
> > @@@ raiserror 30000, 'OUCH'
> > @@@ end
> > @@@ -- commit
> MOTHER, MARY and JOSEPH. *w*h*a*a*a*a*a*a*t* is this, and why do you do
> it? W-OW.
> What is with the number of '@'s threatening to exceed the rest of the
> letters by a simple majority? ... I hope I don't seem too naive to bother
> with, but I'm mostly not sure of the difference between "@@@" and "@@@ --" .
Anything starting with @@@ is SQL. The white space and @@@ and single space
get stripped off so that 1) It runs as SQL and 2) it looks neat if it gets
printed out in an error message such as 'Failed to run:\n\n$sql\n\n'.
A lot of people will say why bother putting the stuff in, only to remove it
straight away. My reason is that the places I do this, the difference in
performance to the user will not be noticed, but the difference in readability
to anyone reading the code is noticed. I obviously would not suggest doing
this in a big loop.
If you want to know more about this, I would recommend the Perl Cookbook,
Section 1.11, Page 23. I would recommend the rest of the book as well ;-)
> Any help, clue, even criticism is welcomed in reply.
> Many happy returns of the day ...
> "Nothing succeeds like success."
> Brad Morrison, firstname.lastname@example.org
> "Press to test."
> "Release to detonate."