Solved

Multiple parameters passed from Reporting Services to an Oracle database

Posted on 2011-03-10
11
449 Views
Last Modified: 2012-05-11
I have an oracle procedure that works fine with reporting services if I want either 'All' of the items in the list
or if I want just one, but not multiples.  I have tried creating a function from code I found but I get
an error "Error(4,23): PLS-00201: identifier '','' must be declared".  I have done very little work with either
Oracle or reporting services.  Can someone please give me very clear detailed instructions on
what I'm doing wrong.  Thank you.  My deadline is tomorrow.

create or replace function MultiParam
(
    p_cursor sys_refcursor,
    p_del varchar2 := "','"
) return varchar2
is
    l_value   varchar2(32767);
    l_result  varchar2(32767);
begin
    loop
        fetch p_cursor into l_value;
        exit when p_cursor%notfound;
        if l_result is not null then
            l_result := l_result || p_del;
        end if;
        l_result := l_result || l_value;
    end loop;
    return l_result;
end MultiParam;

Open in new window

0
Comment
Question by:bmurray61259
  • 5
  • 3
11 Comments
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35094750
Please provide more about the requirements.

From the little you posted, I would guess that you are wanting to pass a comma delimited list into a function/procedure and have it processed in some IN-List in a query.

This can be done but you need to use Dynamic SQL.

I can help with the PL/SQL code but have never touched Reporting Services.
0
 

Author Comment

by:bmurray61259
ID: 35094859
I am receiving a list from reporting services like the following
'123, 456, 789'.  What I need is a list for the parameter that looks like '123', '456', '789'.

I create the variable which is a varchar2 in a stored procedure.  The original line that gets me either all or one is WHERE (sitrepinteractionfields.sitename = p_Site  OR NVL(p_Site, ' ') = ' ' or p_Site = 'All')

If you need any other info let me know.
0
 

Author Comment

by:bmurray61259
ID: 35094870
I am receiving a list from reporting services like the following
'123, 456, 789'.  What I need is a list for the parameter that looks like '123', '456', '789'.

I create the variable which is a varchar2 in a stored procedure.  The original line that gets me either all or one is WHERE (sitrepinteractionfields.sitename = p_Site  OR NVL(p_Site, ' ') = ' ' or p_Site = 'All')

If you need any other info let me know.
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35095389
Can you post your stored procedure?

You will need to use dynamic sql or a little smoke and mirrors.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:bmurray61259
ID: 35096672

procedure Rpt_Multiple
  
              (p_Site varchar2 
              , p_ Type varchar2
              , p_Status varchar2
              , p_Start date :=null
              , p_End date :=null
              , cur_Multiple out t_cursor
              ) AS
  BEGIN
        open cur_Multiple for
   
          SELECT sitename
                , type
                , status
                , SITREPID
                , Service
                , ItemName
                , CreateDate
                , ModifiedDate
                
            FROM  interactionfields
               Inner Join sitreps
                on interactionfields. id = sitreps. id  

            WHERE (sitename in p_Site  OR NVL(p_Site, ' ') = ' ' or p_Site = 'All Locations')
              and (incidenttype = p_Incident_Type or NVL(p_Incident_Type, ' ') = ' ' OR p_Incident_Type = 'All' )
              and (status = p_Status OR NVL(p_Status, ' ') = ' ' OR p_Status = 'All')
              and (CreateDate <= p_ReportDateEnd or NVL(To_Char(p_ReportDateEnd, 'DD-MON-YY'),' ')= ' ' )
              and (CreateDate >=  p_ReportDateStart  or NVL(To_Char(p_ReportDateStart, 'DD-MON-YY'),' ')= ' ' )
             ;
END Rpt_Multiple;

Open in new window

0
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 35096935
Here's an example following your code.

the var, exec and print are sqlplus pieces to test the code.
drop table tab1 purge;
create table tab1(col1 char(1) primary key);

insert into tab1 values('a');
insert into tab1 values('c');
commit;

create or replace procedure myProc(in_site in varchar2, cur_multiple out sys_refcursor) is
begin

	open cur_multiple for 
	'select col1 from tab1 where ''' || in_site || ''' is null or col1 in (''' || replace(replace(in_site,' ',''),',',''',''') || ''') ';
end;
/

show errors

var myCur refcursor

exec myProc('a, b, c',:myCur);

print mycur

Open in new window

0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35366206
I believe http:#a35096935 answers the question.
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35370611
I suggest accept: http:#a35096935
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
A recent questions about how to add SSRS named instances, couldn't find any that talks about SQL server 2008, anyway I decided to help by creating some screen shots. The installation is straightforward, you just pop the SQL server 2008 installati…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now