IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

INSERTING IN DB2 TABLE GERTTING -310 error


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ravi.singh

New User


Joined: 05 Oct 2013
Posts: 18
Location: india

PostPosted: Thu Oct 17, 2013 11:33 pm
Reply with quote

hi ,
I had a table column whose DCL GEN IS defined as
AMOUNT PIC S9(7)V9(2)

Now requirement is I am getting an input feed in file as

WS-DOLLAR PIC9(4) value 356
WS-CENT PIC9(2) value 10
.
I need to concatenate the above two variables and insert into table , so that my table has data like 356.10 .

I am doing using a group variable to club the value and then passing to DCLGEN variable .At the time of imsertion its showing -310 error code .

I am using below logic

01 ws-net amt
05 ws-dollar pic 9(4)
05 ws-cent pic 9)2)

Before insertion , I am using this

Move ws-net-amt to AMOUNT(DCL GEN VARIABLR)

And using this value to insert , but its throwing -310 SQL ERROR , PLEASE GUIDE[/b]
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Thu Oct 17, 2013 11:51 pm
Reply with quote

That you're getting SQLCODE -310 suggests that you're not telling the whole truth, inadvertantly or otherwise. Read about SQLCODE -310 here. Re-read the "Programmer Response" as many times as necessary, until you understand what it means.
Back to top
View user's profile Send private message
ravi.singh

New User


Joined: 05 Oct 2013
Posts: 18
Location: india

PostPosted: Thu Oct 17, 2013 11:55 pm
Reply with quote

Hi Sir ,
I know , I am not passing the correct value , but I tried and unable to fix the things , thats why had given the exact column defination . Please guide me where I ma going wrong
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Fri Oct 18, 2013 12:41 am
Reply with quote

The description of SQLCODE -310:
Quote:
-310


DECIMAL HOST VARIABLE OR PARAMETER number CONTAINS NON-DECIMAL DATA

Explanation


DB2® received nondecimal data from either an application (in the form of a host variable), function or a stored procedure (in the form of a parameter that was passed to or from function or a stored procedure). number Identifies either the host variable number (if the message is issued as a result of a FETCH, INSERT, UPDATE, MERGE, DELETE, SELECT, VALUES INTO, or SET assignment statement), or the parameter number (if the message is issued as the result of the invocation of a function, or a CALL statement).
System action


The statement cannot be processed.

Programmer response


Correct the application program or stored procedure. Ensure that all decimal variables or parameters contain valid System/370 packed decimal numbers.

(Emphasis added.)

Now, how do you define a packed decimal variable in COBOL? By specifying USAGE of COMP-3. Do you tell us that AMOUNT is defined as COMP-3? No; therefore I say that you are not being entirely truthful.

Now, review the rules for group moves in COBOL. Do you think, even if AMOUNT were defined as COMP-3, that it would end up containing valid packed decimal data?
Back to top
View user's profile Send private message
ravi.singh

New User


Joined: 05 Oct 2013
Posts: 18
Location: india

PostPosted: Fri Oct 18, 2013 12:50 am
Reply with quote

Hi,
Sir thanks for your reply , I even tried giving
Amount as PicS9(5)v9(2) comp -3
but getting same error
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Fri Oct 18, 2013 1:04 am
Reply with quote

Quote:
Now, review the rules for group moves in COBOL. Do you think, even if AMOUNT were defined as COMP-3, that it would end up containing valid packed decimal data?

Those rules are
Quote:
A group move is any move in which an alphanumeric group item is a sending item or a receiving item, or both.

The group moves are:

•A move to an alphanumeric group item from one of the following items:
◦any elementary data item that is valid as a sending item in the MOVE statement
◦a national group item
◦a literal
◦a figurative constant
•A move from an alphanumeric group item to the following items:
◦any elementary data item that is valid as a receiving item in the MOVE statement
◦a national group item
◦an alphanumeric group item
A group move is treated as though it were an alphanumeric-to-alphanumeric elementary move, except that there is no conversion of data from one form of internal representation to another. In a group move, the receiving area is filled without consideration for the individual elementary items contained within either the sending area or the receiving area, except as noted in the OCCURS clause.

(Emphasis again added.)

Now WS-DOLLAR contains 356 and WS-CENT contains 10. So, what will WS-NET-AMT contain? X'F0F3F5F6F1F0', not so? When you move WS-NET-AMT, a group item, to WS-AMOUNT, the rules state that it will be as if WS-NET-AMT were defined as X(6), and WS-AMOUNT were defined PIC X(4), not so? So, WS-AMOUNT will contain X'F0F3F5F6'; is that a valid packed decimal number?

Define WS-CENT as PIC 99V99, and COMPUTE WS-AMOUNT = WS-DOLLAR + (WS-CENT / 100).
Back to top
View user's profile Send private message
ravi.singh

New User


Joined: 05 Oct 2013
Posts: 18
Location: india

PostPosted: Fri Oct 18, 2013 1:13 am
Reply with quote

HI SIR,
Thanks for such gr8 explanation.I realized my mistake
.Cant try this now ,as I am in home. Will try tomorrow and let you know

thanks and regsrds
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Oct 18, 2013 4:43 pm
Reply with quote

move ws-dollar to amount.
add ws-cent/100 to amount

or

compute amount = ws-dollar + ws-cent/100 end-compute

and you can preface the compute with an IF

IF ws-dollar numeric and ws-cent numeric
Then compute.
else
move zero (or all 9's as an error indicator) to amount
end-if
that way you don't have non-numerics in your host-variable
and don't blow up the compute.
Back to top
View user's profile Send private message
ravi.singh

New User


Joined: 05 Oct 2013
Posts: 18
Location: india

PostPosted: Fri Oct 18, 2013 10:38 pm
Reply with quote

thanks all, the solution worked and i realized my mistake
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Fri Oct 18, 2013 11:37 pm
Reply with quote

We're glad to hear that this worked for you.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Error when install DB2 DB2 2
No new posts Pulling a fixed number of records fro... DB2 2
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
Search our Forums:

Back to Top