The iSeries Blog

Sep 3 2008   3:37PM GMT

Coloring source code with SQL: Error encountered

Leah Rosin Leah Rosin Profile: Leah Rosin

We recently received a reader question in response to a reader-submitted tip on using SQL on System i to color source code and inline comments. On August 27, 2008, Don sent us this inquiry:

This is in response to a tip published 05/2008 concerning applying color coding using SQL to update SRCDTA in your program source files. I tried it and got the message (STRSQL): Argument *N of function CONCAT not valid. Any advice on this?

I passed it on to the tip author, Narendra Devireddy who responded with this information:

Although I cannot confirm with the details given, it might be because Don’s source file length may be less than 112 (i.e. SRCDTA less than 100 bytes), so when he tries to use SUBSTR for 100 bytes it might be giving this error.

Please let the user know that in the second query ” UPDATE QTEMP/ALIAS# SET SRCDTA = SUBSTR(SRCDTA,1,4)||X’22′||SUBSTR(SRCDTA,6,94) WHERE
SUBSTR(SRCDTA,7,1) = ‘*’”
the second parameter of highlighted SUBSTR should be  6 less than SRCDTA length(i.e src file length-18, as 12 bytes are reserved for SRCDAT & SRCSEQ), and try it out

Using Source files of length 112 is standard these days for RPGLE programs, and therefore I have built the query to fit that standard. Please do let me know the result after the change.

We passed this back to Don and he let us know that in fact, the problem was resolved but through slightly different means:

Thanks for the timely response, the problem was actually that the SQL session attributes was set to “SQL Rules” = *STD instead of *DB2, after the change it worked fine. Thanks for the help.

As always, if you find something in a tip that doesn’t work for you please let us know. Also, if you have general questions there are many helpful people on IT Knowledge Exchange ready to answer your AS/400 questions. Additionally, Narendra recently submitted a follow-up tip for creation of multicolored comment lines that may be of interest.

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: