Subject | Re: SQL statement with multiply function |
---|---|
Author | Adam |
Post date | 2006-03-15T01:21:01Z |
--- In firebird-support@yahoogroups.com, "majstoru" <majstoru@...>
wrote:
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
wrote:
>which
> 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
> will return this table in formatqty
> 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
> column in table1.A stored procedure can output the article and id however many times
>
> Thanks for help!
>
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