Subject Re: [firebird-support] for..do statement help
Author Alexandre Benson Smith
dinol.softedge wrote:
> Hi
>
> I am trying to iterate through records in the tbl_job_card table and
> insert the values retrieved from the select statement and insert them
> into another table called tbl_job_card_employee. My statement follows
>
> BEGIN
> for select job_card_id, employee_id, employee_commission FROM tbl_job_card
> into :job_card, :employee, :comm DO
> INSERT INTO tbl_job_card_employee
> (job_card_id,
> employee_id,
> commission)
> VALUES
> (job_card,
> employee,
> comm);
> SUSPEND;
> END
>
> I get an error on job_card on line 4
>

missing collons.

try this:

BEGIN
for
select
job_card_id, employee_id, employee_commission
FROM
tbl_job_card
into
:job_card, :employee, :comm
DO
INSERT INTO
tbl_job_card_employee
(job_card_id, employee_id, commission)
VALUES
(:job_card, :employee, :comm);

END




> I would also like to run this statement directly (i.e. not a
> procedure), is this possible?
>

yes

INSERT INTO

tbl_job_card_employee
(job_card_id, employee_id, commission)
select
job_card_id, employee_id, employee_commission
FROM
tbl_job_card


> Any help with this statement would be greatly appreciated.
> Thanks in advance
>
>

see you !

--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br