Can't pass a parameter to an SQL Query

I've looked for about an hour or more now on the web, java.sun.com, but can't find what I need:
I have a page called display.jsp, and I call it from the browser
http://localhost/display.jsp?libnum=1
In the page I have the following code:
<sql:query var="profileQuery" dataSource="${profileDS}">
SELECT * FROM singles.profile where libnum=?
<sql:param value="${libnum}"/>
</sql:query>
However, the database sees the query as
" SELECT * FROM singles.profile where libnum=null"
So, my question is how do I make this line work ? :
" <sql:param value="${libnum}"/> "
can you help ?
thanks !
Dennis

Dude .....
Here's my code now -- solved it... phew..
Just to think of it ... what a difference between "libnum" and "param.libnum". That was like 3-4, if not 5 hour difference for me.
<sql:query var="profileQuery" dataSource="${profileDS}">
SELECT * FROM singles.profile where libnum=?
<sql:param value="${param.libnum}"/>
</sql:query>
Dennis

Similar Messages

  • Passing user parameter into your sql query

    I've created two user parameters...'Order_date_from' and 'Order_date_to'
    I've written a simple query to list the total order amount, order number, party name and ordered date
    Select sum ((unit_selling_price)*(ordered_quantity)), count(line_number), oe_order_headers_all.order_number, hz_parties.party_name, oe_order_headers_all.ordered_date
    from oe_order_lines_all,
    oe_order_headers_all,
    hz_parties,
    hz_cust_accounts
    where oe_order_lines_all.header_id=oe_order_headers_all.header_id
    and oe_order_headers_all.sold_to_org_id = hz_cust_accounts.cust_account_id
    and hz_cust_accounts.party_id = hz_parties.party_id
    group by order_number, party_name, ordered_date;
    I want to know how I can pass the value for the above mentioned parameters into my sql query so that it reflects as the 'ordered_date' in the report and only shows the data for the dates that the user inputs.
    Any feedback would be appreciated. Thanks.

    I want to know how I can pass the value for the above
    mentioned parameters into my sql query so that it
    reflects as the 'ordered_date' in the report and only
    shows the data for the dates that the user inputs.
    Any feedback would be appreciated. Thanks.And how does the "user" input these dates?

  • How do I Pass a parameter to a SQL Component Task where the source SQL statement is also a variable

    Hi,
    I have been tasked with making a complex package more generic.
    To achieve this I need to pass a parameter to a SQL Component Task where the source SQL statement is also a variable.
    So to help articulate my question further I have create a package and database as follows; -
    USE [KWPlay]
    GO
    /****** Object: Table [dbo].[tblTest] Script Date: 05/14/2014 17:08:02 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[tblTest](
    [ID] [bigint] IDENTITY(1,1) NOT NULL,
    [Description] [nvarchar](50) NULL,
    CONSTRAINT [PK_tblTest] PRIMARY KEY CLUSTERED
    [ID] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    I populated this table with a single record.
    I unit tested the SQL within SSMS as follows;
    SELECT * FROM dbo.tblTest
    Result; -
    ID           
    Description
    1             
    Happy
    DECLARE @myParam NVARCHAR(100)
    SET @myParam = 'Sad'
    UPDATE dbo.tblTest SET [Description] = @myParam FROM dbo.tblTest WHERE ID = 1
    SELECT * FROM dbo.tblTest
    Result; -
    ID   
    Description
    1    
    Sad
    Within the package I created two variables as follows; -
    Name: strSQL
    Scope: Package
    Data Type: String
    Value: UPDATE dbo.tblTest SET [Description] = @myParam FROM dbo.tblTest WHERE ID = 1
    Name: strStatus
    Scope: Package
    Data Type: String
    Value: Happy
    I then created a single ‘Execute SQL Task’ component within the control flow as follows; -
    However when I run the above package I get the following error; -
    SSIS package "Package.dtsx" starting.
    Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the query "UPDATE dbo.tblTest SET [Description] = @myParam FR..." failed with the following error:
    "Parameter name is unrecognized.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
    Task failed: Execute SQL Task
    Warning: 0x80019002 at Package: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. 
    The Execution method succeeded, but the number of errors raised (1) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the
    errors.
    SSIS package "Package.dtsx" finished: Failure.
    I also tried; - 
    Name: strSQL
    Scope: Package
    Data Type: String
    Value: UPDATE dbo.tblTest SET [Description] = ? FROM dbo.tblTest WHERE ID = 1
    However I received the error; - 
    SSIS package "Package.dtsx" starting.
    Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the query "UPDATE dbo.tblTest SET [Description] = ? FROM dbo...." failed with the following error: "Parameter name is unrecognized.". Possible failure reasons: Problems with
    the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
    Task failed: Execute SQL Task
    Warning: 0x80019002 at Package: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED.  The Execution method succeeded, but the number of errors raised (1) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches
    the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
    SSIS package "Package.dtsx" finished: Failure.
    Kind Regards,
    Kieran.
    Kieran Patrick Wood http://www.innovativebusinessintelligence.com http://uk.linkedin.com/in/kieranpatrickwood http://kieranwood.wordpress.com/

    Tried; - 
    Name: strSQL
    Scope: Package
    Data Type: String
    Value: UPDATE dbo.tblTest SET [Description] = ? FROM dbo.tblTest WHERE ID = 1
    and; - 
    Result; - 
    SSIS package "Package.dtsx" starting.
    SSIS package "Package.dtsx" finished: Success.
    Therefore the answer was to put the parameter number rather than the parameter name under the parameter mapping tab-> parameter name column. 
    Kieran Patrick Wood http://www.innovativebusinessintelligence.com http://uk.linkedin.com/in/kieranpatrickwood http://kieranwood.wordpress.com/

  • How can i pass a parameter to the query to filter the result of this lookup

    Hello,
    i'm developping a web application with JDeveloper 10.1.2 and JHeadStart.
    i realy need to know how can i filter the lookup (LOV) query result.
    in other word, when i click on the lookup, it show all the row that exist in may data base table.
    what i want is how can i pass a parameter to the query to filter the result of this lookup ?
    Thank you

    Hi,
    have a look if this helps
    http://oracle.com/technology/products/jdev/tips/fnimphius/restrictlovlist/restrictlov.html
    Frank

  • Passing  Time Parameter to a SQL Script

    I am trying to create an SSIS package that will extract data from a non BPC database  to load into BPC. I am calling the package from DM prompting for the time parameter.  However,   I am having problems passing the parameter to the SQL script.  I am using OLEDB Data source task using the SQL command - Using the following scrip where the '?'' is the prompt for the BPC time parameter.  Any suggestions on how to resolve would be greatly appreciated.
    SELECT
             CASE
                      WHEN LEN(GLAccountNumber)=10
                      THEN LEFT(GLAccountNumber,6)
                      ELSE GLAccountNumber
             END                                                   AS ACCOUNT     ,
             'F_CLO'                                               AS ACCTDETAIL  ,
             'ACTUAL'                                              AS CATEGORY    ,
             RTRIM(CompanyCode)                             AS COMPANY     ,
             RTRIM(CompanyDepartment)                              AS COSTCENTER  ,
             'FM'                                                  AS DATASRC     ,
             'NON_INTERCO'                                         AS INTERCO     ,
             'NOMAT'                                               AS MATERIALS   ,
             'NOPC'                                                AS PROFITCTR   ,
             'LC'                                                  AS RPTCURRENCY ,
             CAST(YearNumber AS CHAR(4)) + '.' + MonthAbbreviation AS [TIME]      ,
             SUM(TransactionAmount)                                AS SIGNEDDAA
    FROM     dbo.GLTransactionDimension a WITH (nolock)
             JOIN dbo.GLTransactionFacts b WITH (nolock)
             ON       a.GLTransactionDimensionKey = b.GLTransactionDimensionKey
             JOIN dbo.DateDimension c WITH (nolock)
             ON       b.EntryDateDimensionKey = c.DateDimensionKey
    WHERE    EntryDateDimensionKey         LIKE
              CASE
                      WHEN RIGHT(?,3)='APR' THEN '200904%'
                      WHEN RIGHT(?,3)='MAY' THEN '200905%'
               END
             AND      RowType = 'T'
    GROUP BY CompanyCode ,
             DepartmentCode     ,
             CompanyDepartment  ,
             GLAccountNumber    ,
             YearNumber         ,
             MonthAbbreviation
    ORDER BY CompanyCode ,
             DepartmentCode     ,
             GLAccountNumber    ,
             YearNumber         ,
             MonthAbbreviation

    Hi Steven,
    Use SQL task without parameter
    Into DM package into Modify script Build a variable where you will build the entire sql string and of course you will be able to pass also the variable.
    After that you will call into Modify scrip something like:
    TASK( Yourtask, SQL, "the entire SQL with parameter")
    Regards
    Sorin

  • How can i pass the  parameter for strored procedure from java

    dear all,
    I am very new for stored procedure
    1. I want to write the strored procedure for insert.
    2. How can i pass the parameter for that procedure from java.
    if any material available in internet create procedure and call procedure from java , and passing parameter to procedure from java

    Hi Ram,
    To call the callable statement use the below sample.
    stmt = conn.prepareCall("{call <procedure name>(?,?)}");
    stmt.setString(1,value);//Input parameter
    stmt.registerOutParameter(2,Types.BIGINT);//Output parameter
    stmt.execute();
    seq = (int)stmt.getLong(2);//Getting the result from the procedure.

  • Passing an argument in the SQL Query of a View Object

    Hi,
    It is possible that this question has been asked before, however I have searched for a half an hour in the forums and couldn't find a solution.
    I am also new to using JDeveloper and ADF. Here's the situation:
    I am developing an application that doesn't have to do anything else then displaying data from a database. Pretty straightforward actually.
    Now I have made a vew pages with several collapsible panels (af:showDetailHeader) and have setup the datasources (or so I thought).
    All that remains is:
    - drag & drop a view object, from the application module that I created, onto the collabsible panels, so a child element gets created which displays data from the database.
    - hack the layout so it looks like I want it to.
    The problem that I have is the following:
    I am using a 'User'-class that contains values I need when quering the database.
    That User-object is part of a user-session.
    What I want, for example, is to use the 'getPersonId()' function of that User-object and pass the argument to a SQL-query of a certain view-object.
    The query would become something like:
    'SELECT * FROM people WHERE people.personId = :someNumber'.
    Now I've read some stuff about variable binding, which is complemented by something like (backing bean code):
    getDBTransaction().getRootApplicationModule().getACertainViewObject().setWhereClauseParameter(1, user.getPersonId());
    The examples I have found that might match my wishes are not using business components, but EJB's. I am having difficulty with understanding the 'how'-part of variable binding.
    Also, I do not know enough of ADF to be able to create a situation like:
    'User loads page, collapsible panel 1 is fully shown, the others are undisclosed.'
    (meaning, that for panel1 a query has been executed.)
    'User clicks on collapsible panel 2 which triggers a backingbean that somehow retrieves data from a view object'.
    I would appreciate any help that somebody can give.
    If it is not too much of a problem, please provide code snippets in case you have a solution. I am new to ADF :(.
    -edit
    I am using JDeveloper 10.1.3.3.0 in case that is of any importance.
    Message was edited by:
    Hugo Boog

    Hello Stijn,
    I didn't think about a referenced bean rule in the faces-config.
    I added it right away and I am now able to set parameters of a View-object, not using a page button and before the page loads. You made my day!
    In case anyone ever reads this post again, the summary of how to generate a table based on a View-object using dynamic parameters.:
    1a: Go to faces-config.xml -> Overview tab'
    1b: Go to the menuitem "Referenced Beans"
    1c: Click on 'new' and select the existing bean you want to access data from and input a name. In this example I use name="user"
    2: Create a View-object using the wizard.
    2a: Specify the query you want in the menuitem 'SQL Statement'.
    Add the 'parameters' you want to. You will have something like:
    "SELECT * FROM someTable WHERE table.columnname LIKE :someArgument".
    - hint: if you want the result to become something like:
    "SELECT * FROM someTable WHERE table.columnname LIKE '%someArgument%'" then you have to add the '%'-characters in your code itself (read: someClass.setParameter("%" + someArgument);).
    2b: In the menuitem 'Bind Variables' you have to add the variables you are referring to in the query. If you look at the query in 2a, then you have to add a variable with name "someArgument".
    2c: Add the View-object to a Application Module (create one if nessecairy).
    3a: Open a .jsp(x) file. Drag the View-object created in step 2 from the 'Data Controls'-pane to the page.
    3b: Click on the '+' of the View-object in the 'Data Controls'-pane and open 'Operations' and drag 'ExecuteWithParams' to your page as a button.
    3c: We do not want to use a button, the action has to be executed immediatly. So In the page source remove the lines that were created after dropping 'ExecuteWithParams'.
    3d: Right-click on the page and select "Go to Page Definition".
    3e: Go to the action id that is called 'ExecuteWithParams#', where # is a number.
    Change the id to something useful.
    3f: Change the NDValue so it corresponds with the value you want.
    Example:
    <action id="getAddressData" IterBinding="AddressesView1Iterator"
    InstanceName="MyHRServiceModuleDataControl.AddressView1"
    DataControl="MyHRServiceModuleDataControl" RequiresUpdateModel="true" Action="95">
    <NamedData NDName="someArgument" NDType="java.lang.String"
    NDValue="#{user.personId}"/>
    </action>
    Note: It is possible to use the value of a Backing Bean in NDValue.
    Note 2: user is the bean I referred to in the faces-config.xml!
    3g: Under the executables item, add an 'invokeAction' to pass the parameter to the View-object before your JSP-file loads:
    <executables>
    <invokeAction Binds="getAddressData"
    id="loadAddressDataOfPersonIdInSession"
    Refresh="prepareModel"/>
    Thank Stijn Haus for this :)

  • Pass the result of a SQL Query as table_name  for another SQL Query

    Hi All,
    How to pass the result of a SQL Query as parameter to another SQL Query
    Eg: I am doing the steps below.
    1) select distinct table_name as TAB1 from all_tab_cols where table_name like 'T_%' and column_name like '%XYZ'
    2) I want to pass the table_name from step 1 above as parameter to another query "select * from TAB1"
    Thanks

    Naveen B wrote:
    Hi All,
    How to pass the result of a SQL Query as parameter to another SQL Query
    Eg: I am doing the steps below.
    1) select distinct table_name as TAB1 from all_tab_cols where table_name like 'T_%' and column_name like '%XYZ'
    2) I want to pass the table_name from step 1 above as parameter to another query "select * from TAB1"
    ThanksYou should craete PL/SQL code with cursor which will accept a parameter and call that cursor inside the first one
    But if the first sql returns only one row, you can do it with simple sql code
    select * from (select distinct table_name as TAB1 from all_tab_cols where table_name like 'T_%' and column_name like '%XYZ')- - - - - - - - - - - - - - - - - - - - -
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • How to pass a parameter into execute sql task and later use it into dataflow task?

    i am in a situation, where i have a logging table in which i have a primary key called ETL_log_ID which is an identity column and acts as a foreign key for various fact table and dimension tables which are populated using SSIS packages. Now i wanna use the
    ETL_log_ID as a parameter in the execute sql task which populates the log table and pass the same value in the data flow task which populates the facts and dimension. Can you let me know how to pass the parameter in a step by step procedure.
    Thanks,
    Nikhil
      

    Nikhil,
    You can check the following :
    http://www.programmersedge.com/post/2013/03/05/ssis-execute-sql-task-mapping-parameters-and-result-sets.aspx
    http://stackoverflow.com/questions/7610491/how-to-pass-variable-as-a-parameter-in-execute-sql-task-ssis
    Regarding the usage in Dataflow task, Can you elaborate on that a little?
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

  • How to pass a parameter into a sql expression?

    How to pass a report parameter into a sql expression?

    Hi Donald,
        The functionality of using a parameter in a function is only available in the formula editor and not in SQL Expression. Parameters cannot be passed to the SQL Expression, the main purpose of the SQL Expression is to make use of Database functions to make calculations at the database level but the current functionality of the product only allows you to use Database fields.
    There is an article that talks on SQL Expressions and can be useful http://technicalsupport.businessobjects.com/KanisaSupportSite/search.do?cmd=displayKC&docType=kc&externalId=c2016184&sliceId=&dialogID=6018612&stateId=1%200%206020316
    Regards,
    Vinay

  • Pass customer parameter to oem_exec_template.sql

    Hello
    i have created on process flow using OWB9.2.0.8. This process flow is having an external activity that calls one MS-Dos batch file for the renaming of flat files
    i am passing the SYDATE to this process flow so that the batch file receives this value and renames the files accordingly.
    i have set a parameter at START and bind that parameter with the External activity.
    When i execute this process flow using deployment manager i can see the prompt window for that parameter. Passing the parameter value is working perfectly fine.
    but how can i pass the value to this process flow when i register this process flow through OEM.
    i am passing the following parameters for scheduling thorough OEM to oem_exec_template.sql
    RUNTIME_REP WF_LOC PROCESS SAMPLE_PF “param1” “,”

    I can see the topic is raised here, but......what's the answer? ( I have the same problem )
    I have a mapping input parameter, use the oem_exec_template.sql to run the mapping, but fail to see where to enter the mapping input parameter. The documentation I read through doesn't refer to this possibility whatsoever.
    Anyone? :-)

  • Can we pass data-parameter in host

    Can we pass a data-parameter to a report using host command in the form.
    urgent please
    vishal

    Your answer is quite correct, but it is stupid behavior - how do you build backwards compatibility into a function if you have to specify the keyword 'default'?
    For example, I have an existing function that takes one parameter, but I need to alter it to take two parameters.   I work for a large bank that has a rigorous change management process, and this function resides in the data warehouse, so many
    people can use this function in their code, and I need to ensure that any changes I make are backwards compatible, and don't break any existing code that I don't know about.
    If this was a stored proc, I could call it without the optional parameter, and the default value would be applied, but a function needs me to specify the keyword 'default' or to provide a value.
    My only option seems to be to create a wrapper function that calls either the old function (if only one parameter is provided) or the new function (if both parameters are provided).   Sort of defeats the purpose of having default or optional values.

  • Can I pass a parameter to a mapping without using a process flow?

    I have to load data from multiple countries at different times. Rather than creating an individual mapping for each country, I want to create 1 mapping and pass the country code as a parameter to the mapping. I tried to use an input parameter in the mapping and add a custom parameter to the sqlplus_exec_template hoping the custom parameter would pass to the mapping input parameter but it's not working. No data loads.
    When I add a default value to the input parameter, the data loads but this isn't the solution I need. The value of the parameter will vary depending on the country so I can't use defaults. Since the mappings load automatically, I need the script to be able to pass the parameter in.
    I'm trying to avoid going through a process flow because that just seems like overkill for what I need to do. I just want to load all the data where country code = 'X'. Is this even possible?

    o.k. I tried everything to see which would be the best scenario.
    Zeppo - I can't use your solution because ".main", I believe, applies to an older version of OWB. We have 10g. I know in 3.1 ".main" applies because I still have mappings from that version. Doesn't apply to 10g.
    Sutirtha - I set the property for the prompt but it still didn't work.
    MccM - Yes, the premapping process works perfectly. Only thing is that I have to come up with so many different scenarios in the If then else logic. Giving me a migraine ...
    .... so ....
    I punked out and created a table that stores all of the load times by country code. In the joiner, I linked the table's country code to the country code in my view and only retrieved data where the table's load hour equals the sysdate hour. Now all I have to do is change an entry in the working table if I need to reschedule a load.
    It's cluggy but it works ... and I met me goal of only using 1 mapping.
    Thanks to all of you for providing your input. Much appreciated.

  • Passing parameter to a SQL query - Please help

    Hi All,
    I am new to JDBC. I have been trying to pass an external variable to an SQL Query.
    The query is
    String username1="le";
    PreparedStatement pstmt = null;
    pstmt = c.prepareStatement("select * from users where USER_NAME like '%?%'");
         pstmt.setString(1, username1);
         pstmt.executeQuery();
         ResultSet rs = pstmt.getResultSet();
    I am trying to retrieve values from the users table where the USER_NAME column value that is a String contains the supplied value username1.
    I am using the question mark (?) character to pass the value from the variable username1. I am also using the '%' substitution character which matches for any number of characters. So, the above query should retrieve rows where the USER_NAME is something like "charles","leander","Elena" etc.( that contains "le")
    I am getting the error:
    SQLException: java.sql.SQLException: ORA-01006: bind variable does not exist
    I changed the query to
    PreparedStatement pstmt = null;
    pstmt = c.prepareStatement("select * from users where USER_NAME like '% " + username1 + "%'");
         //pstmt.setString(1, username1);
         pstmt.executeQuery();
    This time , it is not giving the error and retrieving properly.
    But I want to use the original query and use the "pstmt.setString(1, username1); " . Is there any way of achieving this?
    Please help.
    Cheers,
    charles_am

    hi,
    try this...
    String username1="%le%";
    pstmt = c.prepareStatement("select * from users where USER_NAME like ?")
    pstmt.setString(1,username1);
    cheers,
    rpk

  • How can i Pass a parameter to JNLP ?

    How to pass a prarmeter from HTML or JSP or PHP to JNLP ?
    (Not JNLP to application <--- that's i knew)

    Actually, i want to pass a parameter tfrom HTML to JNLP <parameter> field and execute JNLP from HTML

Maybe you are looking for

  • Voice memos in ios 7: lengths not set at first

    Hello; I intended to write this as a question about what happened to an important voice memo that I recorded yesterday, but going through what I did yesterday leads me to believe that I actually deleted it because I thought it was empty. I just upgra

  • Short text in the PO

    HI, Is there any way to make short text uneditable in purchase order userwise? is there any setting in the spro? Thanks, Arati.

  • Help with scrolling screen

    I am writing a turn based strategy game in Java but I am unable to make a scrolling screen you can "move" your view of the game board around in. I can do every other aspect of the game myself, except for this. Examples of this on the internet are onl

  • Assign Business Area to cost center

    HI Guru's i would like to assign the business area to existing cost center, which is having some posted entries. But system throws the below error message "For change Business area is not possible (transaction data already exists)" Pls help me Rgds,

  • I cannot open dreamweaver CS4

    I cant open the program on my laptop, which is windows vista, I have no probs of opening the same prog on my new PC which is also windows vista (I also have no probs with my old PC which is windows xp).