SQL does not have Arrays and Data structures like RPG.
IMHO you can only wrap the original procedure by with each element as
separate parameter. Within the procedure you fill the arrays with the passed
parameters and call the original procedure.
This new procedure can be registered as SQL Stored Procedure.
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
Modernization ? Education ? Consulting on IBM i
Database and Software Architect
IBM Champion since 2020
"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
"Train people well enough so they can leave, treat them well enough so they
don't want to. " (Richard Branson)
"Learning is experience ? everything else is only information!" (Albert
Einstein)
-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of K Crawford
Sent: Wednesday, 5 March 2025 22:11
To: rpg400-l@xxxxxxxxxxxxxxxxxx
Subject: Stored Procedure over RPGLE with arrays as parms issues
I have an RPGLE program set up this way.
dcl-pr CallTheProgram extpgm('HROLL') ;
p_Client char(2); // Input
p_employee zoned(7); // Input
p_planyear zoned(4); // Input
p_RoLLin zoned(7: 2) dim(8); // InputOutput
p_RoLLou zoned(7: 2) dim(8); // InputOutput
p_eavL zoned(7: 2) dim(8); // InputOutput
p_year1 zoned(4); // InputOutput
end-pr;
I am trying to write a Stored Procedure to consume it.
This was one attempt:
CREATE TYPE myLib.INTARRAY4 AS NUMERIC(4,0) ARRAY[8] ; CREATE TYPE
myLib.INTARRAY7 AS NUMERIC(7,2) ARRAY[8] ; CREATE OR REPLACE PROCEDURE
myLib.sp_HROLL2 (
IN Client CHAR(2)
,IN ENum numeric(7,0)
,IN PlanYr numeric(4,0)
,INOUT Category cafteria.intarray4
,INOUT ROLL_IN cafteria.intarray7
,INOUT ROLL_OUT cafteria.intarray7
,INOUT Year4 cafteria.intarray4
)
LANGUAGE RPGLE
specific cafteria.sp_hRoll2
not deterministic
no sql
called on null input
EXTERNAL NAME myLib.HROLL
parameter style general with nulls
This will not compile I get a message:
SQL State: 42710
Vendor Code: -601
Message: [SQL0601] INTARRAY4 in CAFTERIA type *SQLUDT already exists. Cause
. . . . . : An attempt was made to create INTARRAY4 in CAFTERIA or to
rename a table, view, alias, or index to INTARRAY4, but INTARRAY4 already
exists. All tables, views, aliases, indexes, SQL packages, sequences,
global variables, masks, permissions, constraints, triggers, user-defined
types, and XSR objects in the same schema must have unique names. -- If
INTARRAY4 is a temporary table, it cannot be replaced unless the WITH
REPLACE clause is specified. -- If the schema name is *N, this is a CREATE
SCHEMA statement. If this is a CREATE TABLE or ALTER TABLE statement and
the type is *N, INTARRAY4 is a constraint. Recovery . . . : Change
INTARRAY4 to a name that does not exist, or delete, move, or rename the
existing object. If this is a temporary table, use the WITH REPLACE clause.
If creating an SQL package, specify REPLACE(*YES) on CRTSQLPKG. Try the
request again.
Then I tried
CREATE OR *REPLACE* PROCEDURE cafteria.sp_HROLL3 (
IN Client *CHAR*(*2*)
,IN ENum *numeric*(*7*,*0*)
,IN PlanYr *numeric*(*4*,*0*)
,OUT Category *numeric*(*32*)
,OUT ROLL_IN *numeric*(*56*)
,OUT ROLL_OUT *numeric*(*56*)
,OUT Year4 *numeric*(*32*)
)
LANGUAGE RPGLE
specific cafteria.sp_hroll3
not deterministic
no sql
called on null input
EXTERNAL NAME cafteria.HROLL
parameter style general with nulls
This will return values but the arrays are all messed up.
How would you write the stored procedure command?
--
Kerwin Crawford
--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a
message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit:
https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.
As an Amazon Associate we earn from qualifying purchases.