SQL command to feed a dynamic param

I have created a sql statement :-
SELECT "SRMHOST"."HOSTNAME"
FROM   "EMCSTS"."SRMAGENTCOMPONENT" "SRMAGENTCOMPONENT" INNER JOIN "EMCSTS"."SRMHOST" "SRMHOST" ON "SRMAGENTCOMPONENT"."HOSTKEY"="SRMHOST"."HOSTKEY"
WHERE  "SRMAGENTCOMPONENT"."AGENTDESC" LIKE 'Host%' AND "SRMAGENTCOMPONENT"."COMPSTATUS"='inactive' AND "SRMAGENTCOMPONENT"."COMPVERSION" LIKE '6.1%'
It just displays host names, which match the "where".
I want to use the output from this command to feed a dynamic param. I am able to create the param, and set it to record selection, but i get presented with the list of "hostnames", and have to make a selection(s).
I want the output from the sql command to just feed the dynamic param without any interaction from myself. I do not see a setting to do this.

>
John E Fleming wrote:
> Thanks Debi, could not see the wood for the trees !
> ?
Been there and done that before  : )
>
John E Fleming wrote:
> The report works fine, but takes a long time, about 2 mins.
>
> If i link command.hostname to srmhost.hostname in db expert, it is even slower.  Any ideas ?
> ?
I my short experience with SQL, I learned that linking from the crystal reports database expert to a command field is very slow indeed, and short of doing your whole select statement SQL. I do not know anyway around it.
Edited by: DebiHerbert on Dec 14, 2010 2:00 PM

