View previous topic :: View next topic
|
Author |
Message |
ms0033436
New User
Joined: 20 Nov 2008 Posts: 15 Location: Pune
|
|
|
|
Hi
My requirement is :
There are 2 variables X and Y.
X - IMS segment variable - pic 9(4) comp value 0001
Y is DB2 variable (DCLGEN variable ). - pic s9(4) usage comp.
My program uses cobol-db2 where the below is happening:
move X to Y.
There is a select query (Dynamic cursor) which uses Y variable in the where clause.
After executing the program it abends with SQL CODE -104 as it is expecting in this form '+0001' in DB2 table
can anybody has idea how to move pic 9(4) comp to pic s9(4) usage comp? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
can anybody has idea how to move pic 9(4) comp to pic s9(4) usage comp? |
COBOL has a number of ways to do this: MOVE, COMPUTE, ADD, SUBTRACT, MULTIPLY, DIVIDE. If you need an IMS or DB2 solution, you need to specify this and you should not have posted in the COBOL forum. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Deleted by poster. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
ms0033436 wrote: |
Hi
My requirement is :
There are 2 variables X and Y.
X - IMS segment variable - pic 9(4) comp value 0001
Y is DB2 variable (DCLGEN variable ). - pic s9(4) usage comp.
My program uses cobol-db2 where the below is happening:
move X to Y.
There is a select query (Dynamic cursor) which uses Y variable in the where clause.
After executing the program it abends with SQL CODE -104 as it is expecting in this form '+0001' in DB2 table
can anybody has idea how to move pic 9(4) comp to pic s9(4) usage comp? |
Although it has been quite a few years since I last wrote COBOL, ISTR that it is:
Code: |
MOVE COMP-VAR TO SIGNED-COMP-var. |
Show us -- cut and paste using the code tags, not an attached screen shot -- the declarations of the variable, the query, the DDL for the table (or an equivalent section from SYSCOLUMNS), and the error message. Your story does not seem to be congruent with reality. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Compile the program using the LIST,NOOFFSET options (generate Assembler) and post the Assembler expansion of this move.
Bill |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
I suspect that the actual move is not the problem but rather the definitions of the data in the database versus the program are not acceptable to db2 as presented.
Methinks Akatsukami is on target. . .
And the requested info needs to be posted for us to better help. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Dick,
Remember the recent posting where the OP insisted that COMP was Packed-Decimal? The compiler should execute this COMP-to-COMP move in one MVC.
But, maybe Akatsukami is on to something?
Bill |
|
Back to top |
|
|
david jackson
New User
Joined: 24 Jan 2011 Posts: 22 Location: California
|
|
|
|
Quote: |
After executing the program it abends with SQL CODE -104 as it is expecting in this form '+0001' in DB2 table
|
S9(4) Comp is a half word binary field and would contain x'0001' if positive (or for example x'FFFF' if negative 1).
What exactly is the form that DB2 is expecting this in as you say it is expecting '+0001'? Can you clarify that point?
Quote: |
can anybody has idea how to move pic 9(4) comp to pic s9(4) usage comp? |
There is nothing wrong with that Move.
Have you looked further into SQL CODE -104?
publib.boulder.ibm.com/infocenter/dzichelp/v2r2/topic/com.ibm.db29.doc.codes/n104.htm |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hi Bill,
Yup, i do recall. . . Unfortunately, we have very many with a complete mis-understanding of how data is actually stored for the various data types. . .
And it is almost like pulling teeth to get the useful info posted . . .
Maybe it will follow soon
d |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
After further review, perhaps the compiler is loading the unsigned-halfword into a register and then issuing a "LOAD POSITIVE REGISTER"?
This would ensure any negative value becomes positive.
After the LPR of itself (or another register), it probably issues a STH (or maybe an STCM) to the signed-halfword and we're done?
Yeah, an MVC would not completely do the trick, because you're going from an unsigned-halfword to an signed-halfword and the receiving field needs to be a signed-value.
But, I agree, this MOVE should work as-is....
Bill |
|
Back to top |
|
|
david jackson
New User
Joined: 24 Jan 2011 Posts: 22 Location: California
|
|
|
|
Bill O'B,
In the direction of a move of an unsigned to a signed field, a straight MVC will be fine as the from field is by implication positive.
The opposite move however of a signed filed to an unsigned, will as you indicate result in a LH, followed by a LPR and a STH to ensure the result is positive.
None of this helps the OP however...! |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
ms0033436 wrote: |
After executing the program it abends with SQL CODE -104 as it is expecting in this form '+0001' in DB2 table
|
There is nothing wrong with the move statement. But OP need to post his SQL for the query, as SQLCODE -104 is a syntax error, so we need the SQL statements to be able to help. |
|
Back to top |
|
|
ms0033436
New User
Joined: 20 Nov 2008 Posts: 15 Location: Pune
|
|
|
|
[S9(4) Comp is a half word binary field and would contain x'0001' if positive (or for example x'FFFF' if negative 1).
What exactly is the form that DB2 is expecting this in as you say it is expecting '+0001'? Can you clarify that point?
]
David,
i am getting the below message UNEXPECTED SQLCODE OF -104 ENCOUNTERED IN program CAUSING U3920 ABEND.
SQLCODE = -104, ERROR: ILLEGAL SYMBOL " ". SOME SYMBOLS THAT MIGHT BE
LEGAL ARE: + .
SQLSTATE = 42601 SQLSTATE RETURN CODE
SQLERRP = DSNHPARS SQL PROCEDURE DETECTING ERROR
SQLERRD = 3 0 0 -1 250 502 SQL DIAGNOSTIC INFORMATION
SQLERRD = X'00000003' X'00000000' X'00000000' X'FFFFFFFF'
X'000000FA' X'000001F6' SQL DIAGNOSTIC INFORMATION
BAD SQLCODE ON PREPARE QUERY AGAINST DB2 TABLE PARA
PROGRAM ABNORMALLY TERMINATED
PTOM DUMP OUTPUT 383
Due to this i am thinking that + is need in that variable. but when i display all the values used in the select query are coming correctly
this value comes with out a sign - ie. 0001 |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
If a halfword contained X'0001' (H'1'), the high-order sign-bit is "Off" and therefore, the value is positive, so it could be defined to an unsigned or signed halfword picture clause and utilized as such.
As you've said, a negative halfword one is X'FFFF' (H'-1') and the high-order bit is "On".
There's something we're missing here, because your code (based upon what you've posted), should work as-is.
Have you posted all there is to this problem?
Just a WAG, but perhaps these halfwords need to be aligned (a/k/a COMP SYNC)?
Bill |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
The OP's problem is that his generated dynamic sql SUCKS
the error message ---ILLEGAL SYMBOL " "
says it all.
the OP's refuses to post the generated slop that he feeds DB2 and
only responds to posters (like David) that provide a potential excuse
not to be responsible for his code. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Dick,
Yes, absolutely, Kjeld's post said it all, but I missed it completely < sigh >
Bill |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
I think OP has confused the format of host variables that are populated by the query and host variables that introduces dynamic literals in the where statements, and thats why we need to see the SQL-code and host variable contents that causes the syntax error. |
|
Back to top |
|
|
|