Subject RE: [firebird-support] Is there a better way of doing this ?
Author Alan McDonald
> Alan,
>
> For small tables yes, but some tables have dozens of columns so
> rather that a long insert statement - this shortcut is used.
>
> Stephen

it's not a shortcut though. even if there are 100 other fields, you can
still ignore then in the insert statement. After all, you are ignoring them
in the upate statement.
Alan

> ----- Original Message -----
> From: Alan McDonald
> To: firebird-support@yahoogroups.com
> Sent: Friday, November 24, 2006 3:50 PM
> Subject: RE: [firebird-support] Is there a better way of doing this ?
>
>
> > When a new product is created the insert statement ensures that
> > it is inserted in the table.
> >
> > After that point, it exists and only the update section matters.
>
> but you only need to insert, not insert then update. make it
> one operation
> INSERT INTO BALE(CODE, FABRICCODE, FABRICDESCR, APMCODE, etc, ) VALUES
> (:CODE, :FABRICCODE, ETC).
>
> >
> > What is the 'exists predicate' ?
>
> Alexandre has answered this one
>
> >
> > Thanks
> >
> >
> > ----- Original Message -----
> > From: Alan McDonald
> > To: firebird-support@yahoogroups.com
> > Sent: Friday, November 24, 2006 10:42 AM
> > Subject: RE: [firebird-support] Is there a better way of doing this ?
> >
> >
> > > I use this structure to table maintenance processes.
> > >
> > > The simple question is , can it be done in a better way ?
> > >
> > > Thanks
> > >
> > > Stephen
> > >
> > > SET TERM ^ ;
> > > CREATE PROCEDURE BALE_SAVE
> > > (
> > > CODE VARCHAR(30),
> > > FABRICCODE VARCHAR(20),
> > > FABRICDESCR VARCHAR(60),
> > > APMCODE VARCHAR(20),
> > > APMDESCR VARCHAR(60),
> > > QTYEST NUMERIC(15,2)
> > > )
> > > AS
> > > DECLARE VARIABLE CNT INTEGER ;
> > > BEGIN
> > >
> > > SELECT COUNT(CODE) FROM BALE
> > > WHERE BALE.CODE = :CODE
> > > INTO CNT ;
> > >
> > > IF (:CNT=0) THEN INSERT INTO BALE(CODE) VALUES (:CODE) ;
> > >
> > > UPDATE BALE
> > > SET
> > > FABRICCODE = :FABRICCODE,
> > > FABRICDESCR = :FABRICDESCR,
> > > APMCODE = :APMCODE,
> > > APMDESCR = :APMDESCR,
> > > QTYEST = :QTYEST
> > > WHERE
> > > CODE = :CODE ;
> > >
> > > END ^
> > >
> >
> > I would use the exists predicate and not do a count - it's
> much faster.
> > And why do an insert, then an update? Why not just insert the values?
> > Alan
> >
> >
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
> >
> >
> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >
> > Visit http://www.firebirdsql.org and click the Resources item
> > on the main (top) menu. Try Knowledgebase and FAQ links !
> >
> > Also search the knowledgebases at http://www.ibphoenix.com
> >
> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://www.firebirdsql.org and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Yahoo! Groups Links
>
>
>
>
>