Subject Re: [firebird-support] Simple stored procedure won't work
Author Helen Borrie
At 07:20 PM 8/12/2004 -0700, you wrote:

>I'm back with another lame question, I'm seriously stumped here!
>
>I have a simple sproc that selects records from a table, filtered by a
>parameter passed into it. I can do a regular select statement, copied right
>out of the sproc itself and it returns records. But...when I execute the
>stored procedure, I get *nothing*.

Well, first I'm tempted to wonder why you want to use a SP at all to get
this set. Is there something you are not telling us?

Still, if you must....either write it as a selectable SP (as below) and
invoke it with SELECT <output list> FROM SELECT_PRODUCT_BY_PRODUCT(:product_id)


>create or alter procedure sel_product_by_product_id
>(
> product_id int
>)
>returns
>(
> product_id_ int,
> product_name_ varchar(50),
> product_num_ varchar(50),
> synopsis_ varchar(500),
> description_ varchar(1000),
> wholesale_price_ decimal(9, 2),
> unit_price_ decimal(9, 2),
> sale_price_ decimal(9, 2),
> weight_ decimal(9, 2),
> height_ decimal(9, 2),
> width_ decimal(9, 2),
> length_sz_ decimal(9, 2),
> insured_value_ decimal(9, 2),
> is_free_shipping_ char,
> shipping_amt_ decimal(9, 2),
> is_cross_sell_ char,
> thumbnail_ varchar(100),
> photo_ varchar(100)
>)
>AS
>begin

FOR

> select
> product_id,
> product_name,
> product_num,
> description,
> synopsis,
> wholesale_price,
> unit_price,
> sale_price,
> weight,
> height,
> width,
> length_sz,
> insured_value,
> is_free_shipping,
> shipping_amt,
> is_cross_sell,
> thumbnail,
> photo
> from
> product
> where
> product_id = :product_id
> into
> :product_id_,
> :product_name_,
> :product_num_,
> :synopsis_,
> :description_,
> :wholesale_price_,
> :unit_price_,
> :sale_price_,
> :weight_,
> :height_,
> :width_,
> :length_sz_,
> :insured_value_,
> :is_free_shipping_,
> :shipping_amt_,
> :is_cross_sell_,
> :thumbnail_,
> :photo_

DO SUSPEND;

>end
> ^

....or keep it as it is, use EXECUTE PROCEDURE and read the XSQLDA
structure when it has executed.

Tip:
Don't try to test EXECUTE PROCEDURE in IBConsole or some other tool that
doesn't provide an interface for reading the results of executed DML. The
procedure call will work but you won't be able to inspect the results. Use
isql or, if you hate the command line interface, use something like IB_SQL,
which has a DSQL tool that returns your result (read the Fields tab - it
uses IBO, which returns EXECUTE PROCEDURE output to an array of Fields[]).

./hb