ejemplo de la ejecución, delphi 7, zeos 6.1.5 stable, postgres 8:
Código Delphi
[-]
zConnection1.HostName := host;
zConnection1.Port := puerto;
zConnection1.User := 'hola';
zConnection1.Password := 'mundo';
zConnection1.Connect;
zQuery1.SQL.Clear;
ZQuery1.SQL.Add('SET CLIENT_ENCODING TO ' + #39 + 'LATIN2' + #39 + ';');
zQuery1.SQL.Add('SELECT * FROM busca_CD(');
zQuery1.SQL.Append('NULL' + ',' +
#39 + cadena + #39 + ',' +
#39 + 'NULL' + #39 + ',' +
#39 + 'NULL' + #39);
zQuery1.SQL.Append(') AS ("Cód." char, "Título Principal" varchar, "Título Secundario" varchar, "Contenido" text);');
zQuery1.Active := TRUE;
ZConnection1.Disconnect
el cual llama a esta función:
Código SQL
[-]
CREATE OR REPLACE FUNCTION busca_cd(bpchar, character varying, character varying, character varying)
RETURNS SETOF record AS
'
SELECT
CD.cod_amigable,
CD.titulo1,
CD.titulo2,
Contenido_CD.descripcion
FROM CD, Contenido_CD
WHERE
(((CD.cod_barra LIKE $1) OR
(CD.titulo1 LIKE ''%'' || $2 || ''%'') OR
(CD.titulo2 LIKE ''%'' || $3 || ''%'') OR
(Contenido_CD.descripcion LIKE ''%'' || LOWER($4) || ''%'')) AND
Contenido_CD.cod_barra = CD.cod_barra);
'
LANGUAGE 'sql' VOLATILE;
En el código delphi, #39 corresponde al caracter --> ' <-- (ALT+39), que lo ingresé así pq sino me cerraba el string en el código de delphi :P
Si quieres ver los datos, enlazas a un DBGrid y listo
Saludos !!