Passing Comma separated input to stored procedure in IN clause

Hi All,
I have a query below in a stored procedure as like this
Create PROCEDURE insertinfo
@userids varchar(MAX)
AS
BEGIN
INSERT INTO records
(id
,name
,address1
,address2
,pincode
SELECT
id,
name,
addr1,
addr2,
pin,
FROM userinfo
WHERE userinfo.id in(@userids)
END
I am not using any dynamic sql. Its a simple insert into select query with multiple parameters supplied via thd @userids parameter. When i  run the query nothing is inserting in the "records" table. I have gone throught the web search have
tried with few options but no result yet. The query works fine when i pass only a single value, but it does not work when is pass multiple values.
Please guide on this.
Your help is appreciated.
Thanks,
mds2907

mds2907,
CHeck this:
--Method 1
--Usage of TVP
--Method 2
--Usage of SPLIT fn()
Create PROCEDURE insertinfo(@userids varchar(MAX))
AS
BEGIN
INSERT INTO records
(id,name,address1,address2,pincode)
SELECT id, name,addr1,addr2, pin
FROM userinfo
WHERE userinfo.id in(select * from sample_split(@userids,','))
END
--Method3
--Usage of Dynamic SQL
Applicable only when the values in csv are integers
like '1,2,3'
Create PROCEDURE insertinfo(@userids varchar(MAX))
AS
BEGIN
DECLARE @sql nvarchar(max)
SET @sql='
INSERT INTO records
(id,name,address1,address2,pincode)
SELECT id, name,addr1,addr2, pin
FROM userinfo
WHERE userinfo.id in('+@userids')'
EXEC sp_executesql @sql
END
Sample_Split():
CREATE FUNCTION dbo.sample_Split
@RowData nvarchar(2000),
@SplitOn nvarchar(5)
RETURNS @RtnValue table
Id int identity(1,1),
Data nvarchar(100)
AS
BEGIN
Declare @Cnt int
Set @Cnt = 1
While (Charindex(@SplitOn,@RowData)>0)
Begin
Insert Into @RtnValue (data)
Select
Data = ltrim(rtrim(Substring(@RowData,1,Charindex(@SplitOn,@RowData)-1)))
Set @RowData = Substring(@RowData,Charindex(@SplitOn,@RowData)+1,len(@RowData))
Set @Cnt = @Cnt + 1
End
Insert Into @RtnValue (data)
Select Data = ltrim(rtrim(@RowData))
Return
END
Usage of TVP for a scenario similar to yours is explained herE:
http://blog.sqlauthority.com/2008/08/31/sql-server-table-valued-parameters-in-sql-server-2008/
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/0ead7ceb-3fdd-4625-aa82-1d4195f984b1/passing-multivalue-parameter-in-stored-procedure-ssrs
Thanks,
Jay
<If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

Similar Messages

  • Passing comma separated string to stored procedure

    Hi,
    There is thread with same query I created earlier and that was answered. That solution worked if I pass comma separated string containing IDs. But due to changes in the logic, I have to pass usernames instead of userIDs. I tried to modify the solution provided to use with this.
    Following the link to previous post :
    Re: Passing comma separated string to stored procedure
    ------Package-------
    TYPE refcurQID IS REF CURSOR;
    TYPE refcurPubs IS REF CURSOR;
    procedure GetAllPersonalQueue (p_user_name in nvarchar2, TestQID OUT Test.refcurQID
    , TestPubs OUT Test.refcurPubs);
    ------Package-------
    ------Package Body-------
    PROCEDURE GetAllPersonalQueue (p_user_name in nvarchar2, TestQID OUT Test.refcurQID, TestPubs OUT Test.refcurPubs) as
    BEGIN
    Open TestQID for
    select id from cfq where name in (p_user_name);
    Open TestPubs for
    SELECT qid FROM queues WHERE qid in(
    select id from cfq where name in (p_user_name));
    END GetAllPersonalQueue;
    ------Package Body-------
    Thanks in advance
    Aditya

    Hi,
    I modified the query as per the solution provided by isotope, after which the logic changed and I am passing username instead of userID in comma separated string.
    Following is the changes SP, which does not throw any error, but no data is returned.
    PROCEDURE GetAllPersonalQueue (p_user_name in nvarchar2, TestQID OUT Test.refcurQID, TestPubs OUT Test.refcurPubs
    ) is
    --local variable
    strFilter varchar2(100);
    BEGIN
    Open TestQID for
    select id, name from cfq where name in
    select regexp_substr(p_user_name||',','[a-z]+[0-9]+',1,level)
    from dual
    connect by level <= (select max(length(p_user_name)-length(replace(p_user_name,',')))+1
    from dual)
    Open TestPubs for
    SELECT qid FROM queues WHERE qid in(
    select id from cfq where name in
    select regexp_substr(p_user_name||',','[a-z]+[0-9]+',1,level)
    from dual
    connect by level <= (select max(length(p_user_name)-length(replace(p_user_name,',')))+1
    from dual)
    END GetAllPersonalQueue;
    Edited by: adityapawar on Feb 27, 2009 8:38 AM

  • How to pass an array to a stored procedure

    create or replace package demo_pkg
    as
    type cityArray is table of city%rowtype index by binary_integer;
    procedure city_report( p_inputs in cityArray );
    end;
    CREATE OR REPLACE PACKAGE BODY demo_pkg
    AS
    PROCEDURE city_report (p_inputs IN cityarray)
    IS
    BEGIN
    FOR i IN 1 .. p_inputs.COUNT
    LOOP
    DBMS_OUTPUT.put_line ( 'citycode = '
    || p_inputs (i).city_code
    || ' CITYDESCRIPTION = '
    || p_inputs (i).city_description
    INSERT INTO testing
    (city_code, city_description
    VALUES (p_inputs (i).city_code, p_inputs (i).city_description
    commit;
    END LOOP;
    END;
    END;
    to call that procedure ia m using this
    declare
    my_data demo_pkg.cityArray;
    begin
    my_data(1).city_code := 1234;
    my_data(1).CITY_DESCRIPTION := 10;
    my_data(2).city_code := 4567;
    my_data(2).CITY_DESCRIPTION := 20;
    my_data(3).city_code := 4321;
    my_data(3).CITY_DESCRIPTION := 30;
    demo_pkg.city_report( my_data );
    end;
    but actually the procedure (demo_pkg.city_report)is called from front end(.net).how they will call this procedure in .net invironment

    Hi,
    Your exact question has been asked before, see: http://asktom.oracle.com/pls/ask/search?p_string=How+to+pass+an+array+to+a+stored+procedure
    or do a search on this forum.
    And please use this tag => (yes, just the 4 characters forming the word 'code' between curly brackets)
    *before* and *after* your example to maintain formatting and indentation, it's hard to read now....                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to pass the parameter of a stored procedure to iReport

    Hi... i don't know how to pass the parameter of the stored procedure to the iReport.
    In the Report Query, i tried
    1. sp_storedprocedure ' value'
    2. sp_storedprocedure +''''+$P{parameter}+''''+
    3. sp_storedprocedure +$V+$P{parameter}++$F($F is a variable having a value of ' (a single quote))may you enlighten us please? thank you

    For M$ SQL server I find that it only works when U use the fully qualified name...
    e.g. catalod.dbo.my_procedure_name 'variable'
    My full query in the Report Query window is something like this:
    EXEC arc.dbo.jasper_Invoice 1000
    Note that you may find that selecting from VIEWS / TABLES fails for no apparent reason and iReport will prompt you with the usual very unhelpful (we have what we "pay" for) prompt, stating that "The document is empty".
    To work around this issue, where a statement like "SELECT * FROM arc.dbo.acc_invoices WHERE Invoice_id=1000" does not work, simply create a PROC, something like:
    CREATE PROC jasper_MyProc (@my_rec_id integer) AS
    SELECT * FROM arc.dbo.acc_invoices WHERE Invoice_id= @my_rec_id integer
    ...to wrap your SELECT statement, then call the PROC
    Edited by: Sylinsr on Apr 22, 2008 4:23 PM

  • URGENT: I want to pass a variable to a stored procedure at run time

    Post Author: aruplabs
    CA Forum: Data Connectivity and SQL
    I work for a health care provider and I have reports that pull PHI (Protected Health Information) about patients that needs to be logged according to federal HIPAA regulations. One of the pieces of information that needs to be logged is the username of the person who ran the report. Since these reports will be run from our Crystal Enterprise server I can get this from the CurrentCEUserName variable but I am looking for a way to pass this value to a stored procedure that will not only return the records for the report, but also log the disclosure in our PHI disclosure tracking table. I know you can pass a parameter to a stored procedure but I dont know how, or if it is even possible, to pass a run time variable. This is an urgent problem that I need to find a solution for. Any help would be appreciated.
    Thank you.

    Here it is. Right now, when i press te "Go" it runs for the specific time i've set and when its done the variable "Run" is set true. When i call this VI from another VI it waits for the loop to be finished before it will read the variable.
    Regards
    Viktor
    Attachments:
    Untitled 2.vi ‏26 KB

  • How to pass javascript variable to PLSQL stored procedure

    Hi,
    How can I pass a javascript variable to a database procedure. I have a form with a radio button group and would like to save the value of the selected radio button to a database table by passing the value to the stored procedure.
    Thanks

    Hi
    You can use iframe to call the procedure. Here is an example used in dynamic page or pl/sql portlet. The pl/sql procedure is called myprocedure and resists in the schema myschema. This example passes 2 parameters, but I have not yet reased a limit.
    First the call within a javascript function:
    myiframe.location.href="myschema.myprocedure?p_myprameter1=" + vJvascriptparameter1 + "&p_myprameter2=" + vJvascriptparameter2;
    Then the iframe:
    <iframe id="myiframe" height="0" width="0" frameborder="0"></iframe>
    You can let the pl/sql procedure print a value, that can be used i the portlet. You can get the value in a javascript this way:
    myvalue=top.window.frames["myiframe"].document.body.innerHTML;
    Best regards
    Klaus

  • Passing multi-value parameter in stored procedure ssrs

    I have  customer parameter which is a drop down list in my report and I have set it to "allow multiple values". This is an SSRS report.
    How do I pass multiple values to my stored procedure?
    RJ

    Hi ,
    Create a Table valued function in SQL Functions  as below 
    Step 1
    CREATE FUNCTION [dbo].[FnSplit]
    @List nvarchar(2000),
    @SplitOn nvarchar(5)
    RETURNS @RtnValue table 
    Id int identity(1,1),
    Value nvarchar(100)
    AS  
    BEGIN
    While (Charindex(@SplitOn,@List)>0)
    Begin 
    Insert Into @RtnValue (value)
    Select
    Value = ltrim(rtrim(Substring(@List,1,Charindex(@SplitOn,@List)-1))) 
    Set @List = Substring(@List,Charindex(@SplitOn,@List)+len(@SplitOn),len(@List))
    End 
    Insert Into @RtnValue (Value)
    Select Value = ltrim(rtrim(@List))
    Return
    END
    Step 2 in your store procedure change the parameter where condition something like below
    ALTER PROCEDURE [dbo].[SomeSP] 
    -- Add the parameters for the stored procedure here
    @CostCentre NVARCHAR(255)
    SELECT
    [ProjectCode],[ProjectName],[ProjectManager],SUM([Hours]) AS [Hours MTD]FROM dbo.Rpt_NRMA_CATS NC
    INNER JOIN PeriodID P ON NC.PeriodID=P.PeriodID
    WHERE 
    ([CostCentre]) collate database_default IN(SELECT Value FROM dbo.FnSplit(@CostCentre,','))
    END
    I hope this will help you.
    Dasari

  • Pass a date parameter to Stored Procedure

    Hello friends,
    Can you help to pass a date parameter to Stored procedure from JSP. This is my code:
    In Oracle 9i I have this:
    PROCEDURE SP_EDORES(
    pfechaini IN hist_pol_reclama.hrc_fecha_contabilidad%Type, <-- This is a date field
    pfechafin IN hist_pol_reclama.hrc_fecha_contabilidad%Type, <-- This is a date field
    p_recordset OUT PKG_REP_CIERRE.cursor_type) AS
    In JSP have this:
    CallableStatement stmt = (CallableStatement)conn.prepareCall( "begin PKG_REP_CIERRE.SP_EDORES(?,?,?); end;" );
    stmt.registerOutParameter(3,oracle.jdbc.driver.OracleTypes.CURSOR);
    stmt.setDate(1,Date.valueOf("01-06-2005"));
    stmt.setDate(2,Date.valueOf("30-06-2005"));
    ResultSet rset = (ResultSet)stmt.getObject(3);
    while (rset.next()) {
    %>
    <TR>
    <TD ALIGN=CENTER> <%= rset.getString(1) %> </TD>
    <TD ALIGN=CENTER> <%= rset.getString(2) %> </TD>
    <TD ALIGN=CENTER> <%= rset.getString(3) %> </TD>
    <TD ALIGN=CENTER> <%= rset.getInt(4) %> </TD>
    </TR>
    <%
    The Stored Procedure returns de Result set, however I think does not recognized the date format because I need it with this format dd-mm-yyyy.
    Thanks in advance

    to use Date you will need the oracle package.
    u can try this other solution: use String, not Date
    CallableStatement stmt = (CallableStatement)conn.prepareCall( "begin PKG_REP_CIERRE.SP_EDORES(?,?,?); end;" );
    stmt.registerOutParameter(3,oracle.jdbc.driver.OracleTypes.CURSOR);
    stmt.setString(1,"01-06-2005");
    stmt.setString(2,"30-06-2005");
    ResultSet rset = (ResultSet)stmt.getObject(3);
    while (rset.next()) {
    %>
    if this don't work you can change your PL/SQL to get Strings and do the conversion with TO_DATE in the sql statement.

  • Passing CLOB datatype to a stored procedure

    Hi,
    How do I pass a CLOB value to a stored procedure?
    I am creating a stored procedure which appends a value to a CLOB datatype. The procedure has 2 in parameter (one CLOB and one CLOB). The procedure is compiled but I'm having problem executing it. Below is a simplified version of the procedure and the error given when the procedure is executed.
    SQL> CREATE OR REPLACE PROCEDURE prUpdateContent (
    2 p_contentId IN NUMBER,
    3 p_body IN CLOB)
    4 IS
    5 v_id NUMBER;
    6 v_orig CLOB;
    7 v_add CLOB;
    8
    9 BEGIN
    10 v_id := p_contentId;
    11 v_add := p_body;
    12
    13 SELECT body INTO v_orig FROM test WHERE id=v_id FOR UPDATE;
    14
    15 DBMS_LOB.APPEND(v_orig, v_add);
    16 commit;
    17 END;
    18 /
    Procedure created.
    SQL> exec prUpdateContent (1, 'testing');
    BEGIN prUpdateContent (1, 'testing'); END;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'PRUPDATECONTENT'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Any help or hints please.
    null

    sorry I made a mistake with the in parameter types - it's one NUMBER and one CLOB.

  • Pass BPC SSIS variable to stored procedure

      Dear All
    We have a ssis package in which there is data flow task. There
    is a OLEDB source which uses “Data access mode” as sql command. We used OLEDB data source instead of execute sql task as the outuput is table format generated in Stored proc which is used in following task
    This task calls a stored procedure with a input parameter which will be appset name.   [EXEC ProcName '@BPCAPPSET']
    The stored procedure is executing fine without any issues.But when I pass variable containing appset name to that stored  procedure its not taking properly and package ending successful.
    The variable is “BPCAPPSET” it contains appset name which
    will be taken front end.
       However to test if this value is taken by stored procedure
    or not, I tried to hardcode and pass appset name to stored procedure. i.e exec
    ProcName Appset1.
      Appset1 is existing appset. It worked fine. But we want to
    put this package in all land scapes, such that whenever it is triggered it will
    take the appset as parameter and does the calculation in stored procedure.
       Please advice how to pass this variable to stored
    procedure.
    regards
    Prasad

      Hi Roberto
    Thanks for your mail.
    I have tried, but I am getting error that @BPCAPPSET scalar
    variable must be defined.
    I believe that @BPCAPPSET is system defined variable which
    will be passed from Data manager package. May be this is the reason it is not
    recognizing this variable?
    If so, should I define a variable in SSIS. How can we
    assign value of @BPCAPPSET to the newly defined variable?
    Please advise. Attached screenshot.

  • Passing XMLType Data into oracle stored procedure using JDBC

    Hi Friends,
    I have requirement where my oracle stored procedure accepts XML file as an input. This XML File is generated in runtime using java, I need to pass that xml file using JDBC to oracle stored procedure. Please let me know the fesibile solution for this problem.
    Following are the environment details
    JDK Version: 1.6
    Oracle: 10g
    Server: Tomcat 6.x
    Thanks in Advance

    user4898687 wrote:
    I have requirement where my oracle stored procedure accepts XML file as an input. This XML File is generated in runtime using java, I need to pass that xml file using JDBC to oracle stored procedure. Please let me know the fesibile solution for this problem.As stated - no.
    A 'file' is a file system entity. There is no way to pass a 'file' anywhere. Not PL/SQL. Not java.
    Now you can pass a file path (a string) in java and to PL/SQL.
    Or you can pass xml data (a string) in java and to PL/SQL. For PL/SQL you could use eithe a varchar2, if the xml is rather small, or a blob/clob.

  • Passing Tables back from Java Stored Procedures

    Thomas Kyte has written (in reference to
    trying to pass an array back from a stored
    function call):
    You can do one of two things (and both require the use of
    objects). You cannot use PLSQL table types as JDBC cannot bind to
    this type -- we must use OBJECT Types.
    [snip]
    Another way is to use a result set and "select * from
    plsql_function". It could look like this:
    ops$tkyte@8i> create or replace type myTableType as table of
    varchar2 (64);
    2 /
    Type created.
    ops$tkyte@8i>
    ops$tkyte@8i>
    ops$tkyte@8i> create or replace
    2 function demo_proc2( p_rows_to_make_up in number )
    3 return myTableType
    4 as
    5 l_data myTableType := myTableType();
    6 begin
    7 for i in 1 .. p_rows_to_make_up
    8 loop
    9 l_data.extend;
    10 l_data(i) := 'Made up row ' &#0124; &#0124; i;
    11 end loop;
    12 return l_data;
    13 end;
    14 /
    Function created.
    ops$tkyte@8i>
    ops$tkyte@8i> select *
    2 from the ( select cast( demo_proc2(5) as mytableType )
    3 from dual );
    COLUMN_VALUE
    Made up row 1
    Made up row 2
    Made up row 3
    Made up row 4 [Image]
    Made up row 5
    So, your JDBC program would just run the query to get the data.
    If the function "demo_proc2" cannot be called from SQL for
    whatever reason (eg: it calls an impure function in another piece
    of code or it itself tries to modify the database via an insert
    or whatever), you'll just make a package like:
    ops$tkyte@8i> create or replace package my_pkg
    2 as
    3
    4 procedure Make_up_the_data( p_rows_to_make_up in
    number ); 5 function Get_The_Data return myTableType;
    6 end;
    7 /
    Package created.
    ops$tkyte@8i>
    ops$tkyte@8i> create or replace package body my_pkg
    2 as
    3
    4 g_data myTableType;
    5
    6 procedure Make_up_the_data( p_rows_to_make_up in number )
    7 as
    8 begin
    9 g_data := myTableType();
    10 for i in 1 .. p_rows_to_make_up
    11 loop
    12 g_data.extend;
    13 g_data(i) := 'Made up row ' &#0124; &#0124; i;
    14 end loop;
    15 end;
    16
    17
    18 function get_the_data return myTableType
    19 is
    20 begin
    21 return g_data;
    22 end;
    23
    24 end;
    25 /
    Package body created.
    ops$tkyte@8i>
    ops$tkyte@8i> exec my_pkg.make_up_the_data( 3 );
    PL/SQL procedure successfully completed.
    ops$tkyte@8i>
    ops$tkyte@8i> select *
    2 from the ( select cast( my_pkg.get_the_data as mytableType
    ) 3 from dual );
    COLUMN_VALUE
    Made up row 1
    Made up row 2
    Made up row 3
    And you'll call the procedure followed by a query to get the
    data...
    I have tried this, and it works perfectly.
    My question, is what does the wrapper look
    like if the stored function is written
    in java instead of PL/SQL? My experiments
    with putting the function in java have been
    dismal failures. (I supposed I should also
    ask how the java stored procedure might
    look also, as I suppose that could be where
    I have been having a problem)
    null

    Thanks for the response Avi, but I think I need to clarify my question. The articles referenced in your link tended to describe using PL/SQL ref cursors in Java stored procedures and also the desire to pass ref cursors from Java to PL/SQL programs. Unfortunately, what I am looking to do is the opposite.
    We currently have several Java stored procedures that are accessed via select statements that have become a performance bottleneck in our system. Originally the business requirements were such that only a small number of rows were ever selected and passed into the Java stored procedures. Well, business requirements have changed and now thousands and potentially tens of thousands of rows can be passed in. We benchmarked Java stored procedures vs. PL/SQL stored procedures being accessed via a select statement and PL/SQL had far better performance and scaleable. So, our thought is by decouple the persistence logic into PL/SQL and keeping the business logic in Java stored procedures we can increase performance without having to do a major rewrite of the existing code. This leads to the current problem.
    What we currently do is select into a Java stored procedure which has many database access calls. What we would like to do is select against a PL/SQL stored procedure to aggregate the data and then pass that data via a ref cursor (or whatever structure is acceptable) to a Java stored procedure. This would save us a significant amount of work since the current Java stored procedures would simple need to be changed to not make database calls since the data would be handed to them.
    Is there a way to send a ref cursor from PL/SQL as an input parameter to a Java stored procedure? My call would potentially look like this:
    SELECT java_stored_proc(pl/sql_stored_proc(col_id))
    FROM table_of_5000_rows;
    Sorry for the lengthy post.

  • Passing Values to Stored Procedure for "IN" Clause

    Hello All:
    I am trying to pass values to a stored procedure to use in an IN clause, and getting an "ORA-01722: invalid number".
    I believe this has something to do with how .Net handles strings and how I am trying to pass it to my stored procedure.
    The values I know need to be IN (2, 1) for the stored procedure to work, and I built a routine that creates a string value to pass in the format "2, 1", but I believe because this value is defined as a string in the .Net code, the leading and trailing apostrophe characters are causing the problem in the stored procedure.
    I have in my .Net code the following:
    oCommand.Parameters.Add("groupID_", OracleDbType.Varchar2).Value = GroupID;
    Where GroupID is defined as a string character, and has values of the following: 2, 1, but due to how .net handles it, it passes as "2, 1".
    So of course, inside my stored procedure,
    CREATE OR REPLACE PROCEDURE PAYSOL.sp_ProjectsManAppAndFundRpt(
    p_Cursor1 OUT SYS_REFCURSOR,
    p_Cursor2 OUT SYS_REFCURSOR,
    p_Cursor3 OUT SYS_REFCURSOR,
    p_Cursor4 OUT SYS_REFCURSOR,
    p_Cursor5 OUT SYS_REFCURSOR,
    groupID_ IN VARCHAR2)
    where I am defining the groupID_ parameter as a VARCHAR2, it is keeping the apostrophes, causing problems when I use it in my IN clause:
    AND S.GroupID IN (groupID_)
    What do I need to do to pass this value correctly? Is there something I can do inside the stored procedure to strip those characters, or do I need to pass it differently, or completely alter how I am handling this? I don't know the right path to head down, so wanted to seek some help.
    Thanks
    Andy

    IN Clauses and parameterized queries can be tricky beasts; so while logically it makes sense to do what you want (it does not do so in databases!)
    you can handle this problem in a few ways:
    1) anonymous sql (don't recommend)
    2) a user defined type and function as such
    --see  http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:210612357425
    --create a table of numbers ,create a function to split the "where" into a table
    --then return the data
    CREATE OR REPLACE type numberTableType as table      of number;
    create or replace function in_number(  p_string in varchar2 ) return numberTableType  AS
            l_string        long default p_string || ',';
            l_data          numberTableType := numberTableType();
            l_number        number ;
            N               NUMBER;
        BEGIN
          loop
              exit when l_string is null;
              n := instr( l_string, ',' );
             l_data.extend;
             begin --is user inputs a non-numeric value  skip the value
                l_number := cast(ltrim( rtrim( substr( l_string, 1, n-1 ) ) )  as number);
                l_data(l_data.count) := l_number ;
                EXCEPTION
                        WHEN VALUE_ERROR THEN
                            l_number := 0;
                        WHEN OTHERS THEN
                            raise ;
             end ;
             l_string := substr( l_string, n+1 );
        end loop;
        RETURN L_DATA;
      END in_number;
    --then your code
    AND S.GroupID IN (select column_value from table(in_number(groupID_))3) actually, just look at this blog posting! it does a better job at this than I am!
    http://tkyte.blogspot.com/2006/06/varying-in-lists.html

  • Passing multiple values to a stored procedure

    Hi All,
    I have a stored procedure which displays a chart. The header of this procedure is:
    create or replace procedure chart ( p_period IN VARCHAR2) is
    When calling this procedure with something like the folloeing:
    <PARAM NAME=movie VALUE="/i/charts.swf?library_path=/i/charts_library&xml_source=ohsinit.chart?p_period=MONTH">
    everything works OK.
    Now, I would like to replace p_period=MONTH with a value coming from an ITEM on the page, so something like:
    <PARAM NAME=movie VALUE="/i/charts.swf?library_path=/i/charts_library&xml_source=ohsinit.chart?p_period=:P13_PERIOD">
    However, the above doesn't work.
    Can anyone give me the correct syntax please?
    Also what would be the syntax for passing more than one value? ie:
    source=ohsinit.chart?p_period=:P13_PERIOD,p_start=:P13_START_DATE ?
    Regards,
    Pawel.

    Hi Denes,
    I am not sure I understand your post...
    What I am trying to do here is to pass 3 values namely
    P13_PERIOD (VARCHAR2),
    P13_START_DATE (DATE),
    P13_END_DATE (DATE)
    into a stored procedure which displays the graph.
    So far I managed to get it working using:
    <PARAM NAME=movie VALUE="/i/charts.swf?library_path=/i/charts_library&xml_source=ohsinit.chart?p_period=&P13_PERIOD.">
    However when I try to put in:
    <PARAM NAME=movie VALUE="/i/charts.swf?library_path=/i/charts_library&xml_source=ohsinit.chart?p_period=&P13_PERIOD.,p_start=&P13_START_DATE.">
    I get the graph blank (but not the orange timeout message... if you are familiar with XML/SWG graphs.)

  • Passing Dynamic Values to a Stored Procedure

    I have a stored procedure to create a Table. How to I pass a
    value to the procedure to name the Table. This SP works except the
    name of the table is @newcomm not the value I am trying to pass in.
    What is the proper syntax to make this happen.
    CREATE PROCEDURE [dbo].[sp_newcommenttbl]
    @newcomm varchar (50)
    AS
    BEGIN
    CREATE TABLE [dbo].[@newcomm] (
    [configid] [int] IDENTITY (1, 1) NOT NULL ,
    [email] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
    NULL ,
    [adminemail] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [erroremail] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [toCommentFormEmail] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [dsn] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
    NULL ,
    [gmdsn] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
    NULL ,
    [dbusername] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [dbpassword] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [acfcpath] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [acfcpath2] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [acfcpath3] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [urlactivate] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [urlresetpassword] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [initialized] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [dbtablename1] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [dbtablename2] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [dbtablename3] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [dbtablename4] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [dbtablename5] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [dbtablename6] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [dbtablename7] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [dbtablename8] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [dbtablename9] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [dbtablename10] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [pageheader] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL
    ) ON [PRIMARY]
    END
    GO
    <cfstoredproc procedure="sp_newcommenttbl"
    datasource="xxxxx" returncode="no">
    <cfprocparam type="in" maxlength="50"
    cfsqltype="cf_sql_varchar" value="pighg3">
    </cfstoredproc>

    When I create the procedure I don't get an error. I get an
    error when I call it.
    [Macromedia][SQLServer JDBC Driver][SQLServer]Incorrect
    syntax near the keyword 'ON'.
    ColdFusion cannot determine the line of the template that
    caused this error. This is often caused by an error in the
    exception handling subsystem.
    Here is the call.
    <cfstoredproc procedure="sp_newcommenttbl"
    datasource="pisecurity" returncode="no">
    <cfprocparam type="in" maxlength="50"
    cfsqltype="cf_sql_varchar" value="pighg3" variable="newcomm">
    </cfstoredproc>
    Here is the syntax for the SP.
    CREATE PROCEDURE [dbo].[sp_newcommenttbl]
    @newcomm varchar (50)
    AS
    BEGIN
    EXEC('CREATE TABLE [dbo].['+@newcomm+'] (
    [configid] [int] IDENTITY (1, 1) NOT NULL ,
    [email] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
    NULL ,
    [adminemail] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [erroremail] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [toCommentFormEmail] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [dsn] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
    NULL ,
    [gmdsn] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
    NULL ,
    [dbusername] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [dbpassword] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [acfcpath] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [acfcpath2] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [acfcpath3] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [urlactivate] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [urlresetpassword] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [initialized] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [dbtablename1] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [dbtablename2] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [dbtablename3] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [dbtablename4] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [dbtablename5] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [dbtablename6] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [dbtablename7] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [dbtablename8] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [dbtablename9] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [dbtablename10] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL ,
    [pageheader] [varchar] (50) COLLATE
    SQL_Latin1_General_CP1_CI_AS NULL
    ON [PRIMARY]')
    END
    GO

Maybe you are looking for

  • MacOS 10.7 needs a new name

    I propose Lion King, as in "The Lion Sleeps Tonight .." On a serious note, this OS is truly slow, as in snail's pace. The simplest actions: opening/closing a file, quitting out of an application, or, on opening Preview, and clicking on File->Open Rec

  • Working of pga

    hi please tell me the internally working of pga ..im confused how it is work... working of PMON.. which type of lock release by pmon and how the lock held...

  • OSX 10.4.3 and ilife 06 Help!!

    I just installed ilife 06 on my mac. everything seemed to work fine but after installing it, the O.S asked me to restart which i did. Now OSX will not start up again. I get the startup progress bar, and it just hangs on that screen when the progress

  • Windows 7 User Startup

    We have 2 PC's that need to run only one Web Site Link for all Students.  We have a default user name and login profile for the PC's, but we would like to perform the following: Bypass the Login and go directly to IE opening the Web Site Link and all

  • Trying to add a Win7 laptop to network of 2 XPs.

    I'm running a home network with a desktop wired to a modem and WRT54G, with a laptop, also XP. Tried to add a new laptop, OS: Win7. The new laptop says it can access the network but can't access the Net. If I wire the laptop directly to the router, i