View previous topic :: View next topic
|
Author |
Message |
vijayalakshmidv
New User
Joined: 19 Jul 2007 Posts: 2 Location: bangalore
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
vijayalakshmidv
New User
Joined: 19 Jul 2007 Posts: 2 Location: bangalore
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
have you looked at the explanation of the max column function? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|