Re: Suchfelder
geschrieben von:
mozart (---.landkreis-oder-spree.de)
Datum:
Suche mit mehreren Feldern in HTMLDB:
nachfolgendes Beispiel benötigt eine Seite 9 ;-) und damit : P9_Suchfeld 1-5
die Abfrage ist also dynamische Abfrage zu formulieren ...
ich denke die Arbeitsweise wird anhand des Beispiels gut klar ...
(- Abfrage in Variable
- prüfe of etwas im Suchfeld ist, wenn ja füge es der abfrage hinzu ansonten nix ...
- gib inhalt der variable als abfrage aus ... )
declare q varchar(4000);
begin
q:= 'select "PACHT_ID","FLSTKEY","ABS_NR","GEMARKUNG","GEMARKUNGSNR","FLUR", "ZAEHLER","NENNER" from "ABSCHNITTE" WHERE 1=1 ' ;
if :P9_SUCHFELD1 is not null then
q:=q||' and instr(upper(FLSTKEY),upper(nvl(:P9_SUCHFELD1,FLSTKEY))) > 0 ';
else null; end if;
if :P9_SUCHFELD3 is not null then
q:=q||' and instr(upper(FLUR),upper(nvl(:P9_SUCHFELD3,FLUR))) > 0 ';
else null; end if;
if :P9_SUCHFELD4 is not null then
q:=q||' and instr(upper(ZAEHLER),upper(nvl(:P9_SUCHFELD4,ZAEHLER))) > 0 ';
else null; end if;
if :P9_SUCHFELD5 is not null then
q:=q||' and instr(upper(NENNER),upper(nvl(:P9_SUCHFELD5,NENNER))) > 0 ';
else null; end if;
if :P9_SUCHFELD2 is not null then
q:=q||' and instr(upper(GEMARKUNG),upper(nvl(:P9_SUCHFELD2,GEMARKUNG))) > 0 ';
else null; end if;
return q;
end;
Gruß
mozart <[a]> htmldb.de