?
Solved

Stored Procedure in IBM DB2 for MAX ID

Posted on 2007-08-01
7
Medium Priority
?
393 Views
Last Modified: 2008-01-09
Hi,

I like to ask what is the equivalent of a stored procedure in IBM DB2 of the below

SELECT MAX(ID) FROM USERS with ur;

As I'm unsure the format of it there.
to return an ID in decimal
0
Comment
Question by:jedistar
6 Comments
 
LVL 37

Expert Comment

by:momi_sabag
ID: 19607246
it exactly what you wrote
SELECT MAX(ID) FROM USERS with ur;

you want to put that in a stored procedure ?
0
 
LVL 15

Expert Comment

by:deepaknet
ID: 19607260
SELECT MAX is also available in DB2 also right? Can you please elaborate your query a bit?
0
 
LVL 37

Expert Comment

by:momi_sabag
ID: 19607464
the query will return the highset value for column id in the table
the with ur clause indicates that the query should use isolation uncommited read which means it does not acquire any row / page share locks
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:jedistar
ID: 19615118
yes whats the format of the stored proc in db2
0
 
LVL 37

Accepted Solution

by:
momi_sabag earned 2000 total points
ID: 19615421
oh
you can find it here
http://publib.boulder.ibm.com/infocenter/db2luw/v8/topic/com.ibm.db2.udb.doc/admin/r0008329.htm
for example

CREATE PROCEDURE getMaxId (OUT maxId INT)
LANGUAGE SQL
BEGIN
     SELECT MAX(id)
     INTO :maxId
     FROM USERS
     WITH UR;
END @
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20475796
Forced accept.

Computer101
EE Admin
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Integration Management Part 2
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question