Subject | Re: [firebird-support] how to use order by for selected record in insert |
---|---|
Author | Helen Borrie |
Post date | 2008-02-10T21:11:09Z |
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
>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