|
I know there are array, that's why I said "like in RPG"SQL Does have arrays...
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 Charles
Wilt
Sent: Thursday, 6 March 2025 15:51
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: Stored Procedure over RPGLE with arrays as parms issues
SQL Does have arrays...
And they are actually supported as a parameter when Java is used for your
External Stored Procedure.
https://www.ibm.com/docs/en/i/7.4?topic=statements-create-procedure-external
*array-type-name*Specifies an array type. Array types are only supported
for LANGUAGE JAVA. To use an array type as a parameter for a Java™ stored
procedure, the parameter style must be JAVA.
If the name of the array type is unqualified, the database manager
resolves the schema name by searching the schemas in the SQL path.
HTH,
Charles
On Wed, Mar 5, 2025 at 9:19 PM Birgitta Hauser <Hauser@xxxxxxxxxxxxxxx>
wrote:
SQL does not have Arrays and Data structures like RPG.Cause
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.
. . . . . : An attempt was made to create INTARRAY4 in CAFTERIA or tostatement and
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
the type is *N, INTARRAY4 is a constraint. Recovery . . . : Changeclause.
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
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.
--
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.
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.
--
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.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.