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 - 4104 days ago
Last viewed on: 17 Apr 2024 (4366 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.

Thanks!

 

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

COMMENTS

(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 4 months 6 days 14 hours 48 minutes ago

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

 

execsql valuesnextvalfor batch_seq into :batchno;

Thanks!