Subject | Re: SQL statement with multiply function |
---|---|
Author | majstoru |
Post date | 2006-03-15T01:45:12Z |
--- In firebird-support@yahoogroups.com, "Adam" <s3057043@...> wrote:
Thanks for yours very fast reply!
But I need this function for a printing a stickers, sometime a qty
number can be very very large and this is a main reaso why I would
like to just pass some SQL script and get a resultset that I need!
Yours idea is a great, but how can I do this on client to spare
network traffic and to be more eficient in n-tier setup?
Thanks again!
>Hi Adam,
> --- In firebird-support@yahoogroups.com, "majstoru" <majstoru@>
> wrote:
> >
> > Hi,
> >
> > I have a data in table (example)
> > Table1
> > id name qty
> > 1 Article 1 3
> > 2 Article 2 2
> > 3 Article 3 1
> >
> > is there any solution if Firebird that I can write SQL statement
> which
> > will return this table in format
> > Table2
> > id name
> > 1 Article 1
> > 1 Article 1
> > 1 Article 1
> > 2 Article 2
> > 2 Article 2
> > 3 Article 3
> >
> > whih mean that I get result table where avery record is multiplied
> > with qty, or how many rows are in resultset, that is represent a
> qty
> > column in table1.
> >
> > Thanks for help!
> >
>
> A stored procedure can output the article and id however many times
> qty represents:
>
>
> Create procedure SP_MultiplyArticles
> returns
> (
> id integer,
> name varchar(50)
> )
> as
> declare variable qty integer;
> declare variable i integer;
> begin
> for select id, name, qty
> from articles
> into :id, :name, :qty
> do
> begin
> i = 1;
> while (:i <= :qty) do
> begin
> suspend;
> i := :i + 1;
> end
> end
> end
> ^
>
> To run it.
>
> select *
> from SP_MultiplyArticles;
>
> It may be quicker to do it from the client (network traffic etc) if
> there are large qty numbers.
>
> Adam
>
Thanks for yours very fast reply!
But I need this function for a printing a stickers, sometime a qty
number can be very very large and this is a main reaso why I would
like to just pass some SQL script and get a resultset that I need!
Yours idea is a great, but how can I do this on client to spare
network traffic and to be more eficient in n-tier setup?
Thanks again!