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!

*********************************************************************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

Reply via email to