|
Brian, You're doing a INSERT, not a SELECT. You don't need the DECLARE C2 CURSOR, OPEN C2, or CLOSE C2 since you're not using a cursor. Cursors are for reading and optionally updating the row you just fetched. You need an EXECUTE SQL2 in place of the crap above. I can't believe that this even compiled let alone ran without error messages. HTH, Charles Wilt -- iSeries Systems Administrator / Developer Mitsubishi Electric Automotive America ph: 513-573-4343 fax: 513-398-1121 > -----Original Message----- > From: rpg400-l-bounces@xxxxxxxxxxxx > [mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of Brian Piotrowski > Sent: Wednesday, June 29, 2005 1:07 PM > To: RPG programming on the AS400 / iSeries > Subject: Committing data without assigning to a variable in SQL > > > Hi All, > > > > I have a two tables from which I read from one table and write the > results to another. I changed my code to use a PREPARE statement, but > the system doesn't appear to write anything to the target table. Do I > need to do a FETCH command into a variable in order to write to the > table? If so, how would I get it to write to the other table? > > > > Here's the snippet of code: > > > > /free > > SQLMlist = 'insert into sswdppp ('; > > SQLMlist = SQLMlist + 'select pskdl1, pskdl2, pskdl3, > psyear, psmdl,'; > > SQLMlist = SQLMlist + ' pstyp, psexcl,psinbt, psuqty'; > > SQLMlist = SQLMlist + ' from sst25 where concat(PSKDL2, PSKDL3) '; > > SQLMlist = SQLMlist + ' between ' + apos + shortyy + cmm + apos; > > SQLMlist = SQLMlist + ' AND '+ apos + nextsyy + nmm + apos + ')'; > > /end-free > > > > C/Exec SQL > > C+ PREPARE SQL2 FROM :SQLMlist > > C/End-exec > > C* > > C/Exec SQL > > C+ DECLARE C2 CURSOR for SQL2 > > C/End-exec > > C* > > C/Exec SQL > > C+ OPEN C2 > > C/End-exec > > C* > > C* Do I need to add another /EXEC SQL here??? > > C* > > C/Exec SQL > > C+ Close C2 > > C/End-exec > > C* > > C/Exec SQL > > C+ commit > > C/End-exec > > > > Another question I have is if I can compress the /Exec SQL lines down, > or must they remain on separate lines? > > > > Thank you! > > > > Brian. > > > > -=-=-=-=-=-=-=-=-=-=-=-=-=- > > Brian Piotrowski > > Specialist - I.T. > > Simcoe Parts Service, Inc. > > Ph: 705-435-7814 x343 > > Fx: 705-435-6746 > > bpiotrowski@xxxxxxxxxxxxxxx > > -=-=-=-=-=-=-=-=-=-=-=-=-=- > > > > -- > This is the RPG programming on the AS400 / iSeries (RPG400-L) > mailing list > To post a message email: RPG400-L@xxxxxxxxxxxx > To subscribe, unsubscribe, or change list options, > visit: http://lists.midrange.com/mailman/listinfo/rpg400-l > or email: RPG400-L-request@xxxxxxxxxxxx > Before posting, please take a moment to review the archives > at http://archive.midrange.com/rpg400-l. > >
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.