roberthagan
Technical User
I'm trying to break up a client list by zipcode in several stored procedures where I have to provide a list of zips. I tried writing a function that would supply the list.
the query (simplified):
SELECT *
FROM CLIENT
WHERE ZIP IN (Manh_Split_Where_FuncSITE))
The function:
CREATE OR REPLACE FUNCTION Manh_Split_Where_Func (SITE IN CLIENT.SITE_CD%TYPE)
RETURN VARCHAR2
IS
searchwhere VARCHAR2(100);
BEGIN
IF SITE = 'MANHS' THEN
SEARCHWHERE := ' ' ||CHR(39)|| 10034 ||CHR(39)|| ',' ||CHR(39)|| 10040 ||CHR(39)|| ',' ||CHR(39)|| 10045 ||CHR(39)|| '' ;
ELSIF SITE = 'MANHN' THEN
SEARCHWHERE := ' ' ||CHR(39)|| 10025 ||CHR(39)|| 10025 ||CHR(39)|| ' ' ;
END IF;
RETURN SEARCHWHERE;
END Manh_Split_Where_Func;
/
(I found the idea of using CHR(39) here. Thanks.)
The function runs and returns the list of zips, but when I call it from the query, it runs and the query returns nothing. Any idea of what might be going on?
Thanks
Bob Hagan
the query (simplified):
SELECT *
FROM CLIENT
WHERE ZIP IN (Manh_Split_Where_FuncSITE))
The function:
CREATE OR REPLACE FUNCTION Manh_Split_Where_Func (SITE IN CLIENT.SITE_CD%TYPE)
RETURN VARCHAR2
IS
searchwhere VARCHAR2(100);
BEGIN
IF SITE = 'MANHS' THEN
SEARCHWHERE := ' ' ||CHR(39)|| 10034 ||CHR(39)|| ',' ||CHR(39)|| 10040 ||CHR(39)|| ',' ||CHR(39)|| 10045 ||CHR(39)|| '' ;
ELSIF SITE = 'MANHN' THEN
SEARCHWHERE := ' ' ||CHR(39)|| 10025 ||CHR(39)|| 10025 ||CHR(39)|| ' ' ;
END IF;
RETURN SEARCHWHERE;
END Manh_Split_Where_Func;
/
(I found the idea of using CHR(39) here. Thanks.)
The function runs and returns the list of zips, but when I call it from the query, it runs and the query returns nothing. Any idea of what might be going on?
Thanks
Bob Hagan