Subject | Re: [firebird-support] Re: Insert SQL ??? |
---|---|
Author | Uwe Grauer |
Post date | 2004-03-06T15:54:36Z |
Gerry,
you have to place the transaction outside of Stored Procs.
start transaction
call stored proc
commit transaction
There are execute stored procs and select stored procs.
suspend is needed in select stored procs:
select from storedproc
Please read the appropiate Docs!
I do not know the syntax out of my head.
I have to consult the docs also.
Feel free to ask again.
Uwe
ggroper wrote:
you have to place the transaction outside of Stored Procs.
start transaction
call stored proc
commit transaction
There are execute stored procs and select stored procs.
suspend is needed in select stored procs:
select from storedproc
Please read the appropiate Docs!
I do not know the syntax out of my head.
I have to consult the docs also.
Feel free to ask again.
Uwe
ggroper wrote:
> 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
> <http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_download_documentation>
> >
> > > thanks,
> > >
> > > gerry
> >
> >
> > Hope this helps for a starting point.
> >
> > Uwe