Subject | Re: Union in firebird |
---|---|
Author | Adam |
Post date | 2005-08-16T02:53:52Z |
--- In firebird-support@yahoogroups.com, "didinh2000"
<didinh2000@y...> wrote:
name and zip code as parameters if you liked.
...
BEGIN
FOR select emp_id,emp_loan from loan_mtd
union
select emp_id,emp_loan from loan_ytd
INTO :EMP_ID, :EMP_LOAN
DO
BEGIN
insert into employee (emp_id,emp_name,emp_zip,emp_loan) values
(:emp_id,'Name xxx','0001',:emp_loan);
END;
END;
But I am not too sure if your original logic would work anyway,
because I am guessing that loan_mtd and loan_ytd would contain
records relevant to other customers (so you would want to include a
where condition)
Adam
<didinh2000@y...> wrote:
> Why this statement doesn't work in firebird 1.5 ?Pretty simple, Firebird doesn't support that syntax.
>
> insert into employee (emp_id,emp_name,emp_zip,emp_loan)
> select emp_id,'Name xxx','0001',emp_loan from loan_mtd
> union
> select emp_id,'Name xxx','0001',emp_loan from loan_ytd
>
> or you've suggest for this problem ?A Stored Procedure could easily do it. You could pass in the employee
name and zip code as parameters if you liked.
...
BEGIN
FOR select emp_id,emp_loan from loan_mtd
union
select emp_id,emp_loan from loan_ytd
INTO :EMP_ID, :EMP_LOAN
DO
BEGIN
insert into employee (emp_id,emp_name,emp_zip,emp_loan) values
(:emp_id,'Name xxx','0001',:emp_loan);
END;
END;
But I am not too sure if your original logic would work anyway,
because I am guessing that loan_mtd and loan_ytd would contain
records relevant to other customers (so you would want to include a
where condition)
Adam