Similar Messages

  • Dynamic SQL Command Queries Using Parameters

    Post Author: tdoman
    CA Forum: Data Connectivity and SQL
    I'm using Crystal Reports 11 and am trying to dynamically build part of the "Where" clause in the SQL command query to filter data on the server before the results are sent to the client. I'm doing this to decrease the load time of my reports by not having to send a large set of data to the client, then filter the results on the client side.
    I want to create a parameter list that is dynamically generated from a table in a database and allows you to select mutiple values from that list. For example: I have two tables. One employee table and one employee type table. The employee table lists all employees and their related employee types (full-time, part-time, and contractor). The employee type table lists the employee types that will dynamically be loaded into the parameters list.
    Employee Table
    ID    Name       TypeID
    1     Bob          2
    2     Steve        1
    3     John         3
    4     Bill            1
    Employee Type Table
    ID   Type
    1     Full-Time
    2     Part-Time
    3     Contractor
    Assuming the user selects u2018Full-Timeu2019 and u2018Contractoru2019 from the parameter list, the SQL command query I want to generate is as follows:
    SELECT *
    FROM emp, emp_type
    WHERE emp.ID = emp_type.ID and emp.TypeID in (u20181u2019, u20183u2019)
    I tried building the following SQL command query so it would dynamically replace {?EmpType} with the IDu2019s of the types the user selected but it doesnu2019t work. Any ideas how to fix this?
    SELECT *
    FROM emp, emp_type
    WHERE emp.ID = emp_type.ID and emp.TypeID in ({?EmpType})

    Post Author: tdoman
    CA Forum: Data Connectivity and SQL
    btw...I just realized I had a typo in my "where" clause of the previous example. It should have been like so:WHERE emp.TypeID = emp_type.ID and emp.TypeID in (u20181u2019, u20183u2019)  satish_nair31:
    Instead of passing the filter condition as parameter it would be fine if you pass it by ReportViewer.SelectionFormula Property.
    The selection formula property of report viewer control will dynamically append the where condition with the SQL value. You will pass the filter condition as per the syntax of language supported by crystal reports.I believe using the ReportViewer.SelectionFormula property you are referring to is only available if I'm loading the report through a VB application. If this is true, then this option will not work for me because I'm loading the report in a browser from the Crystal Report web server and currently don't have a VB application that can load the report. If I did, then I could dynamically build the SQL string using VB then pass it to the Crystal Report on the fly.But I'm trying to figure out if it's possible to do it without loading the report using VB. Please correct me if I'm wrong on these assumptions.

  • SQL Command Dynamic Parameters

    I have several reports which run on SQL commands.  I created a number of parameters and inserted them into the Command.  When I then modify the parameters to be 'dynamic', I get 2 sets of prompts.
    I'm told this is a bug in XI.  I'm using Crystal reports 2008.  Does anybody know if there is a fix for this bug?

    Use a separate Command to pull your LoVs (make sure that it's doesn't require any parameters). There should be no need to link the LoV Command to your main data Command... Just make sure you aren't placing any of the LoV fields on the report.
    HTH,
    Jason

  • Passing table names as parameters (aka Trouble building a dynamic SQL command)

    I am attempting to develop a template for publishing some data, and would like to pass standard table names as parameters to the various queries.  What I have created generates the following error:
    Msg 137, Level 16, State 1, Procedure spPublishTrans_FlashersCaution, Line 68
    Must declare the scalar variable "@tmpTable".
    I thought I was declaring it properly ?
    Thanks.
    DECLARE @FeatureClass as Nvarchar(MAX) = 'Trans_FlashersCaution'
    DECLARE @ED as Nvarchar(MAX) = 'edgis.dbo.' + @FeatureClass
    DECLARE @tmpTable TABLE
    [OBJECTID] [int] NOT NULL,
    [Id] [int] NULL,
    [Location] [nvarchar](60) NULL,
    [Zone] [nvarchar](5) NULL,
    [Shape] [geometry] NULL
    DECLARE @tmpTableParam AS NVARCHAR (MAX) = @tmpTable
    SELECT @tmpTableParam
    DECLARE @execquery AS NVARCHAR(MAX)
    SET @execquery = 'INSERT INTO' + @tmpTableParam +
    [OBJECTID]
    ,[Id]
    ,[Location]
    ,[Zone]
    ,[Shape]
    SELECT
    [OBJECTID]
    ,[Id]
    ,[Location]
    ,[Zone]
    ,[Shape]
    FROM' + @ED;
    EXECUTE sp_executesql @execquery

    Always PRINT the SQL string prior to execution when developing dynamic SQL script:
    PRINT @execquery
    --EXECUTE sp_executesql @execquery
    Second step, test the printed SQL script for validity.
    Dynamic SQL: http://www.sqlusa.com/bestpractices/dynamicsql/
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

  • 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?

  • "Between NVL" - Works in SQL Command, not in APEX report region

    First, I realize I could use dynamic SQL (model 4), but I don't want to (too hard just yet).
    I have a select statement with a series of Where conditions that employ values, in bind variables, supplied by the user.
    I want the choice of parameters to be optional, so I am checking for and replacing nulls.
    Select emp_name from employee_table where
    emp_rating between nvl(:p7_rating_choice, 0) and nvl(:p7_rating_choice, 99)
    and
    emp_language_no between nvl(:p7_lang_choice, 0) and nvl(:p7_lang_choice, 99);
    (the binds should be numeric).
    The actual statement is quite a bit longer, but the point is that the BETWEEN NVL(:x, min) AND NVL(:x, max) piece does not seem to work when used in a report region.
    It works fine if ALL parameters are provided, but returns an error if one or more are null.
    In the SQL command window it works (with a pop-up) just fine.
    By the way, the :p7_lang_choice bind variable is chosen from a LOV list which works in all other cases.
    Also, if I disable nulls (choosing "no" in ITEM page), everything works fine. It seems that the substitution of the min and max values via the NVL returns the wrong data type.
    Any ideas what I have done wrong?

    Thanks Scott.
    Every day brings a little more understanding!
    I also noticed a simplified method in the APEX documentation (although there was no explanation of the code) as follows:
    Where
    (column = :p1_user_input_1 OR :p1_user_input_1 = [null substitution value])
    AND
    (column = :p1_user_input_2 OR :p1_user_input_2 = [null substitution value])
    AND
    etc...
    Using the value you provide in the LOV section for the null, the second part of the OR handles the null situation.
    For some reason I was so tied up with comparing to the column that I never thought to have an OR with a compare to something else.
    Oh well.
    Thanks,
    Norm

  • Executing a SQL Command in my bean class

    Hello everyone,
    I'm using JDeveloper 12.1.2.0.0.
    I have an interest in executing a query in my bean method. I've done some research and i still got a code but it can't find the method that the method requires so i tried to added the query in my AppModule and i've added my method as a data control but how can i access it and modify it in my bean method?
    The page with the code that doesn't find the method: http://jjzheng.blogspot.pt/2010/11/run-single-query-in-application-module.html
    Which gives me: "Method 'getDBTransaction' not found"
    The page that creates my method as a data control: http://amit-adf-work.blogspot.pt/2013/09/how-to-execute-sql-using-adf-application.html
    Is any of this the right way? How can i execute a SQL Command in my bean class?
    Regards,
    Frederico.

    This is the code I use
    // GET A METHOD FROM PAGEDEF AND EXECUTE IT
    // get the binding containe
    BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
    // get an Action or MethodAction
    OperationBinding method = bindings.getOperationBinding("YourMethodAction");
    // if there are parameters to set...
    Map paramsMap = method.getParamsMap();
    paramsMap.put("param","value")  ;    
    // execute the method
    method.execute();
    List errors = method.getErrors();
    if (!errors.isEmpty())
       // handle errors here errors is a list of exceptions!
    // no error resume normal work
    Timo

  • 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

  • JDBC: send batch of SQL commands as anonymous PL/SQL block

    Hi All,
    I did a little measurement to see if I can improve jdbc
    applications by batching dissimilar SQL commands into one
    anonymous PL/SQL block and execute it once. To my surprise, for
    a batch of 5 SQL commands, it take 60% more time than execute
    each of the 5 SQL commands separately.
    The same JDBC code, using similar SQL text batching, running
    against Sybase or MSSQL shows 60%-300% improvement.
    Is there any other way to batch dynamic dissimilar SQL commands
    in Oracle other than using anonymous PL/SQL block? Here is an
    example of how the "text-batching" PL/SQL block looks like:
    "begin insert into testtab1(col1, col2) values(1, 'row1');
    insert into testtab2(col1, col2) values(100, 1);....; end;"
    Thanks,
    Nam Nguyen
    null

    If you do:
    declare
    l_sql varchar2(32767);
    l_value varchar2(32767);
    begin
    select query_sql into l_sql from lov where lov_id = 100;
    dbms_output.put_line(l_sql);
    end;
    You'll see something like that:
    SELECT
    l.DESCRIPTION || decode(l2.DESCRIPTION,null,'',l2.description, '-' || l2.description) || decode(a.DT,'Y',' - Distributed Training','N',null,null) as value1
    FROM ACTIVITY a
    ,MOUNTAINEERING m
    ,LOV l
    ,LOV l2
    WHERE a.JSATFA_ID = 82
    AND a.SPECIFIC_ACTIVITY_LOV_ID = l.LOV_ID
    AND m.ACTIVITY_ID(+) = a.ACTIVITY_ID
    AND m.CLASSIFICATION_LOV_ID = l2.LOV_ID(+);
    you need to duplicate the '
    you can do many things like:
    CTH@> select * from sqls;
    C
    select first_name || ' ' || last_name as value1 from employees where rownum=1
    1 fila seleccionada.
    CTH@>
    CTH@> ;
    1 declare
    2 l_sql varchar2(32767);
    3 l_value varchar2(32767);
    4 type generic_cursor is ref cursor;
    5
    6 c generic_cursor;
    7
    8 begin
    9 select replace(c, ''', ''''') into l_sql from sqls;
    10
    11 execute immediate l_sql into l_value;
    12 dbms_output.put_line(l_value);
    13* end;
    CTH@> /
    Ellen Abel
    Procedimiento PL/SQL terminado correctamente.
    CTH@>

  • Sql commands in cmd file

    I have been forced to write some simple scripts for Windows users who use Oracle. I used to write in bash/ksh and have no experience at all about windows scripts. What I figured out is :
    cmd file:
    echo off
    set script_dir= .
    set log=%script_dir%\log\db.log
    set scrsql=%script_dir%\db.sql
    sqlplus /nolog @%scrsql% >> %log%
    so my questions are :
    - I would like to have all commands ( batch and sql) visible inside cmd file. Is it any way to put sql commands line by line into cmd file ?
    - how to redirect output of sql command ( for example simple select ) to screen or file
    - how to put external parameter into sql command ( for example select xx from yy where zz=@param)
    KP>

    well, I do not see too much responses for my question - maybe it was not clear enough ?
    Let me write it in this way:
    I have a short ksh script:
    +#!/usr/bin/ksh+
    LOG_DIR=$ORACLE_HOME/dba/scripts/log
    LOG=$LOG_DIR/log.txt
    VAR=$2
    export ORACLE_SID=$1
    sqlplus -s '/as sysdba' << ! >> $LOG                  <<  call sqlplus commands inside a script
    whenever sqlerror exit failure;
    select * from table where columnsvalue= $VAR;          <<  use variable in sql query
    +!+
    How to convert, in most easy way, such a script to windows batch. If I get an answer it solves almost all problems I have.

  • Is there a way to execute the SQL command in PLSQL block

    Hi all
    With reference to the above subject do you have any example.
    Thanks in advance.

    What sort of SQL command do you have in mind? DML can easily be wrapped in PL/SQL blocks. DDL requires the use of dynamic SQL such as EXECUTE IMMEDIATE.
    Cheers, APC

  • Member acces profile error(A table name, specified in an sql command)

    Hi friends,
    In my bpc application(A) below 3 dims are secure dims.
    1. entiiy  (std)
    2. category (std)
    3. location (custom dim)
    while defining one member access profile,
    Read Only      : CATEGORY 100
    Read & Write      : CATEGORY 200,500
    for whatever combinatio i use, for other secure dims (eg: category,location where base member,or parent members ) i'm getting below error  message
    A table name, specified in an sql command, is unknown.
    We are on bpc75nw sp04.
    Pls suggest us .
    dump(st22):
    Short text
        A table name, specified in an SQL command, is unknown.
    What happened?
        Error in the ABAP Application Program
        The current ABAP program "CL_UJE_MEMACCESS_CACHE========CP" had to be
         terminated because it has
        come across a statement that unfortunately cannot be executed.
    Error analysis
        An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_SY_DYNAMIC_OSQL_SEMANTICS', was
         not caught in
        procedure "REMOVE_MEMACCESS" "(METHOD)", nor was it propagated by a RAISING
         clause.
        Since the caller of the procedure could not have anticipated that the
        exception would occur, the current program is terminated.
        The reason for the exception is:
        An invalid table name "/1CPMB/RDWCSUMAS" was specified in an Open SQL command:
        Due to one of the following reasons, the error occurs only at runtime:
        - the table name was specified dynamically, or
        - the SELECT clause, WHERE clause, GROUP-BY clause, HAVING clause, or
          ORDER-BY clause was specified dynamically.
    Thanks,
    naresh
    Edited by: Naresh P on Feb 19, 2011 10:40 AM

    Hi Naresh,
    As far as I know You have specify Explicit Access to all the dimensions mentioned as Secured in your Application.
    You can't skip the secured Dimesions.
    In your case if you want to restrict only one dimension for 1 Member Access Profile then give Read & Write access to other 2 Dimensions and select ALL members.
    This might solve your problem.
    Hope it helps.
    Chaithanya

  • Issuing SQL command through  Forms

    Hi
    How we can issue SQL command e.g. CREATE USER, through Forms.
    Regards!

    Issues dynamic SQL statements at runtime, including server-side PL/SQL and DDL.
    Note All DDL operations issues an implicit Commit
    Syntax
    Function FORMS_DDL(statement VARCHAR2);
    If you use FORMS_DDL to executed a valid PL/SQL Block:
    If you user FORM_DDL to executed a single DML or DDL stmt :
    Omit the trailing semicolon to avoid an invalid character error
    Thanks

  • Mixing SQL Command parameters and UI created parameters

    Post Author: shecter
    CA Forum: Data Connectivity and SQL
    I'm using Crystal Reports XI.  I've created a report with an SQL Command - no other tables or views. I want to allow my users to be able to choose data from a dynamic parameter and have the SQL read that and spit out the results. I was able to add a parameter to the SQL using the Parameter column in the Command window. This allows my user to type in a parameter. However, when I run the report after creating a parameter using the UI (i.e. Field Explorer/Parameters/right clicking and selecting "new" and then adding the parameter to a field using the selection wizard), i first get a screen that shows me the parameter that I created in the SQL Command window, then I get a screen that shows me the UI created parameters. How can I make it show only one screen with all the parameters?  -Marc 

    Post Author: jenxia
    CA Forum: General
    SQL Command is :
    SELECT UNIQUE ContactID,  incomingAddress,applicationid,
    MediaStatus, MediaDirection, EndDateTime, StartDateTime
    FROM MMCAContactMediaViewwhere EndDateTime>= {?1-reportstarttime}  and  EndDateTime <= {?2-reportendtime}
    Order by ContactID
    Select formula using dynamic prompts as
    {Command.contactid} = {?ContactID} and{Command.applicationid} = {?ApplicationID} and{Command.incomingaddress} = {?IncomingAddress}

  • Possible to change the datasource from a business-view to a Sql Command ?

    Hello,
    When a business view contains a lot of elements it takes a while just to open the report.
    We'd like to keep the BV as the dictionnary, but,
    once the report design completed,
    we'd like to disconnect the business view and replace it by the Sql command which can be seen in the menu option 'show SQL query'.
    Is it possible via the RAS sdk ?
    Did somebody experience this ?
    How to proceed ?
    Thanks a lot
    Alain

    Hi Ted,
    I'm thinking opening a Case for this problem of opening reports based on a big BV.
    We can't really reduce the BV, since it is the dictionnary and we need the whole thing...
    I'm wondering why it is impossible to change the Datasource if the tables and fields underneath are identical.
    Is it impossible to change the fields' mapping ?
    The other solution, as you suggest, is to create a report from scratch, create a new Datasource with the Sql command format, and rebuild the report... I agree it looks like a big job...
    Do you know if it is possible to export the report in XML for instance, change the XML, and then re-import ?
    Thanks for your Help.
    Alain

Maybe you are looking for

  • Macbook pro mid 2012 backing up from disk ulitiy asking for "login" keychain?

    I bought a "WD My passport For Mac 1TB" portable external hard drive since I can't get into my macbook pro mid 2012 10.9 because when I turn it on its just grey screen with apple logo and spinning wheel. I went to future shop to the geek squad and th

  • SAP Best Practice Baseline upgrade.

    Dear All, Im quite confuse here. I install SAP BP Baseline v1.603 (Malaysia) using system copy. Everything working find and now i try to upgrade it to SAP ERP 6.0 EHP4..May i know is it possible to upgrade to EHP4 for this best practices because i ca

  • N80 PC Suite wont backup phone (connection lost)

    After i received my phone and played with it a bit i installed the Nokia PC Suite and made a backup successfully Now after a couple of weeks use i thought it would be a good idea to make an up-to-date backup of the phone, however now when i try and b

  • Viewing Attachments in emails

    How can I view an attachment in an email without downloading it first? Bruce

  • Can´t open the program

    HI, i can´t open the program, is says that i have to uninstall and install again, I made it 3 times...It says "error 16" .. what´s the problem???? Thanks! Monica