Jeff Crosby wrote:
My question is, is there a way to not hardcode the file name SLSALL? It
doesn't accept a host variable there, like :FileName. I tried setting
it up
with dynamic SQL, parameter markers, and PREPARE, like this:
ActSQL = 'Select Coalesce(Min(INVDT),' + @Q + '0001-01-01' + @Q + ')' +
', Coalesce(Max(INVDT),' + @Q + '0001-01-01' + @@ + ')' +
', Coalesce(Count(*),0) ' +
'Into ?, ? , ? From ?';
Exec SQL Prepare Stmt1 from :ActSQL;
but then couldn't figure out how to execute it. The EXECUTE IMMEDIATE
doesn't like USING. All the examples I found in this regard use a
cursor.
Paul Nelson wrote on 14/09/2007 09:53:51:
Not to belabor a point, but you can do this with SEQUEL's run time
variables:
SELECT *
FROM &library/&filename
And so on.
I like SEQUEL too, but it's worth noting that this functionality doesn't
trump embedded SQL as you imply. What you suggest is no different than
Jeff using
ActSQL = 'Select Coalesce(Min(INVDT),' + @Q + '0001-01-01' + @Q + ')' +
', Coalesce(Max(INVDT),' + @Q + '0001-01-01' + @@ + ')' +
', Coalesce(Count(*),0) ' +
'Into ?, ? , ? From ' + qualifiedName;
to build his SQL statement, then doing a PREPARE each time he needs to run
it, as others have suggested.
Attention:
The information contained in this message and or attachments is
intended only for the person or entity to which it is addressed and may contain
confidential and/or privileged material. Any review, retransmission,
dissemination or other use of, or taking of any action in reliance upon, this
information by persons or entities other than the intended recipient is
prohibited. If you received this message in error, please contact the sender and
delete the material from any system and destroy any copies. Thank you for your
time and consideration.
Attention:
Le contenu de ce message et(ou) les fichiers ci-joints s?adressent
exclusivement à la personne ou -entité à laquelle ils sont destinés. Ils peuvent
contenir de l?information confidentielle, protégée et(ou) classifiée. Il est
strictement interdit à toute personne ou entité autre que le(la) destinataire
prévu(e) de ce message d?examiner, de réviser, de retransmettre ou de diffuser
cette information, de prendre une quelconque action en fonction ou sur la base
de celle-ci, ou d?en faire tout autre usage. Si vous avez reçu ce message par
erreur, veuillez communiquer avec l?expéditeur(trice), supprimer ce message et
les fichiers ci-inclus de tout système, et en détruire toutes copies, qu?elles
soient électroniques ou imprimées. Nous vous remercions de votre entière
collaboration.
As an Amazon Associate we earn from qualifying purchases.