|
DonnaIs it necessary to use SQL? You might consider the edit code APIs - you generate an edit mask that gets applied to a number - this gives you the ability to create variable edit words in the same program. I says this, as it appears you are leaving space for the currency something or other. Building the edit word template for creating the edit mask could involve substringing in the same way as i will suggest below.
But if you must use SQL, here goes. I'd go with something with a SUBSTRING function. I'd maybe use a table expression to get number, then use the result of that in a SUBSTRING function to get the number of spaces from a long string of spaces.
with myspc as (SELECT NUMBER FROM DLESTER/RSFILE WHERE CURRENCYISOCD = 'USD')select char(X_AUTHAXY) concat substring(' ', 1, number) concat '-' from yourfile join myspc
Something like this. I have not run it, so cannot guarantee anything.But the same substring technique can build you an edit mask without using SQL - less complex in my view. The APIs are Convert Edit Word (QECCVTEW) API and Edit (QECEDT) API - Scott Klement might have handled these in his
newsletter, otherwise, it is not too hard to work out how to call them - simple calls in this case.
HTH Vern At 06:58 PM 11/21/2006, you wrote:
Hi, here is my select statement: SELECT NUMBER FROM DLESTER/RSFILE WHERE CURRENCYISOCD = 'USD' I get Number = 2 when I execute this SQL statement. ---------- So I have to insert 2 spaces after period (0.) in the eval statement.... My eval statement is as below: eval M_MSGDATA = %trim(%editw(+ X_AUTHAXY:' , , , , , 0 . -')) To make it more clear eval M_MSGDATA = %trim(%editw(+ X_AUTHAXY:' , , , , , 0 .(onespace)(onespace)-')) It is hard coded in my program with 2 spaces after period.Depending on the NUMBER value after executing SQL statement it should give that many spaces after the period.Eg:If the NUMBER value after executing SQL statement is 1 then I should insert 1 space after the period. If the NUMBER value after executing SQL statement is 3 then I should insert 3 spaces after the period. With 3 spaces it look like below:eval M_MSGDATA = %trim(%editw(+ X_AUTHAXY:' , , , , , 0 .(onespace)(onespace)(onespace)-')) Please help me get logic to make it work by imbedding SQL in my RPGLE. Thanks Donna. --------------------------------- Sponsored Link Degrees for employed people - in as fast as 1 year. A.S. / Bachelors / Masters -- 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.