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

Getting -303 sqlcode in MAX FUNIC


IBM Mainframe Forums -> HomeWorks & Requests
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vijayalakshmidv

New User


Joined: 19 Jul 2007
Posts: 2
Location: bangalore

PostPosted: Mon Sep 10, 2007 2:46 pm
Reply with quote

Hi,
I am having a x(5) field in db2 table but that field(empno) contains numeric data.
I would like to find the maximum employee number in that field and during new employee insert I need to add 1 to maximum available empno.Please suggest me how to do.I am getting -303 sqlcode if I move use MAX FUNIC and later move to comp variable
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Sep 10, 2007 2:53 pm
Reply with quote

the explanation of the -303, if you bothered to look it up, would have suggested that your host variable is not the correct type.

why are you using a comp host variable for an x-type field? is that COMP-3 or what. Binary or PACK-DECIMAL.

use an x-type host variable, which is redefined as numeric if you just have to move it to a comp field. sorta silly since you are only saving two bytes by not using the x-type definition and are incurring more processing costs by either converting the numeric to binary or doing a PACK.
Back to top
View user's profile Send private message
vijayalakshmidv

New User


Joined: 19 Jul 2007
Posts: 2
Location: bangalore

PostPosted: Mon Sep 10, 2007 7:28 pm
Reply with quote

Ya but my question is if i want to retrieve a maximum empno from table
and the empno field is x(5).Is it possible to retrieve maximum empno number
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Sep 10, 2007 7:39 pm
Reply with quote

have you looked at the explanation of the max column function?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Mon Sep 10, 2007 7:40 pm
Reply with quote

Hello,

Well, yes. . . It is possible.

However, if you retrieve the "max" in one transaction and some other process also retrieves the max before it is updated and they both "add 1", you will have problems. . .
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 -> HomeWorks & Requests

 


Similar Topics
Topic Forum Replies
No new posts SQLCODE=-311 in Cobol SP-DB2. COBOL Programming 2
No new posts SQLCODE = -122 while using the scalar... DB2 4
No new posts SQLCODE = -16002 when using XMLEXISTS DB2 1
No new posts Is SQLCODE -811 possible while fetchi... DB2 1
No new posts SQLCODE=-204 SQLSTATE=42704 DB2 4
Search our Forums:

Back to Top