Pass Parameter to IN Operator in SQL Command in OLEDB source

Hi,
I am trying to pass multiple values as one parameter. Eg: I need to get the employess with gender in ('M','F')
query: select eno, ename, sal, gender from emp where gender in (?)
Created a variable 'varGender' with the value - 'M','F'
And passed the parameter mapping in OLEDB Source. But this is not returning any records.
Please advise.
Thanks.

Hi Vaibhav,
Thanks for your kind reply.
I need to pass the same where condition to multiple source queries and we don't want to repeat the same condition in all queries and replace with a variable. Also the query is too big to keep it in the Variable. Please help me.
Thanks
Put the required filter values in a staging table and then use it in a join condition with all the other tables in all the other tasks.
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page

Similar Messages

  • Passing Parameter from Main report to SQL command-based subreport

    I am trying to cut down the run time of my reports and have recently figured out how to write SQL commands to limit the data by filtering prior to being pulled into the reports.  However, many of my reports rely on multiple sub reports, which can cause a dramatic 'drag' on the report.
    I am trying to filter the SQL command used in my sub report by passing the group parameter, which is selected by the user in the main report, to the sub report's SQL command.  Without this parameter, the sub report has to sort through a lot more data than it would with this parameter, making the run time extremely slow.
    Any suggestions on how I can accomplish this?
    Thanks for any help you can provide,
    Marlene Allen
    Crystal Reports Developer
    Crystal Reports Professional;
    Product Type: Full;
    Product Version 11.5

    Hi Marlene,
    I don't believe you can pass a CR parameter to a Command object.
    I suggest replacing all of the Command Objects with a Stored Procedure so all of the data filtering is done server side. DB servers are much more proficient at collecting the data and filtering than CR will ever be. It will also allow you to replace subreports to also speed up your report processing. All depends on your layout of course but something to look at.
    Thank you
    Don

  • Pass a variable value to SQL Command in OLEDB Source

    Hi,
      I have the OLEdb Source where it has SQL Command as Data Access Mode. Below is the sample query that i have in that.
    DECLARE @MonthOffSet int = 24
    DECLARE @PaidDate_SK_Low datetime = dateadd(mm,MONTH(getdate())-@MonthOffSet-1,dateadd(year,datediff(year,0,dateadd(YY,0,getdate())),0))
    DECLARE @PaidDate_SK_High datetime = dateadd(dd,-1,dateadd(MM,@MonthOffSet,@PaidDate_SK_Low))
    followed by select statement which has where clause.
     Instead of hard code the value 24, i am trying to get the value from variable. I know there is a limitation to add the parameters only in where clause. Is there any work around or solution.

    But i need to use the first four lines of code in lot other packages which has different sql statement. But if i make whole query variable then i have a limitation on length 4000 char.
    DECLARE @MonthOffSet int = 24
    DECLARE @PaidDate_SK_Low
    datetime = dateadd(mm,MONTH(getdate())-@MonthOffSet-1,dateadd(year,datediff(year,0,dateadd(YY,0,getdate())),0))
    DECLARE @PaidDate_SK_High
    datetime = dateadd(dd,-1,dateadd(MM,@MonthOffSet,@PaidDate_SK_Low))
    in my select statement in where clause i am using date range between @PaidDate_SK_Low
    datetime  and @PaidDate_SK_High
    datetime 
    Any suggestions

  • How to pass a variable for a SQL query in OLEDB source?

    Hi All,
    I am new to SSIS and working on it past few days. Can anyone please help me getting through a scenario where I need to pass a variable in the SQL statement in OLEDB source connection. Please find below for the details.
    eg:
    1) I have a SQL table with the columns SerialNumber, Name, IsValid, FileName with multiple rows.
    2) I have the file Name in a variable called Variable1.
    3) I want to read the data from my SQL table filtering based on the FileName (Variable1) within a data flow task and pull that data to the destination table.
    Question: In the data flow task, added source and destination DB connection with a script component in between to perform my validations. When trying to retrieve the data from source using the variable (i.e. SQL Query with variable), I am not able to add
    the query as the SQL statement box is disabled. How to filter the data based on the variable in the source DB ?
    Any help/suggestions would be of great help.
    Thanks,
    Sri

    Just to add with Vaibhav comment .
    SQL Command  : SQL query either with SQL variable or any condition  or simple Sql statement
    Like ;
    Select * from dimcustomer
    SQL Command using Varible :
    Sometimes we design our dynamic query in variable and directly use that variable name in oledb source.
    If you Sql query needs a condition based on SSIS variable .
    you can find a Example here :
    http://www.toadworld.com/platforms/sql-server/b/weblog/archive/2013/01/17/ssis-replace-dynamic-sql-with-variables.aspx
    http://www.select-sql.com/mssql/how-to-use-a-variable-inside-sql-in-ssis-data-flow-tasks.html
    Thanks
    Please Mark This As Answer or vote for Helpful Post if this helps you to solve your question/problem. http://techequation.com

  • Pass parameter to control file in SQL LOADER

    Hi guys,
    I need your help.
    I'm currently using Linux Enterprise 3.0 and ORACLE database.
    I got many ASCII text files in a folder.
    And I want to load those text files to database during interval of time.
    For example, if in that folders contains 10 text files I'll load one by one until no file in the folder in once time.
    What i want is Firstly, i got the name of 10 files then i scan one by one pass its name to control files and start loading.
    After that I do with the second file by follow the first step until reach the 10th file.
    can anyone help?
    TIA
    lux

    Something like
    for file  in <<my_directory>>
    do
       sqlldr userid=<<my_connectstring>> data=$file control=<<my_controlfile.ctl>>
    donehttp://download-west.oracle.com/docs/cd/B10501_01/server.920/a96652/ch04.htm#1004744

  • How to pass multi-value input parameter to SQL command

    I'm having trouble following the threads related to passing multi-value parameters to a SQL command.
    I need more details on the work-around that exists for using a dummy main report to GET the input parameters and pass them to a subreport parameter that uses the input parameters in its sql command WHERE clause.
    So far the main report prompts user to enter badge numbers into a multi-value string type parameter field called badgeNumber.
    The main report getRequesters command executes the following SQL:
    SELECT requester FROM lawprod.requester WHERE lawprod.requester.requester IN  '{?badgeNumber}'
    order by requester
    The main report also contains a formula called requesterList that concatenates the input parameters and separates the values with commas:  (Join ({?badgeNumber}, ", ")  
    So if user enters badge numbers 1 and 2 and 3 the value of requesterList is 1, 2, 3
    From the main report I've used the Insert Subreport command to choose an existing report, and used the link tab to link @requesterList to ?requester; where ?requester is a multi-value parameter that is used in the subreport's SQL query as shown below:
    WHERE (lawprod.ictrans.update_date <=  {?endDate} AND
           lawprod.ictrans.update_date >= {?startDate} AND
           lawprod.ictrans.doc_type = 'IS' AND
           lawprod.ictrans.system_cd = 'RQ' AND
           lawprod.mmdist.posting_type = 'O1')
          AND
          (lawprod.ictrans.company = lawprod.mmdist.company AND 
           lawprod.ictrans.system_cd = lawprod.mmdist.system_cd AND
           lawprod.ictrans.location = lawprod.mmdist.location AND
           lawprod.ictrans.doc_type = lawprod.mmdist.doc_type AND
           lawprod.ictrans.document = lawprod.mmdist.doc_number AND
           lawprod.ictrans.shipment_nbr = lawprod.mmdist.doc_nbr_num AND
           lawprod.ictrans.line_nbr = lawprod.mmdist.line_nbr AND
           lawprod.ictrans.component_seq = lawprod.mmdist.component_seq)
          AND
          (lawprod.ictrans.company = lawprod.reqline.company AND 
           lawprod.ictrans.document = lawprod.reqline.req_number_a AND
           lawprod.ictrans.line_nbr = lawprod.reqline.line_nbr AND
           lawprod.reqline.company = lawprod.reqheader.company AND
           lawprod.reqline.req_number = lawprod.reqheader.req_number)
           AND
           (lawprod.reqheader.requester in '{?requester}')
    Following execution of the main report, Crystal appears to prompt for three values as expected: badge numbers for the main report, and start and end dates needed by the subreport.   I can't figure out why Crystal XI returns no data. Can anyone explain what I'm missing?
    Edited by: Patricia Sims on Sep 21, 2009 9:30 PM

    The reason no data is returned is that the multiple values are not (properly?) passed to the main report's SQL.  The main report's SQL should be (MS SQL):
    select 1 as dummy
    This causes exactly one record to be returned, which will basically be ignored (except the fact that it will drive the subreport; any query that returns only 1 record will suffice...).
    Change the concatenation of the selected values to be (basic syntax):
    formula = "|" + join({?badgeNumber}, "|") + "|"
    The leading and trailing vertical bars are important (otherwise a database value of 1 might match a selection of 123).
    Pass the concatenated string as the parameter value to the subreport.  In your subreport, select records on (basic syntax):
    formula = (instr({?sr-badgeParam}, "|"+cstr({requester},"0") + "|") > 0)
    (assumes is numeric in the database, and is integer; modify or eliminate cstr() if otherwise...)
    Put your subreport on the detail format of the main report, and you're all set...
    HTH,
    Carl

  • How to pass a multiple value parameter to SQL Command?

    Hi,
    I created a SQL Command with parameter.  But, I need the parameter to be set as multiple value.  After creating the SQL Command and it's parameter under the Database Expert, I went to Field Explorer --->  Parameter Fields and found the parameter that I had created for the SQL Command.  But when I wanted to edit the parameter to make it a multiple value parameter, the multiple value option was fix grayed as single parameter and I couldn't change it to multiple parameter.  Is there any way that I can set a parameter that is attached to SQL Command as multiple value rather than single value?  Thanks.
    Cheers,
    Al

    Al,
    That's a feature that, apparently, is only available in CR 2008.  If you are using CR 2008, use this link to see how to do it.
    [https://boc.sdn.sap.com/node/19268]
    Cheers,
    Jason

  • How to pass SQL command parameter using OpenDocument

    Hi !
    I have a dynamic List of values configured in Business View manager, used across multiple reports.
    The data source for this LOV is a SQL Command which accepts a static parameter named stringParam. I need to pass this static parameter in the URL using OpenDocument command. How can I do this?
    I tried
    http://bobjdev/businessobjects/enterprise115/InfoView/scripts/opendocument.aspx?spath=[ReportFolder]&sDocName=WebReport.rpt&stype=rpt&lsSstringParam=ABC
    but it still prompts me to select the parameter. I need to avoid this prompt.
    Any help, please.

    Hi,
    I would recommend to take a look at the documentation in order to identify the correct syntax for your URL
    [http://help.sap.com/businessobject/product_guides/boexir31/en/xi3-1_url_reporting_opendocument_en.pdf]
    Regards,
    Shweta

  • How to pass parameter value as "where [fieldname] = [fieldvalue]" in sql query under query type in SSRS report?

    I am having trouble with passing dynamic string to sql query for executing SSRS reports.
    I am using oracle database and I want to pass where clause parameter as "where LAND_NR = 6" to my select query.
    For example: I want to execute Select * from employee :p_where.
    where p_where parameter holds value "where LAND_NR = 6"
    So it will treat as "Select * from employee where LAND_NR = 6" statement which will give me the list of records to display in my reports.
    But it's not taking correct sql command throwing an error as "SQLcommand not properly ended."
    How can I achieve this?

    You need to use dynamic sql
    But please keep in mind that since you're using Oracle you may be better off posting this in some Oracle forums
    This forum is specifically for SQL Server
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Passing Parameter to SQL-Query

    Hello ,
    i have an SQL Query as Data Source of my Crystal Report . I d like to pass the parameter to my SQL-Query.
    Parameter ?city
    Query1
    select
    Order ID,
    City,      -- How to pass my ?city here
    Amount
    from Orders,
    thanx ..

    You can do this by using the 'Add Command' feature.
    Click Add Command -> Create your ?City Parameter -> type SQL statement:
    select
    Order ID
    where City='{?City}'
    Make sure you add single quotes around your parameter.
    Regards,
    Zack H.

  • SQL Command code for multiple value string parameter

    Hi,
    I'm using crystal 2008 and there is a check box for multiple value  SQL Command  I need some help in writing the SQL Command code  for oracle (or sql server) for a multiple value STRING  parameter.
    Thanks in advance,
    Marilyn

    I could be wrong here, but I do not believe you can pass a multiple valued parameter to an SQL Command data source.  How I have gotten around this in the past is to put the "real" report into a subreport.  In the main report, create a formula field (basic syntax):
    formula = join({?parameter}, "|")
    Then, use this to pass the selected values to the subreport's parameter (call it {?sr-parm}).  The SQL Command in the subreport can then use that (MS SQL):
    select *
    from table
    where charindex(table.field, '{?sr-parm}') > 0
    HTH,
    Carl

  • Passing Params & Formulas to SQL Command & Strd Proc in CR 11.5 & 2008 - 1

    I am working with CR 11.5 and heavily use SQL Command rewrites and Stored Procedures (SPs)with the usual limitation that only single parameter values can be passed into SPs, and Parameters must be created within the SQL Command editor (and cannot be referenced to those generated in Field Explorer, or can they?)
    I understand from BE/CR's sales material for CR 2008 that multiple values can now be used under these conditions.  As I recall, Multivalue Parameters are actually arrays that can be made into comma delimited strings.
    Local StringVar StringExpression;
    Local NumberVar ArrayCount := Count({?Code});
    Local NumberVar i;
    if ArrayCount = 0
       then StringExpression := ""
    else
       StringExpression := {?Code}[1];
       i := 2; 
    While i <= ArrayCount Do
        StringExpression := StringExpression + ", " + {?Code}<i>;
        i := i + 1;
    See part 2 for continuation....

    Here is my use case (since most of my reports are against very large databases, running "tuned" SQL Commands is essential).
    SELECT
      PERSON.PatientName,
      PROBLEM.Code,
      PROBLEM.Description
      LASTLABS.HDID,
      RPTOBS.ObsDate,
      RPTOBS.ObsValue
    FROM
      ((PERSON INNER JOIN
        PROBLEM ON
            PERSON.PId = PROBLEM.PId) LEFT OUTER JOIN
         LASTLABS ON
         (PERSON.PId = LASTLABS.PId AND
          LASTLABS.HDID IN (28, 53, 67, 102) LEFT OUTER JOIN      -- Paramaterize
        RPTOBS ON
         (LASTLABS.HDID = C.HDID AND
          LASTLABS.MaxObsDate = RPTOBS.ObsDate AND
          LASTLABS.PId = RPTOBS.PId AND
          RPTOBS.Change IN (2, 5, 7))                             -- Paramaterize
    WHERE
        (PROBLEM.Code LIKE '249%' OR                              -- Paramaterize
         PROBLEM.Code LIKE '250%' OR                              -- Paramaterize
         PROBLEM.Code IN ('V77.1', 'V80')                         -- Paramaterize
    What I am looking for is a Parameterized form as follows....
    SELECT
      PERSON.PatientName,
      PROBLEM.Code,
      PROBLEM.Description
      PROBLEM.Qualifier,
      LASTLABS.HDID,
      RPTOBS.ObsDate,
      RPTOBS.ObsValue
    FROM
      ((PERSON INNER JOIN
        PROBLEM ON
            PERSON.PId = PROBLEM.PId) LEFT OUTER JOIN
        LASTLABS ON
         (PERSON.PId = LASTLABS.PId AND
          LASTLABS.HDID ({?HDID_In_Param}) LEFT OUTER JOIN          -- Paramaterize
        RPTOBS ON
         (LASTLABS.HDID = RPTOBS.HDID AND
          LASTLABS.MaxObsDate = RPTOBS.ObsDate AND
          LASTLABS.PID = RPTOBS.PID AND
          RPTOBS.Change ({?Change_In_Param}))                       -- Paramaterize
    WHERE
        (PROBLEM.Code {?Code_Like_Param} OR                         -- Paramaterize
         PROBLEM.Code {?Code_In_Param})                             -- Paramaterize
    Is this possible? Has it been thought of yet. Has passing in well-constructed @formulas been considered?

  • Passing Parameter in SQL

    How to Passing parameter in SQL.For Example,Table name=&From_Clause.It will asking table name at runtime.How to assign table name based on user.

    Hi,
    796776 wrote:
    It will returm error.what problem in this
    Select * From Emp a,
    (SELECT CASE
    WHEN USER = :UserType
    THEN 'scott.Dept'
    ELSE 'scott.order'
    END AS b
    FROM dual)
    Where a.DeptNo= b.DeptNo &WhereClauseIt's hard to guess, from an example like this with so many errors, exactly what you're trying to do.
    Please post a description of the problem, including CREATE TABLE and INSERT statments for any tables you need (unless you can state the problem using commonly available tables, such as those in the data dictionary or the scott schema), a few values of a parameter (or examples of different user names, if USER acts like a parameter) and the results you want from the same data for each value.
    For example
    "In addition to the scott.dept table, I have a table called my_dept: CREATE TABLE my_dept ...
    which has this data: INSERT INTO my_dept ...
    I need a script such that, when user scott runs it, the results are ...
    but when any other user runs it, the results are ..
    As you can see, the difference is ..."
    Table names must be explicitly given when a SQL statement is compiled. That's why I usggested a preliminary query; so by the time you compiled the main query, the table name would be known and could be passed in a substitution variable.
    If you really want to do it in one query, you can do a UNION of two queries, one of which returns nothing because of the parameter. It's not very efficient.

  • Pass parameter to pl/sql block

    Hi,
    I am getting following error when trying to create staging table from shell script by passing parameter.
    SQL*Loader-941: Error during describe of table T1_1DAY_STG
    ORA-04043: object T1_1DAY_STG does not existThis is PL/SQL block being called inside shell script
    begin
    execute immediate 'create table t1_&1._stg as select * from t1_rpt_tmt';
    end Shell Script Call
    load_data_to_oracle()
    for i in 1DAY 7DAY 15DAY
    do
    ${ORACLE_HOME}/bin/sqlplus ${ORACLE_USER}/${ORACLE_PASSWD}@${ORACLE_SID} << EOF > ${TMP_LOG_FILE} 2>&1
    set serveroutput on
    @${CREATE_STAGE_SQL} "$i"
    COMMIT;
    QUIT;
    EOF
    ########Main#######
    load_data_to_oracleThanks
    Sandy

    It is probably a permission issue. Are you the owner of the table you are trying to select from in your PL/SQL block? if not, do you have select permission granted specifically?
    Here is my test:
    test > create table T_ABC (a number, b number);
    Table created.
    test > @t_abc Hello
    test > begin
    2
    3 execute immediate 'create table t1_&1._stg as select * from t_abc';
    4
    5 end;
    6 /
    old 3: execute immediate 'create table t1_&1._stg as select * from t_abc';
    new 3: execute immediate 'create table t1_Hello_stg as select * from t_abc';
    PL/SQL procedure successfully completed.
    test > desc t1_Hello_stg
    Name
    A
    B
    test > desc T_ABC
    Name
    A
    B
    test >

  • How to pass parameter to pl/sql block

    Hi,
    I am getting following error when trying to create staging table from shell script by passing parameter.
    SQL*Loader-941: Error during describe of table T1_1DAY_STG
    ORA-04043: object T1_1DAY_STG does not existThis is PL/SQL block being called inside shell script
    begin
    execute immediate 'create table t1_&1._stg as select * from t1_rpt_tmt';
    endShell Script Call
    load_data_to_oracle()
    for i in 1DAY 7DAY 15DAY
    do
    ${ORACLE_HOME}/bin/sqlplus ${ORACLE_USER}/${ORACLE_PASSWD}@${ORACLE_SID} << EOF > ${TMP_LOG_FILE} 2>&1
    set serveroutput on
    @${CREATE_STAGE_SQL} "$i"
    COMMIT;
    QUIT;
    EOF
    ########Main#######
    load_data_to_oraclethanks
    sandy

    i dont understand why you want run it from shell script. you can write procedure like this :
    SQL>
    SQL> CREATE OR REPLACE PROCEDURE mytestProc(p_in VARCHAR2) AS
      2  begin
      3    FOR i IN (select REGEXP_SUBSTR(p_in,'[^,]+',1,ROWNUM) tblName
      4                from dual
      5                CONNECT BY INSTR(p_in, ',', 1, level - 1) > 0)
      6    LOOP
      7      execute immediate 'create table t1_'||i.tblname||'_stg as select * from myt2';
      8    END LOOP;
      9  end;
    10  /
    Procedure createdand run it
    SQL> exec mytestProc('1day,7day,15day');
    PL/SQL procedure successfully completed
    SQL> select * from t1_15day_stg
      2  union all
      3  select * from t1_1day_stg
      4  union all
      5  select * from t1_7day_stg;
    T                  N
    SQL>
    SQL> drop table t1_15day_stg;
    Table dropped
    SQL> drop table t1_1day_stg;
    Table dropped
    SQL> drop table t1_7day_stg;
    Table dropped
    SQL> purge table t1_15day_stg;
    Done
    SQL> purge table t1_1day_stg;
    Done
    SQL> purge table t1_7day_stg;
    Done
    SQL>

Maybe you are looking for

  • White macbook boots to black screen?

    I have a 2006 white macbook with the 2.0ghz core 2 duo processor. It boots well and runs fast most of the time, but sometimes after i press the power button instead of the screen becoming white with the apple logo etc. it just stays black. the fans r

  • Ipod freezing when connecting to pc

    i just purchased a 30 gig ipod this summer, but when i plug it into my pc, the ipod lights up and freezes on the first menu...the ipod stays on this screen until the batteries drain. This has happened all but one time when plugging it in. i can't eve

  • Issue in HR Form editor.

    Hi experts, I have an issue with HR form editor  Tcode PE51. In form ZF50 the requirement is to add a certain text message when wage type is '2041' in RT table and the employee is getting ticket fare for that month. If I define a text module and crea

  • Traffic Lights For Hyperlinks panel not showing. INDESIGN.

    My traffic lights for the hyperlinks panels are not showing and I have the latest version of CC. How do I show/hide them? Thanks

  • How do it tranfere pictures from my computer to my iphone

    how do i transfere pictures from my computer to my iphone..