Subject Re: [firebird-support] Re: Custom search string
Author Patrick Antonioli
HEllo GRANT,

I think the fast way is using COALESCE . But there is BUG in this function,
it only WORKS when you don´t use any column of type BLOB(TEXT or BINARY) ...
if you don´t use these columns... put this in you PROC an it will run LIKE
"The Flash".... it is realy simple... but you have to use like in this
example, if you change some thing, may be work, but you will have problems
with NULL columns... that is why you have to have a fixed comparation and
the column comparation and last, your variable ... this way will work FINE.

I am looking for some UDF to make it work with BLOB columns.. if some body
know where I can find, I will be really happy.

Patrick

---------------------------
Take a look in this example...

SET TERM ^ ;
CREATE PROCEDURE spTbl_USUARIO_SelectSearch
(
"iSMALLINT_FIELD" SMALLINT,
"iINTEGER_FIELD" INTEGER,
"iBIGINT_FIELD" BIGINT,
"iFLOAT_FIELD" FLOAT,
"iDOUBLE_FIELD" DOUBLE PRECISION,
"iCHAR_FIELD" CHAR(50),
"iVARCHAR_FIELD" VARCHAR(50),
"iNUMERIC_FIELD" NUMERIC(4, 1),
"iDECIMAL_FIELD" NUMERIC(9, 1),
"iDATE_FIELD" DATE
)
RETURNS
(
"SMALLINT_FIELD" SMALLINT,
"INTEGER_FIELD" INTEGER,
"BIGINT_FIELD" BIGINT,
"FLOAT_FIELD" FLOAT,
"DOUBLE_FIELD" DOUBLE PRECISION,
"CHAR_FIELD" CHAR(50),
"VARCHAR_FIELD" VARCHAR(50),
"NUMERIC_FIELD" NUMERIC(4, 1),
"DECIMAL_FIELD" NUMERIC(9, 1),
"DATE_FIELD" DATE
)
AS
BEGIN
FOR
SELECT
"SMALLINT_FIELD",
"INTEGER_FIELD",
"BIGINT_FIELD",
"FLOAT_FIELD",
"DOUBLE_FIELD",
"CHAR_FIELD",
"VARCHAR_FIELD",
"NUMERIC_FIELD",
"DECIMAL_FIELD",
"DATE_FIELD"
FROM "USUARIO"
WHERE
COALESCE("USUARIO"."SMALLINT_FIELD", 0) = COALESCE(:"iSMALLINT_FIELD",
"USUARIO"."SMALLINT_FIELD", 0) AND
COALESCE("USUARIO"."INTEGER_FIELD", 0) = COALESCE(:"iINTEGER_FIELD",
"USUARIO"."INTEGER_FIELD", 0) AND
COALESCE("USUARIO"."BIGINT_FIELD", 0) = COALESCE(:"iBIGINT_FIELD",
"USUARIO"."BIGINT_FIELD", 0) AND
COALESCE("USUARIO"."FLOAT_FIELD", 0) = COALESCE(:"iFLOAT_FIELD",
"USUARIO"."FLOAT_FIELD", 0) AND
COALESCE("USUARIO"."DOUBLE_FIELD", 0) = COALESCE(:"iDOUBLE_FIELD",
"USUARIO"."DOUBLE_FIELD", 0) AND
COALESCE("USUARIO"."CHAR_FIELD", '') = COALESCE(:"iCHAR_FIELD",
"USUARIO"."CHAR_FIELD", '') AND
COALESCE("USUARIO"."VARCHAR_FIELD", '') = COALESCE(:"iVARCHAR_FIELD",
"USUARIO"."VARCHAR_FIELD", '') AND
COALESCE("USUARIO"."NUMERIC_FIELD", 0) = COALESCE(:"iNUMERIC_FIELD",
"USUARIO"."NUMERIC_FIELD", 0) AND
COALESCE("USUARIO"."DECIMAL_FIELD", 0) = COALESCE(:"iDECIMAL_FIELD",
"USUARIO"."DECIMAL_FIELD", 0) AND
COALESCE("USUARIO"."DATE_FIELD", '1979.08.27') = COALESCE(:"iDATE_FIELD",
"USUARIO"."DATE_FIELD", '1979.08.27')
INTO
:"SMALLINT_FIELD",
:"INTEGER_FIELD",
:"BIGINT_FIELD",
:"FLOAT_FIELD",
:"DOUBLE_FIELD",
:"CHAR_FIELD",
:"VARCHAR_FIELD",
:"NUMERIC_FIELD",
:"DECIMAL_FIELD",
:"DATE_FIELD"
DO
BEGIN
SUSPEND;
END
END
^
SET TERM ; ^


Patrick

2005/5/2, Ali Gökçen <alig@...>:
>
> > Yes - that what I need,
> >
> > I'll give it a go and let you know how I get on.
> >
> > Thanks for your help.
>
> Wellcome. Makes me happy if it solves your problem.
>
> I was forced to discovered this logic myself when i wrote my
> graduation project using SQL/370 + CSP/AD in 1989.
> They were Internetless, Firebirdless, missing days. ;)
>
> Ali
> The Militia of Firebird
>
>
> Visit http://firebird.sourceforge.net 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]