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?

Similar Messages

  • Passing a string into an SQL query IN statement

    Hello,
    I need to connect to a database to pull some data to dynamically create a form based on the data I pull back. My SQL query works fine when I manually run it through a SQL client tool, but when I try to pass it through my workflow I'm having trouble with passing my string into the IN part of the statement. So if for example my SQL query is:
    SELECT Field1, Field2, Field3 FROM Table1 WHERE Field4 IN (?)
    I have a process variable that has the string I'm trying to pass into the ?, but I don't seem to be able to get the query to run. I have tried setting up my query to run as a Parameterized Query (passing my string process variable into the ?), and by setting the query up through xPath (where I am calling my process variable with an xPath declaration), but am not having any luck.
    The process variable I am trying to pass is formatted such that I'm passing 'Value1','Value2','Value3' but I can reformat this string if need be. Even with using test data I can't get the query to return anything. For test data I have tried: 'Value1','Value2','Value3' ; Value1','Value2','Value3 ; Value1,Value2,Value3 but the query never returns any data. I can't seem to see how to format the string to pass into the query. The Query will work with a single Value in the test data, but as soon as I try to pass multiple values within the string it fails. Any suggestions?

    The problem looks to be a limit on what I can pass into the SQL query component. My string is coming from data returned from another database. I take the xml output from that database call, pass it through a set variable component to remove my xml tags from the string, and then format the string in a script component (I have to do it this way because of the way the data coming out of my first database call). I've put in loggers, and can see that the string I'm passing into my query that is giving me problems, is formatted the same way as if I were to use the concat function Scott listed above. It looks like there is a limitation on what can be passed in my variable. I have tried creating my entire SQL query statement in a set variable component, and then just calling the process variable that holds that statement, but there is a character limit of 128 character for what can be passed in a variable through xpath in the SQL query component.
    The next thing I tried was changing my SQL where clause. Instead of passing my variable directly into the IN statement I set up a PATINDEX('%:'+countyname+ ':%', ?) > 0 call to check for the values in my database call. As you can see I took out the "," that I was passing as part of my string, thinking that the SQL component was getting confused by them, and placed ":" characters around my values being passed in my string variable. No matter what I try to do though I'm not able to get the query to run. The component looks like it is taking my string, and is seeing the whole thing as a string instead of passing it as individual values within a string.
    I think I'm getting close, but I keep getting a Content not allowed in prolog exception in the server logs.

  • 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

  • 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 value into a SQL Query?

    Hi There,
    I want to know if there is a possibility to pass a dynamic value in a sql query. For example I have a currency rate value (ex: rate = 1.319, 2.23 etc) which user wants to input when running the query (The rate is not taken from the system, so I cannot compare to any table column and pass it as a parameter).
    And this rate has to be used in my query to do some calculation. Is this possible? The value :p_currency_rate doesn't work
    Any ideas please?
    Thank you,
    Prathibha

    SELECT DISTINCT
    hou.name
    ,poh.segment1 po_num
    ,pol.line_num po_line_num
    ,poh.currency_code
    --,trunc(poh.creation_date) po_creation_date
    ,pol.cancel_flag
    ,msi.segment1 item_num
    ,pol.unit_price
    ,round(cost.item_cost,5)
    ,round((&p_rate * pol.unit_price),5) "CONVERSION"
    ,(cost.item_cost - round((&p_rate * pol.unit_price),5)) difference
    ,pov.vendor_name
    FROM
    po.po_headers_all poh
    ,po.po_lines_all pol
    ,po.po_vendors pov
    ,hr.hr_all_organization_units hou
    ,inv.mtl_system_items_b msi
    ,bom.cst_item_costs cost
    WHERE
    poh.po_header_id = pol.po_header_id
    and pov.vendor_id = poh.vendor_id
    and poh.org_id = hou.organization_id
    and hou.organization_id = :p_operating_unit
    and poh.currency_code = :p_currency
    and poh.creation_date between :po_creation_date_from and :po_creation_date_to
    and poh.type_lookup_code = 'BLANKET'
    and msi.inventory_item_id = pol.item_id
    and cost.INVENTORY_ITEM_ID = pol.ITEM_ID
    --and (cost.item_cost - pol.unit_price) <> 0
    and (cost.item_cost - round((&p_rate * pol.unit_price),5)) <> 0
    and cost.organization_id = 1
    and msi.organization_id = 1
    and cost.cost_type_id = 3 --- Pending cost type
    and nvl(upper (pol.closed_code),'OPEN') not in('CANCELLED', 'CLOSED', 'FINALLY CLOSED', 'REJECTED')
    and nvl(upper (poh.closed_code),'OPEN') not in('CANCELLED', 'CLOSED', 'FINALLY CLOSED', 'REJECTED')
    and nvl(pol.cancel_flag, 'N') = 'N'
    and &p_rate user parameter
    I want this p_rate to be passed as a user parameter.

  • 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

  • Passing JSP value into an SQL Query

    Hi,
    I am developing a site for a cruise ship company as part of a project. My problem is as follows . . .
    I have a page called cruiseReservation.jsp which passes the value of the selected cabin to the cruiseDetails.jsp page:
    href="CruiseDetails.jsp?cabin_id=cabinE105 " so . .
    cabinE105 was selected.
    my database table for the cabin is as follows:
    create table cabin (
    cruise_id number primary key,
    cabinE105 number,
    cabinD113 number,
    cabinC131 number,
    cabinB127 number,
    cabinA101 number,
    FOREIGN KEY(cruise_id)
    REFERENCES cruisedetails(cruise_id)
    In the cruise details page im running the following code to update the cabin tables cabinE105 value to 0:
    String cabin = request.getParameter("cabin_id");
    String setCabin = "update cabin set '"+cabin+'" = 0 where cruise_id = 1";
    What im trying to do is pass the value of the cabin into the update statement so it updates cabinE105 = 0 where cruise_id = 1.
    How do I dfo this as the above method is not working ??
    I would like any help on this PLEASE !!! THANKS !

    String cabinID = request.getParameter("cabin_id");
    PreparedStatement ps=connection.prepareStatement("update cabin set "+cabinID+"=? where cruise_id=?");
    ps.setInt(1,0);
    ps.setInt(2,0);
    ps.executeUpdate();
    .Regards
    -John-

  • 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 :)

  • How can I enter the data from the recordset into your insert query

    Hi
    i would like to know how I can enter the data from the recordset into your insert query without using a  hidden field.
    thanks
    ------------------------------------------------------------------------------------Below is the code------------------------------------------------------------------------------------- -----
    <?php require_once('../../Connections/ezzyConn.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
       $theValue = function_exists("mysql_real_escape_string") ?  mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "frmpostComment")) {
       $insertSQL = sprintf("INSERT INTO comments (com_topic, com_user, title,  com_content, com_date, online_id) VALUES (%s, %s, %s, %s, %s, %s)",
                           GetSQLValueString($_POST['com_topic'], "int"),
                           GetSQLValueString($_POST['commentby'], "int"),
                           GetSQLValueString($_POST['title'], "text"),
                           GetSQLValueString($_POST['com_content'], "text"),
                           GetSQLValueString($_POST['com_date'], "text"),
                           GetSQLValueString($_POST['online_id'], "int"));
      mysql_select_db($database_ezzyConn, $ezzyConn);
      $Result1 = mysql_query($insertSQL, $ezzyConn) or die(mysql_error());
      $insertGoTo = "index.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $insertGoTo));
    $colname_rsCommentby = "-1";
    if (isset($_SESSION['MM_Username'])) {
      $colname_rsCommentby = $_SESSION['MM_Username'];
    mysql_select_db($database_ezzyConn, $ezzyConn);
    $query_rsTopics = "SELECT topic_id, topic FROM topics ORDER BY topic_date DESC";
    $rsTopics = mysql_query($query_rsTopics, $ezzyConn) or die(mysql_error());
    $row_rsTopics = mysql_fetch_assoc($rsTopics);
    $totalRows_rsTopics = mysql_num_rows($rsTopics);
    mysql_select_db($database_ezzyConn, $ezzyConn);
    $query_rsOnline = "SELECT online_id, `online` FROM `online` ORDER BY online_id DESC";
    $rsOnline = mysql_query($query_rsOnline, $ezzyConn) or die(mysql_error());
    $row_rsOnline = mysql_fetch_assoc($rsOnline);
    $totalRows_rsOnline = mysql_num_rows($rsOnline);
    $colname_rsCommentby = "-1";
    if (isset($_SESSION['MM_Username'])) {
      $colname_rsCommentby = $_SESSION['MM_Username'];
    mysql_select_db($database_ezzyConn, $ezzyConn);
    $query_rsCommentby  = sprintf("SELECT user_id, username FROM users WHERE username = %s",  GetSQLValueString($colname_rsCommentby, "text"));
    $rsCommentby = mysql_query($query_rsCommentby, $ezzyConn) or die(mysql_error());
    $row_rsCommentby = mysql_fetch_assoc($rsCommentby);
    $totalRows_rsCommentby = mysql_num_rows($rsCommentby);
    ?>
    <?php include("../includes/access.php"); ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>ezzybay - easy click, ezzy shopping</title>
    <link href="../css/global.css" rel="stylesheet" type="text/css" />
    <link href="../css/navigation.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <div id="wrapper">
      <?php include("../includes/top.php"); ?>
      <div id="content">
      <div id="pageTitle">
        <h2>CMS Section:</h2>
        <p>Comment Topics Page</p>
      </div>
      <?php include("../includes/leftnav.php"); ?>
        <div id="mainContent">
          <form action="<?php echo $editFormAction; ?>" method="post" name="frmpostComment" id="frmpostComment">
            <table align="center">
            <caption>Post Comment</caption>
              <tr valign="baseline">
                <td nowrap="nowrap" align="right">Topic:</td>
                <td><select name="com_topic" class="listbox" id="com_topic">
                  <?php
    do { 
    ?>
                   <option value="<?php echo  $row_rsTopics['topic_id']?>"><?php echo  $row_rsTopics['topic']?></option>
                  <?php
    } while ($row_rsTopics = mysql_fetch_assoc($rsTopics));
      $rows = mysql_num_rows($rsTopics);
      if($rows > 0) {
          mysql_data_seek($rsTopics, 0);
          $row_rsTopics = mysql_fetch_assoc($rsTopics);
    ?>
                </select></td>
              </tr>
              <tr valign="baseline">
                <td nowrap="nowrap" align="right">Title:</td>
                <td><input name="title" type="text" class="textfield" value="" size="32" /></td>
              </tr>
              <tr valign="baseline">
                <td nowrap="nowrap" align="right" valign="top">Comment:</td>
                <td><textarea name="com_content" cols="50" rows="5" class="textarea"></textarea></td>
              </tr>
              <tr valign="baseline">
                <td nowrap="nowrap" align="right">Status:</td>
                <td><select name="online_id" class="smalllistbox">
                  <?php
    do { 
    ?>
                   <option value="<?php echo $row_rsOnline['online_id']?>"  <?php if (!(strcmp($row_rsOnline['online_id'], 2))) {echo  "SELECTED";} ?>><?php echo  $row_rsOnline['online']?></option>
                  <?php
    } while ($row_rsOnline = mysql_fetch_assoc($rsOnline));
    ?>
                </select></td>
              </tr>
              <tr> </tr>
              <tr valign="baseline">
                <td nowrap="nowrap" align="right"> </td>
                <td><input type="submit" class="button" value="Insert record" /></td>
              </tr>
            </table>
            <input name="commentby" type="hidden" id="commentby" value="<?php echo $row_rsCommentby['user_id']; ?>" />
            <input type="hidden" name="com_date" value="<?php echo date("d/m/y : H:i:s", time()) ?>" />
            <input type="hidden" name="MM_insert" value="frmpostComment" />
          </form>
        </div>
      </div>
    <?php include("../includes/footer.php"); ?>
    </div>
    </body>
    </html>
    <?php
    mysql_free_result($rsTopics);
    mysql_free_result($rsOnline);
    mysql_free_result($rsCommentby);
    ?>

    I'll keep it simple and only use the date as an example. Hopefully you get the concept from the example. Basically you create a recordset and insert the recordset value instead of the POST value into your insert query. In the example below I declared a variable for $the_date and entered the variable into the INSERT query instead of the hidden POST field.
    <?php require_once('../../Connections/ezzyConn.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
       $theValue = function_exists("mysql_real_escape_string") ?  mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $the_date = date("d/m/y : H:i:s", time());
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "frmpostComment")) {
       $insertSQL = sprintf("INSERT INTO comments (com_topic, com_user, title,  com_content, com_date, online_id) VALUES (%s, %s, %s, %s, %s, %s)",
                           GetSQLValueString($_POST['com_topic'], "int"),
                           GetSQLValueString($_POST['commentby'], "int"),
                           GetSQLValueString($_POST['title'], "text"),
                           GetSQLValueString($_POST['com_content'], "text"),
                           GetSQLValueString($the_date, "text"),
                           GetSQLValueString($_POST['online_id'], "int"));
      mysql_select_db($database_ezzyConn, $ezzyConn);
      $Result1 = mysql_query($insertSQL, $ezzyConn) or die(mysql_error());
      $insertGoTo = "index.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $insertGoTo));
    ?>

  • 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 to Pass multiple parameter into single store procedure

    How to Pass multiple parameter into single store procedure
    like a one to many relationship.
    it is possible then reply me immediatly

    you mean like this .....
    CREATE OR REPLACE procedure display_me(in_param in varchar2,in_default in varchar2 := 'Default') is
    BEGIN
    DBMS_OUTPUT.put_line ('Values is .....'||in_param || '....'||in_default);
    END display_me;
    CREATE OR REPLACE procedure display_me_2 as
    cnt integer :=0;
    BEGIN
    For c1_rec In (SELECT empno,deptno FROM test_emp) Loop
         display_me(in_param => c1_rec.empno);
         cnt := cnt+1;
         end loop;
         DBMS_OUTPUT.put_line('Total record count is ....'||cnt);
    END display_me_2;
    SQL > exec display_me_2
    Values is .....9999....Default
    Values is .....4567....Default
    Values is .....2345....Default
    Values is .....7369....Default
    Values is .....7499....Default
    Values is .....7521....Default
    Values is .....7566....Default
    Values is .....7654....Default
    Values is .....7698....Default
    Values is .....7782....Default
    Values is .....7788....Default
    Values is .....7839....Default
    Values is .....7844....Default
    Values is .....7876....Default
    Values is .....7900....Default
    Values is .....7902....Default
    Values is .....7934....Default
    Values is .....1234....Default
    Total record count is ....18

  • 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/]

  • 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 to pass a parameter into RMAN script

    Hello,
    I have the following rman script :
    run {
    CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
    CONFIGURE CONTROLFILE AUTOBACKUP OFF;
    CONFIGURE DEVICE TYPE DISK PARALLELISM 2;
    CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT 'c:\oracle\RmanORCL102\ora_df%t_s%s_s%p';
    This script called configure.rman is launch by a .bat script with the following command:
    rman target 'sys/sys12@ORCL102 as sysdba' @c:\oracle\RmanORCL102\configure.rman
    How can I pass a parameter into rman script, I want to pass an additional directory like this:
    rman target 'sys/sys12@ORCL102 as sysdba' @c:\oracle\RmanORCL102\configure.rman v_dir_name
    And use it in rman script:
    CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT 'c:\oracle\RmanORCL102\$v_dir_name\ora_df%t_s%s_s%p';
    Is it a way to do this?
    Regards,
    Elodie

    One option would be to create a file called backup.bat with the following:
    echo run {
    echo CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
    echo CONFIGURE CONTROLFILE AUTOBACKUP OFF;
    echo CONFIGURE DEVICE TYPE DISK PARALLELISM 2;
    echo CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT 'c:\oracle\RmanORCL102\%1\ora_df%t_s%s_s%p';
    echo } ) | rman target sys/sys12@orcl102and then call the script as:
    c:\> backup.bat backup_directory_name

  • 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

Maybe you are looking for

  • CRM E-Commerce BOB Web shop - Duplicate check for New Customer Creation

    Hi, In CRM E-Commerce BOB Web shop we have a requirement wherein new customer creation should go through a duplicate check. Only unique customers should be created as BP in backend GUI, in case a customer already exists with the same credentials, BP

  • How to populate values in dropdown?

    Hi All, I have counry dropdown in my form. When the user selects any country, I want to refresh values in state dropdown by calling a BAPI. How to do this? Thanks Sundar

  • Cvm 7 meg, what's with that?

    I built cvm with the foundation profile with CVM_DEBUG=true and the resultant executable was over 7megabytes. Is this expected? I thought I could copy this file to another system and use it as the JVM, but when I ran: ./cvm -XbuildOptions I got the f

  • Export and Import of mappings/process flows etc

    Hi, We have a single repository with multiple projects for DEV/UAT and PROD of the same logical project. This is a nightmare for controlling releases to PROD and in fact we have a corrupt repository as a result I suspect. I plan to split the reposito

  • AWM 10.2.0.1 - I can not choosing Value Based hierarchy

    I have Oracle client 10.2.0.1 software with AWM 10.2.0.1 . I want to build a dimension with value-based hierarchy . In AWM I have hierarchy editor with the two radio buttons for choosing type of hierachy : Level Based hierarchy and Value Based hierar