Passing paramter to "in statement "

Hi,
I have a scenario where I have to pass a paramter to "in statement".
When I run the query from SQL plus its working fine.......but when I run the query at run time it doesnot come back with the results. I am sure its formating issue.
This is how I create a paramter
_sbInStatement.Append("(");
*foreach (ListItem item in _listBox.Items)*
if (item.Selected)
_sbInStatement.Append(item.Value).Append(",");*
*string strCheck = sbInStatement.ToString();*
if(_strCheck.EndsWith(","))
sbInStatement.Remove(sbInStatement.Length - 1, 1);*
_sbInStatement.Append(")");*
And for adding the paramter to sql....this is how I do.
oCmd.Parameters.Add(":InStatement", OracleDbType.Varchar2).Value = InStatement;
Can any1 please tell me how do I get this effect.
Thanks.
Reply With Quote

Hello,
Here's a link to an old(er) blog post that covers this (I think):
http://oradim.blogspot.com/2007/12/dynamically-creating-variable-in-list.html
The post is a bit too long to repeat completely here, but it illustrates a technique to create a dynamic in-list.
Regards,
Mark

Similar Messages

  • How to pass values in select statement as a parameter?

    Hi,
    Very simple query, how do I pass the values that i get in the cursor to a select statement. If table1 values are 1,2,3,4 etc , each time the cursor goes through , I will get one value in the variable - Offer
    So I want to pass that value to the select statement.. how do i do it?
    the one below does not work.
    drop table L1;
    create table L1
    (col1 varchar(300) null) ;
    insert into L1 (col1)
    select filter_name from table1 ;
    SET SERVEROUTPUT ON;
    DECLARE
    offer table1.col1%TYPE;
    factor INTEGER := 0;
    CURSOR c1 IS
    SELECT col1 FROM table1;
    BEGIN
    OPEN c1; -- PL/SQL evaluates factor
    LOOP
    FETCH c1 INTO offer;
    EXIT WHEN c1%NOTFOUND;
    DBMS_OUTPUT.PUT_LINE(offer);
    select * from table1 f where f.filter_name =:offer ;
    factor := factor + 1;
    DBMS_OUTPUT.PUT_LINE(factor);
    END LOOP;
    CLOSE c1;
    END;

    Hi User,
    You are looking somethuing like this, as passing the values to the Cursor as a Paramter.
    DECLARE
       CURSOR CURR (V_DEPT IN NUMBER)    --- Cursor Declaration which accepts the deptno as parameter.
       IS
          SELECT *
            FROM EMP
           WHERE DEPTNO = V_DEPT;    --- The, Input V_DEPT is passed here.
       L_EMP   EMP%ROWTYPE;
    BEGIN
       OPEN CURR (30);       -- Opening the Cursor to Process the Value for Department Number 30 and Processing it with a Loop below.
       DBMS_OUTPUT.PUT_LINE ('Employee Details for Deptno:30');
       LOOP
          FETCH CURR INTO L_EMP;
          EXIT WHEN CURR%NOTFOUND;
          DBMS_OUTPUT.PUT ('EMPNO: ' || L_EMP.EMPNO || ' is ');
          DBMS_OUTPUT.PUT_LINE (L_EMP.ENAME);
       END LOOP;
       CLOSE CURR;
       DBMS_OUTPUT.PUT_LINE ('Employee Details for Deptno:20'); -- Opening the Cursor to Process the Value for Department Number 20
       OPEN CURR (20);
       LOOP
          FETCH CURR INTO L_EMP;
          EXIT WHEN CURR%NOTFOUND;
          DBMS_OUTPUT.PUT ('EMPNO: ' || L_EMP.EMPNO || ' is ');
          DBMS_OUTPUT.PUT_LINE (L_EMP.ENAME);
       END LOOP;
       CLOSE CURR;
    END;Thanks,
    Shankar

  • PASSING PARAMETER IN SQL STATEMENT .

    HI,
    Can any one tell me how to use on of the field name as a parameter in the same sql statement ? Here is what i am looking for :
    SELECT EMPNO, DEPTNO, (SELECT COUNT(ORDERNO) FROM ORDERS WHERE DEPTNO = :DEPTNO AND EMPNO = :EMPNO) TOTAL_ORDER FROM EMP;
    Here the embeded sql statment should take the paramter :DEPTNO , :EMPNO from the main sql statement. That means , each DEPTNO, EMPNO should be passed as a aparameter to the embeded SQL statement.
    Thanks
    Feroz

    WHATS THE CONACT, ||, +, HOW TO USE IT, CAN U GIVE ME AN EXAMPLE.
    SORRY , HERE IS THE ACTUAL THING WHAT I AM LOOKING FOR, I WANT TO GET THE MEDIAN AND MODE VALUE IN ORACLE, BUT COZ ORACLE DOES NOT HAVE IN BUILT FUNCTION TO ET THE ABOVE TOW , I WROTE MY SQL STATEMENTS, FOR EXAMPLE THE MEDIAN OF SAL FOR DEPT 20 IS IS
    SELECT AVG(SAL) FROM
    (SELECT RowNum The_Rownum, SAL FROM
    (SELECT SAL FROM EMP WHERE DEPTNO = 20 ORDER BY 1)) V
    WHERE V.The_Rownum = ( SELECT FLOOR((COUNT(SAL)+1)/2) FROM EMP WHERE DEPTNO = 20)
    OR V.the_rownum = (SELECT CEIL((count(SAL)/2) + 1/2) FROM EMP WHERE DEPTNO = 20)
    This median value ncalculation i can put in a functio and return it, but for a record os 1,800,000 volume, calling this function that many times, the sql never executes. It just hangs. so i thought if i can emabede the whole calculaton in the main sql statement instead of writing a function and calling that function in the sql statement. But the median calculation needs the department no as a parameter to calculate the median for that perticular department. Here , where the requirement of PARAMETER comes. ANY IDEA ???
    Thanks
    Feroz

  • Parameter name passed in Set Callable Statement

    Is it not possible to pass parameter name in the callable statement while using Oracle drivers for jk 1.4??
    Thanks!

    Is it not possible to pass parameter name in the callable statement while using Oracle drivers for jk 1.4??
    Thanks!

  • Pass ORG_ID as sql statement for parameter in request set

    We are in a multi-org environment. We are running the request PRC: Generate Draft Revenue for a Single Project as part of the request set. We want the request to automatically fill in the open pa period as the accrue through date. We have been using the SQL Statement below as the value for the accrue through date parameter.
    select end_date
    from pa_periods_all
    where status = 'O'
    and current_pa_period_flag = 'Y'
    Unfortunately that does not limit to a specific company. We a company that still have DEC-05 while another has an open period of JAN-06. This is causing the program fits. How do I pass the org_id to the request? [in beginners terms please]
    Thanks.
    Anne

    No idea what might be wroong without more info...
    Do some output. Test the ${params.id} variable passed to the second jsp. If that is correct, then error is in the select statement or display of jsp2. If it is correct the error comes from jsp1.
    If I have to guess, then I would say the error comes from JSP1, and the ${row.vac_id} should only be called once. In which case I would do something like this:
    //in jsp 1
                <c:forEach var="row" items="${results.rows}"  varStatus="counter"  >
                    <c:set var="vac_id" value="${row.vac_id}" scope="page"/>
                    <tr>
                        <td>${vac_id}</td>
                        <td><a href="vacancydetails.jsp?id=${vac_id}">More</a></td>But that is a guess only...
    Errr... Hold on to that as reference, but the it is entirely likely that I misspelled ${params.id} It may be ${param.id} I forget and away from my machine right now...

  • Pass parameter to sql statement in query manager

    Hai to all,
               I want to pass the percentage  as the parameter into the sql statemnet.i what to execute it in the query manager.
              If i execute that statement then cann't found the tablename error is coming.
             Other than the data in the table (general data)  pass to the parameter in the sql at runtime.
    for example:
    select [%0] *100
    how to pass 10 to that sql statement.
    Please help me...
    Regards,
    Raji.

    Hi Ramya,
    You can create a SP with parameters to accept and then execut this SP from SAP Business One Query Manager by passing the parameter (in your case 10). The result will be as desired.
    Ex:
    Create this Procedure in SQL Management Studio
    create proc Test(@a as int)
    as
    begin
    select (@a*100)
    end
    To Execute the Query use this Query and pass the desired values with parameters
    execute Test 10
    Regards,
    Reno

  • Getting Username to pass into LOV select statement

    Hello!
    I'm wondering if its possible to get the username of the current user logged in and pass it as a variable into a select statement used in a dynamic LOV in Oracle AS Portal?
    What I'm attempting to do is pull all the values from a table that equal the current user's username to user on a portal report
    so (as a rough example)
    select color from mytable where username = 'whatever the user name is would be here'
    And then the current user would get a list of values from which to select based off of the values entered in this table.
    The issue I'm having is determing how to fill the 'whatever the user name is would be here' portion with the actual logged in user's username (or even if its possible). I know on the actual portal one can do #USER.FULLNAME# to display their username, is there a similar "variable" one may use to get the username for a LOV sql call?
    I can get it to work if I statically fix the username to a particular value (ex: where username = 'Joe.Hacker') but I'm unsure if theres a variable or bind value (for lack of a better term) to grab the username on the fly.. dynamically.

    portal.wwctx_api.get_user can be used in the SQL query of your portal report to get the user_name of the currently logged-in portal user. For more info on wwctx_api, see the 10.1.2 or 10.1.4 portal API docs at http://www.oracle.com/technology/products/ias/portal/html/plsqldoc/pldoc1012/index.html or http://www.oracle.com/technology/products/ias/portal/html/plsqldoc/pldoc1014/index.html

  • Passing parameter into SQL statement in Crystal Reports

    Hi all,
    I would like to call Crystal Reports in JSP. I can handle it well now. But I hope to let user input their selection criteria before printing out the report. I know how to get the parameter value in JSP, but I really dunno how to pass these parameter values into the SQL statement in Crystal Report. Actually, is it possible to do so?
    If anyone has idea, please tell me. Thx Thx!
    Regards,
    Betty

    Dear Sir,
    I want to use Crystal Report as a web base using JSP. But, I am getting how to call .rpt file in .jsp file & passing of parameter.
    If you have any idea, please reply as early as possible
    Thanking U.
    My userid = [email protected]
    Regds
    Pankaj..

  • Passing javascript in query statement

    Apexers,
    I have a query statement like below and not really sure what could be the problem here. I am calling a javascript in my query and passing some field values but its not working when i pass the javascript as below though query itself is correct and works if i remove the javascript reference ..can somebody help me on this please?
    SELECT ..... ,
    '<img src=''#WORKSPACE_IMAGES#male1.jpg'' width=''16px'' onclick="javascript:f_EmpDetails('||"EMP"."JOB"||');" height=''16px''/>' Link,
         "EMP"."JOB" as "JOB",
         "EMP"."MGR" as "MGR",
         "EMP"."HIREDATE" as "HIREDATE"
    FROM <TABLE-NAME>
    thanks & regards,
    Edited by: jieri on Aug 24, 2012 8:45 AM

    Hi,
    I have a query statement like below and not really sure what could be the problem here. I am calling a javascript in my query and passing some field values but its not working when i pass the javascript as below though query itself is correct and works if i remove the javascript reference ..can somebody help me on this please?
    SELECT ..... ,
    '<img src=''#WORKSPACE_IMAGES#male1.jpg'' width=''16px'' onclick="javascript:f_EmpDetails('||"EMP"."JOB"||');" height=''16px''/>' Link,
    "EMP"."JOB" as "JOB",
    "EMP"."MGR" as "MGR",
    "EMP"."HIREDATE" as "HIREDATE"
    FROM <TABLE-NAME>Try this
    SELECT ..... ,
    '<img src=''#WORKSPACE_IMAGES#male1.jpg'' width=''16px'' onclick="javascript:f_EmpDetails('||
        dbms_assert.enquote_literal("EMP"."JOB")||');" height=''16px''/>' Link,
    ...or
    SELECT ..... ,
    '<img src=''#WORKSPACE_IMAGES#male1.jpg'' width=''16px'' onclick="javascript:f_EmpDetails('''||
        "EMP"."JOB"||''');" height=''16px''/>' Link,  ...Cheers,

  • Passing tables with PERFORM statement

    Hi all,
    There is a table returned by a function module ZCDAPO_MATNR_CHECK_FOR_QUOTA .
    I want to use the table returned by this FM  in a subroutine.
    So i pass this table thru FORM statement.
    within  PERFORM  and ENDFORM i want to use the data in this table
    and do some manipulation.
    but i am getting an error saying for typing TABLES parameter only table types should be used
    can anyone tell me where i am going wrong or please tell me how use tables in this PERFORM statement.for reference i will paste the code below,
    TYPES  : BEGIN OF x_quota     ,
                   trpid type ztrpid    ,
                   quota TYPE decv1_3   , 
                   END OF x_quota       .
    DATA :  it_qheader TYPE TABLE OF zapo_trqtah,
                 wa_it_qheader LIKE LINE OF it_qheader.
    DATA:    it_qitem TYPE TABLE OF zapo_trqtap,
                 wa_it_qitem LIKE LINE OF it_qitem.
    DATA   : it_quotavalue      TYPE TABLE OF x_quota                    ,
                  wa_it_quotavalue   LIKE LINE  OF it_quotavalue              .
    CALL FUNCTION 'ZCDAPO_MATNR_CHECK_FOR_QUOTA'
          EXPORTING
            i_matnr            = 'AATESTQUOTA2'
            i_werks            = '5034'
          IMPORTING
            e_quota_exist_flag = lv_flag
          TABLES
            t_zapo_trqtap      = it_qitem
            t_zapo_trqtah      = it_qheader
          EXCEPTIONS
            invalid_input      = 1
            OTHERS             = 2.
    perform f_loadquota_apo TABLES it_qitem.
    form f_loadquota_apo tables it_qitem type zapo_trqtap.
                     LOOP AT it_qitem INTO wa_it_qitem.
                     wa_it_quotavalue-trpid = wa_it_qitem-ztrpid.
                     wa_it_quotavalue-quota = wa_it_qitem-zquota / lv_sum.
                     append wa_it_quotavalue to it_quotavalue.
                     endloop.
    endform.

    Hi..
    Using TABLES is like obselete.
    So change your code like this:
    Call the Subroutine like this:
    <b>perform f_loadquota_apo using it_qitem[].</b>
    You can change the Definition of Form like this:
    <b>form f_loadquota_apo USING  it_qitem LIKE zapo_trqtap[].</b>
    LOOP AT it_qitem INTO wa_it_qitem.
    wa_it_quotavalue-trpid = wa_it_qitem-ztrpid.
    wa_it_quotavalue-quota = wa_it_qitem-zquota / lv_sum.
    append wa_it_quotavalue to it_quotavalue.
    endloop.
    endform.
    <b>Reward if Helpful</b>

  • Ssrs 2008 r2 pass paramter value to a sort

    In a new SSRS 2008 r2 report, I am going to be using sql within a dataset and not a stored
    procedure since will I need to pass multiple values to each parameter.
    One of the parameters that I will be working with is allowing the user to be able to pick what items
    they want to sort on. The sort will have 3 items that will be always be sorted on first which are:
    year, and school_number.  The users will be able to pick additional items to sort on like grade, and teacher.
    The following is the sql that I have so far:
    select year,  school_number, grade,teacher,room,course_number, course_name
    from dbo.school
    order by  year,  school_number, several parameter values.
    Thus I am wondering if you would modify the sql above so that I can allow the user to sort on the additional parameters in any order like grade,teacher,room,course_number, course_name?
    If any part of my request is not possible, I am wondering if you would show me what is possible in the sql?

    Hi jazz_dog,
    According to your description, you want to sort the report by grade,teacher,room,course_number or course_name based on a parameter selection. If in this case, we can add an expression in sorting to achieve your requirement:
    Add a parameter named Sort with the available values below to the report:
    Label: grade                                       Value: grade
    Label: teacher                                     Value: teacher
    Label: room                                        Value: room
    Label: course_number                         Value: course_number
    Label: course_name                            Value: course_name
    Add a the expression below to the tablix Sorting:
    =switch(Parameters!Sort.Value="grade",Fields!grade.Value,Parameters!Sort.Value="teacher",Fields!teacher.Value,Parameters!Sort.Value="room",Fields!room.Value,Parameters!Sort.Value=" course_number",Fields!course_number.Value,Parameters!Sort.Value="course_name",Fields!course_name.Value)
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How to pass paramter to webservice header in mobile application

    I've adf mobile application that is built with jdeveloper 11.1.2.4 with the latest ADF mobile extension
    I've consumed  a webservice that takes Object credential , String employeeId  and return salary
    the credentials Object consist of (String username , String password) in the soap header
    i want to know how to consume this webservice and pass user name , password to the soap header as i'v used this method
    List paramNames = new ArrayList();
    paramNames.add("user_number");
    List paramsValues = new ArrayList();
    paramsValues.add("45454");
    List paramTypes = new ArrayList();
    paramTypes.add(String.class);
    try {
    result =
    (String)AdfmfJavaUtilities.invokeDataControlMethod("MYDC", null, "userInfo", paramNames,paramsValues, null);
    } catch (AdfException ae) {
    ae.printStackTrace();
    throw new AdfException("Please check your network connection", AdfException.ERROR);
    } catch (AdfInvocationException aie) {
    aie.printStackTrace();
    throw new AdfException("Please check your network connection", AdfException.ERROR);

    This is the error message appears to me
    Header Authentication Failed. Invalid Credentials.
    i want to call add to array list a parameter of type object that consist of tow string Paramters username and password and i don't know how to achieve this

  • How to pass paramter JHeadstart jsp using setCurrentRowWithKeyValue

    How i can use setCurrentRowWithKeyValue or other ADF function to pass one value to JSP / JHS page and Jheadstart give me rows matching this parameter value passed to this page
    JHS use setCurrentRowWithKey but now i need to pass a value not a rowkey
    for example an deptno to emp.jsp page
    <a href="Emp.do?event=setCurrentRowWithKeyValue&deptno=10/>FetchValues</a>
    this is possible ? there is an easy way to do this ?
    tnx                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi sandra tnx for response my question is how to be in capacity of access any JSP page on my JHS Proyect directly using programmatic links depending of some situations.
    There are some master pages that have details pages for example on simple oe schema
    Customer -> Orders Page -> Order Items
    How from Customer Page i can directly call and Order Items Page and pass parameters?
    if i use native JHS navigation functionality when i click details on Customer page JHS pass parameter and save some info on session depending of row key selected and show Orders Page
    There is a way Having a link on Customer page call a programmatic event onSaveSomeParam save param of Order Number and then call Orders Items page ?
    I also try using native search functionality of JHS
    a href="orditem.do?queryOperatorNonString=is&queryOperatorString=startsWith&event=quickSearch&eventValue=true&searchAttribute=Id&searchText=<c:out value="${orditems.Id}"/>">Order Items
    off course it send me an missing IN OUT parameter because JHS is waiting for
    Orders Page param to be set
    If u have some sample code i really appreciate
    tnx....
    Mensaje editado por:
    mr2k

  • Passing parameter into select statement by using function in discoverer

    I have created two functions in database named Period_in and Period_out and a global variable  g_period_name
    I have called Period_out function in VIEW(Select statement where condition).
    I have registered Period_in function in discoverer admin then created calculation (called Period_in(:input parameter))in discoverer plus.
    My expectation is user will enter period name and that will hit Period_in function and returns 1 and stores entered period name in g_period_name at runtime. then VIEW will executed and fetches data.
    But i am getting no data found.
    Problem is 2 functions running at the same time in select statement. Please help me to overcome this. Thanks in advance
    FUNCTION period_in (p_period VARCHAR2)
          RETURN NUMBER
       AS
       BEGIN
          g_period_name := p_period;
          RETURN 1;
       END period_in;
       FUNCTION period_out
          RETURN VARCHAR2
       AS
       BEGIN
          RETURN g_period_name;
       END period_out;

    You can use this code: 
    WITH cte
    AS ( SELECT EmpID ,
    EmpName ,
    [dbo].[udf_testFunction](EmpID) AS testfunctionvalue
    FROM #Temp
    SELECT EmpID ,
    EmpName ,
    testfunctionvalue ,
    testfunctionvalue * EmpID ,
    testfunctionvalue + 2
    FROM cte
    But using scalar functions in select clause can hurt the performance. Please see this link: 
    SQL Server Scalar User Defined Function Performance
    T-SQL Articles
    T-SQL e-book by TechNet Wiki Community
    T-SQL blog

  • Using passed values in SQL statements

    Using Adobe Livecycle Designer 7, we wish to populate a pdf document with values from a MS SQL database. The values will change depending on the ID of the record called for.
    We can already populate the form using SQL (SELECT firstname FROM names WHERE id = 1), but we need to populate it based on a 'passed' value in a url (http://www.mysite.com/mypdf.pdf?id=1).
    When we try to include this into the SQL (SELECT firstname FROM names WHERE id = request.id) we get an error. Could anyone provide us with the correct syntax that will allow us to populate the form based on the ID passed in a URL?
    Many Thanks
    Craig

    Hi all of you,
    I do have a problem with coding correctly a form I am designing sing the Adobe Livecycle . In one of the field, there is an underlying field that when you exit the first name field or the Middle Initial field or the last name, it should all pass the respective values to the underlying field which becomes visible on printout. I do have this code I wrote on the exit event, but do not understand why it it not working. Please, can anyone tell me why it is not working or help me out on a better way of making it work.
    xfa.host.messageBox("Check this");
    if (EMPFNAME.rawValue <> " " ){
    xfa.host.messageBox("EMPFNAME");
    EMPNAME.rawValue = String(EMPFNAME.rawValue) + " ";
    if (EMPFNAME.rawValue <> " " )&&(EMPMI.rawValue <> " "){
    EMPNAME.rawValue = String(EMPFNAME.rawValue) + " " + String(EMPMI.rawValue) + ".";
    var s = EMPMI.rawValue;
    EMPMI.rawValue = s.toUpperCase();
    if (EMPFNAME.rawValue <> " " )&&(EMPMI.rawValue <> " ")&&(EMPLNAME.rawValue <> " "){
    EMPNAME.rawValue = String(EMPFNAME.rawValue) + " " + String(EMPMI.rawValue) + "." + " " + String(EMPLNAME.rawValue);
    var s = EMPMI.rawValue;
    EMPMI.rawValue = s.toUpperCase();
    Thanks
    Lucky P

Maybe you are looking for

  • Can't get emails on my ipad

    Very strange ... One day, out of the blue, my ipad stopped receiving emails in one of the three accounts that I have configured in it. Nothing had changed.  It just said that either the user name or password were wrong. I chanted my password, I updat

  • Purchase the order, sign out-in, still cannot make...

    purchased this order (****************693) on April 27, tried to sing out and in several times on May 3. even changed the password, but still cannot make calls, land and mobile. any suggestions?

  • Format crashes in WIndows installation

    When I try to install XP Pro SP2, after unplugging everything but the keyboard and mouse from the iMac I can get to the installer screen. When I get the option to format the disk, I try to use the slow NTFS format, but when it tries to format it will

  • The iPhone software update server could not me contacted.

    Hello, im using an iPhone 3GS , current version is 4.3.5. I get this error when i click Check for Updates. The iPhone software update server could not me contacted. Make sure your netword settings are correct and your netword connection is active, or

  • Enterprise Manager Login fails!

    We just installed Oracle 8i under NT 4.0 (sp 6) and the Enterprise Manager Client on a different NT Workstation. Enterprise Manager will not let us log in. We use the default sysmgr/oem_temp and we get invalid userid/password message. We also install