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.