Subject Re: Select + Update in a single SPROC?
Author hartertobak
Hhmm, okay. Thank you for helping, but this still doesn´t work:

ALTER PROCEDURE SP_TBLONE_INS_UPD(
SEARCHTERM VARCHAR(400) CHARACTER SET UTF8 DEFAULT NULL)
RETURNS(
SEARCHEXISTS SMALLINT)
AS
DECLARE VARIABLE getid INTEGER;
BEGIN
select ID from TBLONE where searchterm = :SEARCHTERM into :getid;
SUSPEND;
if (:getid is null) THEN
insert into TBLONE (SEARCHTERM, LASTSEARCH, SEARCHCOUNT) VALUES
(:SEARCHTERM,cast('now' as timestamp), 1);
END;

any hint, please?


--- In firebird-support@yahoogroups.com, "Martijn Tonies"
<m.tonies@...> wrote:
>
> >On Freitag, 23. November 2007, hartertobak wrote:
> >> if (:SEARCHEXISTS = 0) THEN
> >
> >if (:searchexists is null)
>
> This will work, because if you do not initialize your variables,
> they will contain NULL.
>
> Take in account, that if no rows are found, the variable will
> contain the same value as before the SELECT ... INTO.
>
> As a "rule of thumb", it might be wise to get used to initializing
> your variables yourself.
>
> >or with FB 2.0
> >
> >if (row_count=0)
>
>
> Martijn Tonies
> Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB,
Oracle &
> MS SQL Server
> Upscene Productions
> http://www.upscene.com
> My thoughts:
> http://blog.upscene.com/martijn/
> Database development questions? Check the forum!
> http://www.databasedevelopmentforum.com
>