|
It depends on what you need, how many records you are returning, and how
much other processing you need to do.
If all I needed to do is return some records from the database, I would
use an SQL statement in PHP. Of course, I would also be using a framework
such as Zend to do the work rather than some non-OO method. You really
don't gain anything by using a stored procedure unless that procedure is
encapsulating some business logic that needs to be used outside PHP as
well. You still need to do all the same things in PHP to process the
results of the stored procedure that you would have to do if you were
executing an SQL select statement. The only real difference is that you
are executing an SQL call instead.
But if you are intent on using a stored procedure, the easiest way is to
just open a cursor, and end the procedure. As long as the procedure knows
that the cursor returns a result set, then the open cursor will be
returned as the result set. No arrays or multi-occurrence data structure
necessary.
Mark Murphy
STAR BASE Consulting, Inc.
mmurphy@xxxxxxxxxxxxxxx
From: Michael Ryan <michaelrtr@xxxxxxxxx>
To: "RPG programming on the IBM i / System i" <rpg400-l@xxxxxxxxxxxx>
Date: 11/30/2010 09:57 AM
Subject: Best Practice for Returning Multiple Rows from RPG to PHP
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
Ok...here's what I really want to know.
What is the best option for returning multiple rows of data from RPG to
PHP?
Here's some of my considerations:
* I don't want to do complex processing in my PHP script; I'd rather use
the
PHP to access and display data;
* The RPG program is needed because I'll be accessing multiple tables and
could be doing some complex processing;
* I need to return 1-n rows of data.
* I'm on V5R4.
When I look at a stored procedure, I see that I can return a result set.
However, I think I need to have an array or a multiple occurrence DS,
which
makes me think I would need to know how many rows I would return. I was
thinking about a UDTF. Would that mean my RPG program would write (INSERT)
records to the UDTF and then my PHP script would just do a simple SELECT?
Does a global temporary table play in this?
I appreciate the insight. Thanks!
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing
list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 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.