Subject | Re: Stored procedure - what am I doing wrong |
---|---|
Author | reinier_olislagers |
Post date | 2006-08-02T14:53:09Z |
Hoi Martijn,
Thanks for your quick reply.
See my comments below...
--- In firebird-support@yahoogroups.com, "Martijn Tonies"
<m.tonies@...> wrote:
the info concerned to e.g. the TBLPATHS table...
I explicitly declared the local... variables NULL in the beginning of
the sp..
Thanks, but this means more work if the info already exists - I'd have
to get the primary key again using a select statement...
(sending output to an external text table) I realized that I had a
unique constraint on TBLVERSIONS.FILEVERSION. Whenever I tried to add
a FILEVERSION,PRODUCTVERSION record that had an existing FILEVERSION
(but a new PRODUCTVERSION) the sp bombed. Changing the constraint to a
constraint on the two fields together helped <embarrassed grin>.
Reinier
Thanks for your quick reply.
See my comments below...
--- In firebird-support@yahoogroups.com, "Martijn Tonies"
<m.tonies@...> wrote:
>Thanks very much; changed that...
> > IF (:CATALOGID IS NULL) THEN
> > BEGIN
> > SUSPEND;
>
> SUSPEND should only be used if you plan on using this procedure
> as a SELECT-able procedure AND you want to return a row of data.
> If not, then use EXIT; instead.
>SELECT.
> > /* 1. Add path info if necessary */
> > SELECT PATHID FROM TBLPATHS WHERE FILEPATH=:filepath
> > INTO localPATHID;
> > IF (LOCALPATHID IS NULL) THEN
>
> If no row is found in the above SELECT query, LOCALPATHID will not
> be modified. That is, it will keep its value as it had before the
> Given that you did not intialize your variables, it is NULL and itwill be
> NULL afterwards if no rows are found.Exactly. This is my intention: if no rows are found, the sp should add
the info concerned to e.g. the TBLPATHS table...
>that.
> Try initializing it on a specific value, eg "-1" and then check for
I explicitly declared the local... variables NULL in the beginning of
the sp..
>FILEPATH=:filepath ) )
> Or use an EXISTS query:
>
> IF (NOT EXISTS ( SELECT PATHID FROM TBLPATHS WHERE
Thanks, but this means more work if the info already exists - I'd have
to get the primary key again using a select statement...
> > IF (FILEVERSION IS NOT NULL) THENMartijn (& others), I'm an idiot. After much testing and debugging
> > BEGIN
> > SELECT VERSIONID FROM TBLVERSIONS WHERE FILEVERSION=:fileversion
> > AND PRODUCTVERSION=:productversion
> > INTO localVERSIONID;
> > IF (localVERSIONID IS NULL) THEN
>
> Same here. If there's no row to be found, localVERSIONID will be NULL
> if you didn't intialize it before.
(sending output to an external text table) I realized that I had a
unique constraint on TBLVERSIONS.FILEVERSION. Whenever I tried to add
a FILEVERSION,PRODUCTVERSION record that had an existing FILEVERSION
(but a new PRODUCTVERSION) the sp bombed. Changing the constraint to a
constraint on the two fields together helped <embarrassed grin>.
>Thanks,
>
> Hope this helps.
Reinier