Solved

Increment & return current generator value

Posted on 2002-06-24
3
541 Views
Last Modified: 2013-12-09
How can I return the current generator id value using sql.  I want to be able to run a sql query in my code to increment and return the current value.

I would like something like to work, but of course it doesn't:

select GEN_ID (ORDER_ID_GEN, 1) AS ORDER_ID;

I don't want to increment the value based on an insert into a table.

Thanks in advance.
Chris
0
Comment
Question by:cjclayton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
IPCH earned 50 total points
ID: 7106666
Try this:

CREATE PROCEDURE ND (
  MYINC INTEGER
) RETURNS (
  AVALUE INTEGER
) AS  
begin
avalue = gen_id(NUM_DS,:MYINC);
SUSPEND;
end

and this:

SELECT * FROM ND(1)

Ivan
0
 

Author Comment

by:cjclayton
ID: 7109384
Thank you Ivan.  Here is my working version:

/* Procedure: "GET_ORDER_ID" */
/* Usage: SELECT * FROM GET_ORDER_ID(1) */

SET TERM !! ;
CREATE PROCEDURE GET_ORDER_ID ( MYINC INTEGER ) RETURNS ( ORDER_ID INTEGER )
AS
begin
  order_id = gen_id(ORDER_ID_GEN,:myinc);
  SUSPEND;
END !!
SET TERM ; !!
0
 
LVL 2

Expert Comment

by:IPCH
ID: 7109927
You are wellcome.

Ivan
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Read about achieving the basic levels of HRIS security in the workplace.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

729 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