Take a look at the CLOSQLCSR PARM of the CRTSQLRPGI compile command. The
default is to close cursors when the activation group ends. You may want to
change this to close them when the job ends, etc.
JJ
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [
mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of AGlauser@xxxxxxxxxxxx
Sent: Monday, April 09, 2007 11:23 AM
To: RPG programming on the AS400 / iSeries
Subject: Embedded SQL in an RPG *SRVPGM, file stays open
Hi all,
I hope this is the right place to ask this question. I've looked at the
Embedded SQL Redbook a bit, as well as archive.midrange.com, but I haven't
found anything. I'm sort of making baby steps with embedded SQL at this
point, so it's quite possible I'm not looking in the right places.
My problem is that the PF stays open after my SQL statement is run, even
if I add a CLOSE. I understand from the Redbook that the SQL preprocessor
creates it own F-spec for each file it uses, so I can see why the close
isn't working the way I'd hoped. Is there some way to force the file to
close after the SQL statement?
My code looks like this:
P DSRMUNITS_getUnitByAssocUnit...
P B EXPORT
D DSRMUNITS_getUnitByAssocUnit...
D PI LIKE(vuUnit)
D assocUnit LIKE(vuUnit)
D CONST
D errorInfo LIKEDS(UTTERRDS_errorDS)
D* Local fields
D retField S LIKE(vuUnit)
D MORE_THAN_ONE_RECORD...
D C '21000'
C/EXEC SQL
C+ SELECT vuUnit INTO :retField
C+ FROM dsp070
C+ WHERE vuAss = (SELECT vuVMU#
C+ FROM dsp070
C+ WHERE vuUnit = :assocUnit AND
C+ vuStat IN ('OTR','AVL')
C+ )
C/END-EXEC
/FREE
errorInfo.errorCode = DSRMUNITS_NO_ERROR;
if (retField = *blanks);
errorInfo.errorCode = DSRMUNITS_UNIT_NOT_FOUND_ERROR;
elseif (SQLSTATE = MORE_THAN_ONE_RECORD);
errorInfo.errorCode =
DSRMUNITS_ASSOCIATED_TO_MULTIPLE_UNITS_ERROR;
endif;
close DSP070;
return retField;
/END-FREE
P DSRMUNITS_getUnitByAssocUnit...
P E
TIA,
Adam
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 sadressent
exclusivement ` la personne ou -entiti ` laquelle ils sont destinis. Ils
peuvent
contenir de linformation confidentielle, protigie et(ou) classifiie. Il est
strictement interdit ` toute personne ou entiti autre que le(la)
destinataire
privu(e) de ce message dexaminer, de riviser, de retransmettre ou de
diffuser
cette information, de prendre une quelconque action en fonction ou sur la
base
de celle-ci, ou den faire tout autre usage. Si vous avez regu ce message
par
erreur, veuillez communiquer avec lexpiditeur(trice), supprimer ce message
et
les fichiers ci-inclus de tout systhme, et en ditruire toutes copies,
quelles
soient ilectroniques ou imprimies. Nous vous remercions de votre entihre
collaboration.
As an Amazon Associate we earn from qualifying purchases.