|
As much fun as this is, I am running out of time. You can either pursue my example below or try the following: stmt='UPDATE FELKER SET SAL' + AlphaMonth + ' = ?'; /exec sql prepare mystmt using :stmt /end-exec /exec sql execute mystmt using :myvar /end-exec Rob Berendt -- Group Dekko Services, LLC Dept 01.073 PO Box 2000 Dock 108 6928N 400E Kendallville, IN 46755 http://www.dekko.com THarteau@xxxxxxxxxxxxxxxxxx Sent by: rpg400-l-bounces@xxxxxxxxxxxx 03/04/2004 01:55 PM Please respond to RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx> To RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx> cc Subject Re: SQL Update using Variable Field Hi, UPDATE ROB/FELKER SET (case when current month= 1 then SAL01 = :MYVAR when current month= 2 then SAL02 = :MYVAR when current month= 3 then SAL03 = :MYVAR END) That would work, I would only need one SQL statement. But I was thinking more along the lines of: I know what the month number is Use an If to put the field name in :MONTH Then SET :MONTH = 0 Typing this in, I realize I still need an IF or SELECT to get the field name. Your way might be clearer. <===================================================> Terri Harteau Felker Brothers Corporation **************** "There's no point in being grown up if you can't be childish sometimes." - Dr. Who **************** rob@xxxxxxxxx Sent by: To: RPG programming on the AS400 / iSeries rpg400-l-bounces@m <rpg400-l@xxxxxxxxxxxx> idrange.com cc: Subject: Re: SQL Update using Variable Field 03/04/2004 12:32 PM Please respond to RPG programming on the AS400 / iSeries I don't have this worked out yet, but is this kind of what you are thinking: UPDATE ROB/FELKER SET (case when current month= 1 then SAL01 = :MYVAR when current month= 2 then SAL02 = :MYVAR when current month= 3 then SAL03 = :MYVAR END) Rob Berendt -- Group Dekko Services, LLC Dept 01.073 PO Box 2000 Dock 108 6928N 400E Kendallville, IN 46755 http://www.dekko.com THarteau@xxxxxxxxxxxxxxxxxx Sent by: rpg400-l-bounces@xxxxxxxxxxxx 03/04/2004 12:52 PM Please respond to RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx> To RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx> cc Subject SQL Update using Variable Field Hi, I can't find anywhere where it says I can't do this, but I'm not sure how to achieve it. I have a file with a sales amount for each month (SAL01,SAL02...SAL12). I want to use an SQL statement to zero the month in all records before updating it. So, instead of UPDATE SALES SET SAL01 = 0, I can replace SAL01 with the field for the appropriate month. Is this kind of thing possible? I found where you can use variables for the order by clause, but nothing like this. <===================================================> Terri Harteau Felker Brothers Corporation **************** "There's no point in being grown up if you can't be childish sometimes." - Dr. Who **************** _______________________________________________ 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. _______________________________________________ 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. _______________________________________________ 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.