Return-Path: <root@fatcity.cts.com>
Received: from newsfeed.cts.com (newsfeed.cts.com [209.68.248.164])
 by naude.co.za (8.11.2/8.11.2) with SMTP id g2PIv2G16602
 for <oracle-l@naude.co.za>; Mon, 25 Mar 2002 13:57:02 -0500
Received: from fatcity.UUCP (uucp@localhost)
 by newsfeed.cts.com (8.9.3/8.9.3) with UUCP id LAA55287;
 Mon, 25 Mar 2002 11:02:17 -0800 (PST)
Received: by fatcity.com (26-Feb-2001/v1.0g-b70/bab) via UUCP id 004324CB; Mon, 25 Mar 2002 10:40:30 -0800
Message-ID: <F001.004324CB.20020325104030@fatcity.com>
Date: Mon, 25 Mar 2002 10:40:30 -0800
To: Multiple recipients of list ORACLE-L <ORACLE-L@fatcity.com>
X-Comment: Oracle RDBMS Community Forum
X-Sender: "Jamadagni, Rajendra" <Rajendra.Jamadagni@espn.com>
Sender: root@fatcity.com
Reply-To: ORACLE-L@fatcity.com
Errors-To: ML-ERRORS@fatcity.com
From: "Jamadagni, Rajendra" <Rajendra.Jamadagni@espn.com>
Subject: RE: Function With Variable input
Organization: Fat City Network Services, San Diego, California
X-ListServer: v1.0g, build 70; ListGuru (c) 1996-2001 Bruce A. Bergman
Precedence: bulk
Mime-Version: 1.0
Content-Type: multipart/mixed;	boundary="------------InterScan_NT_MIME_Boundary"
--------------InterScan_NT_MIME_Boundary
Content-Type: text/plain;
 charset="iso-8859-1"

Hmmm ....

create or replace function myfunc (in_userlist in varchar2) 
return varchar2 is
  -- in_userlist is a comma delimited list of user numbers
  szRtnVar	varchar2(1000) := null;
  --
  szSqlText	varchar2(1000) := null;
  vRefCur	REF CURSOR;
begin
  szSqltext := 'select nvl(weight, 0) from tablea where usera in (' ||
in_userlist || ')';
  open vRefCur for szSqltext;
  loop
    fetch vRefCur into szTmp;
    exit when vRefCur%notfound;
    szRtnVar := szRtnVar || ',' || to_char(szTmp);
  end loop;
  if vRefCur%isopen then
    close vRefCur;
  end if;
  return (ltrim(szRtnVar,','));
end myfunc;
/

or if you have 8i, 9i then try this ...

create or replace function myfunc (in_userlist in varchar2) 
return varchar2 is
  -- in_userlist is a comma delimited list of user numbers
  szRtnVar	varchar2(1000) := null;
  --
  itTmpTab	dbms_utility.uncl_array;  -- table type definition for
varchar2
  szSqlText	varchar2(1000) := null;
  vRefCur	REF_CURSOR;
  nRows	number := 0; -- holds number of rows
begin
  szSqltext := 'select to_char(nvl(weight, 0)) from tablea where usera in ('
|| in_userlist || ')';
  execute immediate szSqlText BULK COLLECT into itTmpTab;
  dbms_utility.table_to_comma(itTmpTab, nRows, szRtnVar);
  return (szRtnVar);
end myfunc;
/

Of course check for syntaxes etc. Both these examples assume that the "in"
parameter is of type a,b,c,d etc.

Raj
______________________________________________________
Rajendra Jamadagni		MIS, ESPN Inc.
Rajendra dot Jamadagni at ESPN dot com
Any opinion expressed here is personal and doesn't reflect that of ESPN Inc.

QOTD: Any clod can have facts, but having an opinion is an art!

--------------InterScan_NT_MIME_Boundary
Content-Type: text/plain;
 name="ESPN_Disclaimer.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="ESPN_Disclaimer.txt"


*********************************************************************2

This e-mail message is confidential, intended only for the named recipient(s) above and may contain information that is privileged, attorney work product or exempt from disclosure under applicable law. If you have received this message in error, or are not the named recipient(s), please immediately notify corporate MIS at (860) 766-2000 and delete this e-mail message from your computer, Thank you.

*********************************************************************2


--------------InterScan_NT_MIME_Boundary--
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Jamadagni, Rajendra
  INET: Rajendra.Jamadagni@espn.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru@fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

