Subject | RE: [firebird-support] how to use order by for selected record in insert |
---|---|
Author | Mercea Paul |
Post date | 2008-02-10T22:10:54Z |
Thanks Ann, Helen , Uwe
I have made to work with for select do insert.
I thought I could insert in specific order with one statement : insert into
() select from..order by . !
Thanks,
Paul
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Helen Borrie
Sent: Sunday, February 10, 2008 11:11 PM
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] how to use order by for selected record in
insert
At 02:53 AM 11/02/2008, you wrote:
declare val1 integer;
declare val2 varchar(n);
...
begin
newid = whatever;
FOR select "ORDER", complete_descr
from rpr_comp
where code = :oldid
order by 1
INTO :newid, :val1, :val2 DO
insert into rpr_com (TheID, "ORDER", complete_descr)
-- check your typing - did you mean rpr_com or rpr_comp?
values (:newid, :val1, :val2);
...
end
./heLen
[Non-text portions of this message have been removed]
I have made to work with for select do insert.
I thought I could insert in specific order with one statement : insert into
() select from..order by . !
Thanks,
Paul
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Helen Borrie
Sent: Sunday, February 10, 2008 11:11 PM
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] how to use order by for selected record in
insert
At 02:53 AM 11/02/2008, you wrote:
>Hideclare newid integer;
>
>Using FB1.5 I need to copy records from one ID to another in same order
>I have a procedure for copy that contains :
>insert into rpr_com (code, order, complete_descr)
> select :newid, c2.order, c2. complete_descr
> from rpr_comp c2
> where c2. code=:oldid;
>
> I need to order the select by second column (order) ,something like:
>insert into rpr_com (code, order, complete_descr)
> select :newid, c2.order, c2. complete_descr
> from rpr_comp c2
> where c2. code=:oldid order by c2.order;
>
>but I get compilation error when I save the procedure!
>
>How can I insert ? (without using variables)
declare val1 integer;
declare val2 varchar(n);
...
begin
newid = whatever;
FOR select "ORDER", complete_descr
from rpr_comp
where code = :oldid
order by 1
INTO :newid, :val1, :val2 DO
insert into rpr_com (TheID, "ORDER", complete_descr)
-- check your typing - did you mean rpr_com or rpr_comp?
values (:newid, :val1, :val2);
...
end
./heLen
[Non-text portions of this message have been removed]