Subject Re: [firebird-support] Firebird SP Question
Author jengleman@formaleasy.com
myles@... wrote:
> Is it possible to have a stored procedure in FB execute two separate
> SELECT
> statements, and return a merged set of results back? Forgive me being a
> newbie to creative SELECT statements in SQL, but I have a set of data
> that I
> can get with one select statement, and then another set of data from the
> same table with another SELECT statement, and I want to return these back
> from the stored procedure in a sorted order so that the first set of
> results
> appear first, and the 2nd set of results are 'appended' onto the set.
>
> Can this be done?
Below is a sample Stored Procedure I use to return one row of data I
need for several areas
code I support. In this case I only needed sums for specific data and a
calculation

Best Regards

Jack


ALTER PROCEDURE GET_BCOUNT(S VARCHAR(10), SI VARCHAR(5), T CHAR(1))
RETURNS ( C1 INTEGER, C2 INTEGER, C3 INTEGER, S1 NUMERIC(15, 2))
AS
DECLARE VARIABLE X NUMERIC(15,2);
BEGIN
SELECT
COUNT(BARCODE), SUM(COST)
FROM BARCODES, INV_STAT
WHERE STYLE = :S AND SIZE_FIELD = :SI AND BARCODES.STATUS = INV_STAT.STAT
AND INV_STAT.INSTK = "True"
INTO :C1, :S1;
SELECT
COUNT( BARCODE )
FROM BARCODES, INV_STAT
WHERE STYLE = :S AND SIZE_FIELD = :SI AND BARCODES.STATUS = INV_STAT.STAT
AND INV_STAT.AVAIL = "True"
INTO :C2;
SELECT
COUNT( BARCODE )
FROM BARCODES
WHERE STYLE = :S AND SIZE_FIELD = :SI AND (STATUS = "IN" OR STATUS =
"CLE" OR STATUS = "LAU")
INTO :C3;
IF (T = "T") THEN
BEGIN
X = S1/C1;
UPDATE INVENTORY_RECS SET TOTAL_INVESTMENT = :S1, WE_OWN = :C1,
AVG_COST = :X, AVAIL_FOR_RENT = :C2
WHERE STYLE = :S AND SIZE_FIELD = :SI;
END
END ^

>
> Myles
>
>
> ============================
> Myles Wakeham
> Director of Engineering
> Tech Solutions US, Inc.
> Scottsdale, Arizona USA
> Phone (480) 451-7440
> www.techsol.org
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://firebird.sourceforge.net and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>
>
>
> SPONSORED LINKS
> Technical support
> <http://groups.yahoo.com/gads?t=ms&k=Technical+support&w1=Technical+support&w2=Computer+technical+support&w3=Compaq+computer+technical+support&w4=Compaq+technical+support&w5=Hewlett+packard+technical+support&w6=Technical+support+services&c=6&s=195&.sig=s2Gugju7oqbFSnQe5CXN-g>
> Computer technical support
> <http://groups.yahoo.com/gads?t=ms&k=Computer+technical+support&w1=Technical+support&w2=Computer+technical+support&w3=Compaq+computer+technical+support&w4=Compaq+technical+support&w5=Hewlett+packard+technical+support&w6=Technical+support+services&c=6&s=195&.sig=P0EO8-oNi-ENyo4f44hTrg>
> Compaq computer technical support
> <http://groups.yahoo.com/gads?t=ms&k=Compaq+computer+technical+support&w1=Technical+support&w2=Computer+technical+support&w3=Compaq+computer+technical+support&w4=Compaq+technical+support&w5=Hewlett+packard+technical+support&w6=Technical+support+services&c=6&s=195&.sig=yxbBDDzaSk3A5ChUmIsGQg>
>
> Compaq technical support
> <http://groups.yahoo.com/gads?t=ms&k=Compaq+technical+support&w1=Technical+support&w2=Computer+technical+support&w3=Compaq+computer+technical+support&w4=Compaq+technical+support&w5=Hewlett+packard+technical+support&w6=Technical+support+services&c=6&s=195&.sig=waTmaDVJ1O5EVV9ojJdNIA>
> Hewlett packard technical support
> <http://groups.yahoo.com/gads?t=ms&k=Hewlett+packard+technical+support&w1=Technical+support&w2=Computer+technical+support&w3=Compaq+computer+technical+support&w4=Compaq+technical+support&w5=Hewlett+packard+technical+support&w6=Technical+support+services&c=6&s=195&.sig=BHeXNb70xUEL93wl8IkWbQ>
> Technical support services
> <http://groups.yahoo.com/gads?t=ms&k=Technical+support+services&w1=Technical+support&w2=Computer+technical+support&w3=Compaq+computer+technical+support&w4=Compaq+technical+support&w5=Hewlett+packard+technical+support&w6=Technical+support+services&c=6&s=195&.sig=V7eKfOJm-lo7uSPyz1mcEA>
>
>
>
> ------------------------------------------------------------------------
> YAHOO! GROUPS LINKS
>
> * Visit your group "firebird-support
> <http://groups.yahoo.com/group/firebird-support>" on the web.
>
> * To unsubscribe from this group, send an email to:
> firebird-support-unsubscribe@yahoogroups.com
> <mailto:firebird-support-unsubscribe@yahoogroups.com?subject=Unsubscribe>
>
> * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/>.
>
>
> ------------------------------------------------------------------------
>