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
Solved

Increment & return current generator value

Posted on 2002-06-24
3
529 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
  • 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 Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

856 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