Subject Re: Insert SQL ???
Author ggroper
Thanks Uwe,

Could youn please give me a sample syntax for a stored procedure
transaction that I might use.

begin
begin transaction
insert into existingtable select * from view;
commit transaction
end;

What about this suspend statement also???

Thanks,

gerry


--- In firebird-support@yahoogroups.com, Uwe Grauer
<mailinglists@o...> wrote:
> Hi Gerry,
>
> yust a view hints:
>
> ggroper wrote:
>
> > I am new to Firebird and need a little clue as to the proper syntax
> > for a stored procedure.
> >
> > I'm inserting data into and existing empty table from a view.
> >
> > The view and the table structures are the same, field names, field
> > characteristic (as seen by Developers Workbench), and field order.
> >
> > insert into existingtable select * from view
> >
> > First question, does the insert ignore field names and just uses field
> > order and expect the field types to OK?
> >
> No, specify fieldnames in insert and select like you need it:
> insert into existingtable (col1, col2, ...) values (select (col1, col2,
> ...) from view)
>
> > Second, do I need some begin trans ... commit trans statements around
> > the insert statements???.
> >
> Yes, its always better to use exclusive transactions.
>
> > Is there any way to insert new records(primary key) and ignore
> > duplicate records or do I need to revise a view to illiminate those
> > duplicates??
> >
> You could use Generators for this. (You have to write a before insert
> trigger for this.)
> Refer to LANGREF.PDF and DATADEF.PDF:
>
http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_download_documentation
>
> > thanks,
> >
> > gerry
>
>
> Hope this helps for a starting point.
>
> Uwe