Midrange News for the IBM i Community

Posted by: Chris Proctor
Programmer Analyst
Columbia Sports Company
Portland, OR
Accessing a sequence# created w/SQL in an RPG pgm?
has no ratings.
Published: 13 Dec 2012
Revised: 23 Jan 2013 - 4051 days ago
Last viewed on: 25 Feb 2024 (4305 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Accessing a sequence# created w/SQL in an RPG pgm? Published by: Chris Proctor on 13 Dec 2012 view comments(1)

I created a batch# field using the following command in SQL. Iím trying now to access it in my program. It looks like it was created as a data area, but itís defined at char(2000), even though the actual sequence number is dec(8,0). I tried putting it in my pgm as a data area with a size of dec(8,0) and when I ran it it said the field size is wrong.†Maybe I need to have an SQL statement retrieve the value and increment it? Not sureÖ. Any ideas? Just an FYI, I create the counter this way because it's also being used by other SQL stored procedures.


create sequence mm610dvl/batch_seq as decimal(8,0) start with 100†increment by 1 no order cycle no minvalue no maxvalue cache 20††††

Return to midrangenews.com home page.
Sort Ascend | Descend


(Sign in to Post a Comment)
Posted by: chrisp
Premium member *
Portland, OR
Comment on: Accessing a sequence# created w/SQL in an RPG pgm?
Posted: 11 years 2 months 14 days 15 hours 47 minutes ago

Figured it out. Just added the following to the pgm:

execsql valuesnextvalfor batch_seq into :batchno;