Seeking Help with SQL SUBSTR Function using Host Variables in COBOL

200 pts.
Tags:
AS/400
COBOL
SQL
SUBSTR
V5R2
Hello All I am currently on version V5R2 and I am trying to make a COBOL program produce some parsed fields from one large field. I have trying to use host variables for al three arguments in the SUBSTR function. The SQL compiler will take a host variable as argument number one but not for argument numbers two and three. I have defined the variables several different ways but it does not make any sort of differrence. Currently I have reverted back to having the variables defined with in a SQL Declaration. I also am having similar trouble with the LOCATE and POSSTR functions. If anyone knows the trick to making the host variables work or better yet has a code snippet, I would be most grateful.
ASKED: June 17, 2008  8:52 PM
UPDATED: April 28, 2010  6:12 AM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Could you post the error message you a getting from the precompiler? I’ve tried it out today (but my environment was zOS) and it works fine.
My variables were defined as
<pre>
01 …
05 WS-BEGIN PIC S9(9) COMP.
05 WS-END PIC S9(9) COMP.
05 WS-TEXT PIC X(50).
</pre>
If your precompiler doesn’t allow it (I’m not fit in DB2 for AS/400) you could define a UDF that gets the three parms (text, begin, end) and sends the substring back.

========================================================

The declarations could be exactly that way in i5/OS COBOL. But without seeing the code that causes trouble, there is no way to know what is wrong. It could be the variables themselves or it could be an improper program structure for V5R2 (which was getting old at the time of the question.)

Tom

Discuss This Question:  

 
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 members answer or reply to this question.

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:

To follow this tag...

There was an error processing your information. Please try again later.

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

Thanks! We'll email you when relevant content is added and updated.

Following