Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

INSERTING IN DB2 TABLE GERTTING -310 error

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: INSERTING IN DB2 TABLE GERTTING -310 error
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: 1738
Location: Bloomington, IL

PostPosted: Thu Oct 17, 2013 11:51 pm    Post subject:
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    Post subject: INSERTING IN DB2 TABLE GERTTING -310 error
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: 1738
Location: Bloomington, IL

PostPosted: Fri Oct 18, 2013 12:41 am    Post subject:
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    Post subject: Reply to: INSERTING IN DB2 TABLE GERTTING -310 error
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: 1738
Location: Bloomington, IL

PostPosted: Fri Oct 18, 2013 1:04 am    Post subject:
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    Post subject: Reply to: INSERTING IN DB2 TABLE GERTTING -310 error
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    Post subject:
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    Post subject: Reply to: INSERTING IN DB2 TABLE GERTTING -310 error
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: 1738
Location: Bloomington, IL

PostPosted: Fri Oct 18, 2013 11:37 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts S922 Error yuvan ABENDS & Debugging 3 Fri Dec 02, 2016 6:58 pm
No new posts Invoke Webservice Fails with DFHPI100... divated CICS 2 Thu Nov 24, 2016 5:57 pm
No new posts Error during restore rename archanamuthukrishnan All Other Mainframe Topics 2 Fri Oct 14, 2016 3:30 pm
No new posts Error IEC161I 052(009,XXXRS00)-084 wh... amitc23 JCL & VSAM 10 Wed Oct 12, 2016 5:00 pm
No new posts Need Rexx Program to Load in to DB2 T... Hareesh Verma CLIST & REXX 22 Tue Sep 20, 2016 2:59 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us