Hi Charles

I have to admit I was using a textbook rather than the manual which seemed
to suggest it would work. I'll have a look at the VALUES INTO and see what
that does.

Thanks

Jonathan


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Wilt, Charles
Sent: 21 May 2008 17:25
To: RPG programming on the AS400 / iSeries
Subject: RE: Reading a Sum(field) column in RPGSQLLE

RTFM, you can't use SELECT INTO in a prepared statement. Thus you can't use
parameter markers either.

Take a look at VALUES INTO.

HTH,

Charles Wilt
--
Software Engineer
CINTAS Corporation - IT 92B
513.701.1307

wiltc@xxxxxxxxxx


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Jonathan Mason
Sent: Wednesday, May 21, 2008 10:44 AM
To: rpg400-L@xxxxxxxxxxxx
Subject: Reading a Sum(field) column in RPGSQLLE

I am trying to total a an amount on a number of records in a file within
an RPG program using embedded SQL.

I am building up the SQL statement using:

C* Build the SQL Statement for the current line...
C Eval wSql = 'select sum(' + %Trim(CAENVN) +
C ') into ? from ' + %Trim(CAEMVN)

C* If selection criteria was passed and it isn't *NONE then add it to
C* the SQL statement...
C If CAAGNC <> *Blanks and CAAGNC <> '*NONE'
C Eval wSql = %Trim(wSql) + ' where ' + CAAGNC
C EndIf

And then preparing and running it using:

C* Now execute the SQL statement...
C/Exec SQL
C+ Prepare prpSQL from :wSQL
C/End-Exec

C/Exec SQL
C+ Execute prpSQL using :wTotal
C/End-Exec

However, I am getting an error in the joblog that says:

Token ? was not valid. Valid tokens: : <IDENTIFIER>.

Can anybody tell me what I'm doing wrong? I thought I had to use
parameter markers for the variable name.

Thanks

Jonathan




--
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 e-mail transmission contains information that is intended to be
confidential and privileged. If you receive this e-mail and you are not a
named addressee you are hereby notified that you are not authorized to read,
print, retain, copy or disseminate this communication without the consent of
the sender and that doing so is prohibited and may be unlawful. Please
reply to the message immediately by informing the sender that the message
was misdirected. After replying, please delete and otherwise erase it and
any attachments from your computer system. Your assistance in correcting
this error is appreciated.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.