Link to home
Start Free TrialLog in
Avatar of Camillia
CamilliaFlag for United States of America

asked on

can a stored proc call RPG program?

We have an RPG program and I want to call it from my stored proc in AS400...

The RPG program formats something and I need to call it and use the returned result...
Avatar of momi_sabag
momi_sabag
Flag of United States of America image

and what language is the stored procedure ?
why not writting the stored procedure in RPG also ?
Avatar of Camillia

ASKER

Stored Proc is in AS400's SQL language...

Because I dont know RPG and my boss wants AS400 code in SQL to be similar to the SQL Server stuff we do...

Give me good news :)
ASKER CERTIFIED SOLUTION
Avatar of momi_sabag
momi_sabag
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

Momi is right. Wrap the RPG as a stored procedure.

e.g.
CREATE PROCEDURE MyLib/TheStoredProcName (
  IN   parameter1 ....
  OUT outputParam1
)
LANGUAGE RPGLE
NOT DETERMINISTIC
MODIFIES SQL DATA
CALLED ON NULL INPUT                
EXTERNAL NAME theRPGpgm  
PARAMETER STYLE GENERAL WITH NULLS;

-- DaveSlash
can it be as a function instead of a stored proc? Because i want to call it and return a value back...

Also, can u answer my other question here ..please ..ithink u said you've done C function in AS400...

Kent's been helping also...
http://www-new.experts-exchange.com/questions/22151096/What's-wrong-with-this-C-user-defined-function.html?qid=22151096&cid=239

Please ignore my comment about helping with the other question, i think i found my answer...

but for the RPG one...the RPG goes inside that "CREATE PROCEDURE MyLib/TheStoredProcName " OR
is the RPG just compiled on AS400, then I created that stored proc...call the stored proc which then calls the RPG?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can call any RPG program without declaring stored procedure.

See http://www.venera.com/downloads.htm#db2sp 

Look for the "iSeries DB2 stored procedures vulnerability" article.


The RPG name is 11 chars and I'm getting an error that "<rpgname> too long. Maximum 10 characters."..

wrapped it around single quotes too...no way around it? have to rename the RPG program?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hmm..that's what my manager gave me..i'll double check it again with her