SQL Command Object

We are in the process of migrating reports from SSRS to Crystal 2011.
In SSRS we are able to paste complex SQL into reports as the data source for the report (e.g. multiple CTE's, correlated subqueries, temp tables, etc).
It appears that we can accomplish the same thing using Crystal command objects, but the reports created have to be distributed as stand-alone rpt files to customers. In that case the reports that use sql commands return an error that the command object does not exist. It seems the command object exists in the data connection (which is generated at run-time in the host application) and not in the rpt file itself.
Is it possible to somehow use an sql query as the data source in the report in a manner that is independent of the data connection?
Thanks

Hi, 
That's interesting, the query shouldn't be stored in the data connection.  It should be saved inside the rpt as part of the SQL Query. 
How are you distributing the reports? 
How is your application connecting the reports to the database? 
As long as the reports logon to the tables and objects used in the SQL Command exist on the database it should run without a problem. 
As a test, open the report in Crystal and go to Database | Show SQL Query.  You should see your SQL Command there.  Copy and paste the SQL into your production database and see if it runs. 
Good luck,
Brian

Similar Messages

  • Problem creating a SQL command object and adding it to a Crystal report

    Hi,
    I'm trying to add the following SQL command object with the following sql for MYSQL 5.1
    SELECT lic.id, lic.productionname, comp.companyname, lic.paymentreceiveddate, lic.licenseissuedate,
    IFNULL((SELECT sum(licsong.feequoted) from licensesong licsong where licsong.licenseid = lic.id), 0) as totalfeequoted,
    IFNULL((SELECT sum(licsong.feetax) from licensesong licsong where licsong.licenseid = lic.id), 0) as totalfeetax,
    IFNULL((SELECT sum(licsong.feequoted + licsong.feetax) from licensesong licsong where licsong.licenseid = lic.id), 0) as totalfee,
    IFNULL((SELECT sum(pay.fullamount) from payment pay where pay.licenseid = lic.id),0) as totalpaid
    FROM license lic
    INNER JOIN company comp on lic.licensecompanyid= comp.id;
    This sql runs fine in the Query Browser of mysql and returns what I want.
    When I try to add this SQL command to a new Crystal Report, (by right clicking in the sql editor and selecting Crystal Reports - Add to new Crystal Report), it locks up my Eclipses and it ends up not responding. If I just do a simple SELECT * FROM license it works fine.
    The Eclipse I'm using is from the CR4E download page with the crystal plugin already installed.
    Any help with this would be greatful, as I am not having much joy with this CR4E 2.0 with MySQL and may have to scrap it and go back creating reports in Apache POI.
    Any help greatly received.
    Kind regards

    Hi,
    Try to select a particular columns instead of doing SELECT * FROM license.
    Thanks,
    Saravanakumar

  • Possible bug in SQL Commands – object required

    Hello,
    I tried to run the following in the SQL Commands:
    select * from emp
    where empno = (select MIN(empno)
                 from emp
                 where empno > :ITEM)If memory serve, it was suppose to open a pop up window, and allow me to enter a value for the bind variable. What I'm getting is a run time error about object required. Am I missing something?
    Thanks,
    Arie.

    Hi Dimitri,
    Yes, you are correct. It's strange though, because I don't remember such a behavior in the past, and also with this current browser configuration, I don't seems to have any problems with date pickers or help windows. I should probably look into it a bit deeper.
    Thanks,
    Arie.

  • Access to Previously-saved SQL in SQL Commands Window

    Hi all,
    If I've saved some SQL in the SQL Commands window, shouldn't that be available to other developers when they click on the Saved SQL tab? I saved a sample query and one of my other developers doesn't see it. I don't see any setting available in the developer account that controls whether or not the account can see others' saved SQL.
    If this isn't allowed, then I don't really see the point of the Owner drop-down in the Saved SQL tab.
    Any advice?
    Thanks!!
    John

    Hi Sc0tt,
    I think you may be referring to the Schema drop-down that appears in the upper-right area in SQL Commands, Object Browser, etc. That isn't the drop-down I'm referring to. I'm referring to the Owner drop-down that appears in the lower-half of the SQL Commands window then you click the Saved SQL link. I understand that to be the ApEx developer who saved the SQL - nothing to do with database schemas.
    I saved some SQL using the Save button assuming I could tell my other developers that if they click Saved SQL they'd see it listed. They don't, and the only choices in the Owner drop-down for any of us are "-- All Users --" or our own user. I don't see any setting I can change for our accounts to allow/prevent seeing others' Saved SQL, so either it's a bug, or if it's intentional that a user can only bring back their own saved SQL then there doesn't appear to be any point in having an Owner drop-down.
    Thanks,
    John

  • Schema name added to SQL query after SQL Command

    Post Author: rickeb1
    CA Forum: Data Connectivity and SQL
    Hello,
    I am using Crystal Reports XI.  I have created a Crystal report in the usual manner using a set of tables from a given database schema. When I look at the SQL query that Crystal generates, there are no data schema qualifiers anywhere.
    Then I added an SQL Command object that I use as an additional table. Now when I look at the generated SQL query, the data schema name is added to the beginning of the original query as well as to the new SQL Comand code. It also creates an EXTERNAL JOIN which uses this hard-coded schema name (not exactly sure what an "external join" is).
    This hard-coding of the schema name is causing a problem when we try to migrate the report to a different environment. Is there some way to avoid having Crystal generate a query with the schema name imbedded in the query, or is there a way to remove it after it is generated?
    Thanks!

    Post Author: rickeb1
    CA Forum: Data Connectivity and SQL
    Actually, our problem may be related to this:
    http://boardreader.com/t/Crystal_XI_249231/The_Show_SQL_Query_SQL_command_changes_89667.html
    Any help greatly (and desparately) apapreciated!

  • Using a Variable in SSIS - Error - "Command text was not set for the command object.".

    Hi All,
    I am using a OLE DB Source in my dataflow component and want to select SQL Query from the master table  I have created variables v_Archivequery
    String packageLevel (to store the query).
    <Variable Name="V_Archivequery" DataType="String">
         SELECT a.*, b.BBxKey as Archive_BBxKey, b.RowChecksum as Archive_RowChecksum
         FROM dbo.ImportBBxFbcci a LEFT OUTER JOIN Archive.dbo.ArchiveBBxFbcci b
         ON (SUBSTRING(a.Col001,1,4) + SUBSTRING(a.Col002,1,10)) = b.BBxKey
         Where (b.LatestVersion = 1 OR b.LatestVersion IS NULL)
        </Variable>
    I am assigning this query to the v_Archivequery variable, "SELECT a.*, b.BBxKey as Archive_BBxKey, b.RowChecksum as Archive_RowChecksum
    FROM dbo.ImportBBxFbcci a LEFT OUTER JOIN Archive.dbo.ArchiveBBxFbcci b
     ON (SUBSTRING(a.Col001,1,4) + SUBSTRING(a.Col002,1,10)) = b.BBxKey
    Where (b.LatestVersion = 1 OR b.LatestVersion IS NULL)"
    Now in the OLE Db source, I have selected as Sql Command from Variable, and I am getting the variable, v_Archivequery .
    But when I am generating the package and when running I am getting bewlo errror
     Error at Data Flow Task [OLE DB Source [1]]: An OLE DB error has occurred. Error code: 0x80040E0C.
    An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80040E0C  Description: "Command text was not set for the command object.".
    Can Someone guide me whr am going wrong?
    Please let me know where am going wrong?
    Thanks in advance.
    Thankx & regards, Vipin jha MCP

    What happens if you hit Preview button in OLE DB Source Editor? Also you can use the same query by selecting SQL Command option and test.
    Could you try set the Delay Validation = True at Package and re-run ?
    If set the query in variable expression (not in value), then Set Evaluate As Expression = True.
    -Vaibhav Chaudhari

  • Question re Command Object to populate parameter drop-down

    I have a report that uses a SQL Server stored procedure as the data source. The first parameter they enter is their company number (we have numerous clients using Lawson and access Crystal through LBI). The next parameter is the account number. I have a SQL statement written that gets distinct account numbers by company. When I create a Command object with the SQL statement, it doesn't allow me to use the company parameter.
    SELECT DISTINCT GLC.ACCOUNT, GLC.ACCOUNT_DESC
    FROM dbo.GLMASTER AS GLM
    INNER JOIN DBO.GLCHARTDTL AS GLC
    ON GLM.CHART_NAME = GLC.CHART_NAME
    AND GLM.ACCOUNT = GLC.ACCOUNT
    WHERE GLM.COMPANY = {?Company}
    ORDER BY GLC.ACCOUNT
    When I do Add Command in Database Expert and add the SQL above and name the parameter and try to Add, it says "Failed to retrieve data from the datase.
    Details: ADO Error Code: 0x
    Source: Microsoft OLE DB Provider for SQL Server
    Description: No value given for one or more required parameters
    Does anyone have a similar situation and a solution to this problem--either regarding my approach and error or a different approach to get the same thing?
    Any input would be greatly appreciated!

    You can't do this through a command object.  This particular type of parameter is called a "Cascading Dynamic Prompt".  You have to set these up through a Crystal Business View. 
    -Dell

  • SQL Command returns multiple records, but I see only one record in report

    I work with Crystal Reports XI R2 SP3 and Oracle 10g R2 database.
    I have an SQL Command that returns multiple records. Command name is "CommDivisionNames" and it returns column "CommDivisionNames.DIVISION_NAME". When I place this field into report details section of the report, I can see all 10 records returned and this is how it should be. I actually need this field to be placed in the report header section, and when I place the field there, then I see only the first record. I set that field as "can grow = true". When I do "browse field data" for this field, I see that all 10 records are there, but only the first one is displayed in report header section.
    I thought that I can place SQL Command field anywhere on the report (page header, footer, details) and that it will always show all records that it returns from the database. Can that be done?
    My "main part" of the report returns different set of records, and that's what I have in "report details" section. I need this list of divisions to be in the report header section, so user can see that the report was executed for DivA, DivC, DivE.
    Thank you,
    Milan

    sharonamt:
    Users select divisions from parameter, but the parameter multi values are division_numbers (1,5,10), not division_names. Division_names are visible in parameter_prompt_window as description, but parameter remembers only numbers and I don't know how I can reuse division_names later in formula.
    I do join for division_numbers and make them into one string variable and pass to sub-report, but I think that I can only get these division_names by calling an SQL command or calling stored procedure.
    If I try to do join({MySQLcommand.DIVISION_NAME}) I get error message "A string array is required here".
    Carl:
    I'm playing with cross-tab and I can use it to see all division_names in the report-header section. Since I need them in only one column or only one row, I have to edit cross-tab object and turn all unneeded border lines to white to make them look invisible. So, cross-tab could be a solution for my problem here.
    Another option could be to re-write my SQL command. Since I've read here that SQL command could be written in the same way as I would write a stored procedure, then I could use a bit more complex code to get all multiple division names from the database table into a local cursor, and then use do-while loop to concatenate them into one string, and then to return that string as one record (like 'DivA, DivB, DivC'), and then it should not be a problem to display only that one record/string in report header. It is my understanding that Crystal Reports can call stored procedure that works with many cursors/recordsets and CR will use only the last recordset from the stored procedure. Do you think it could be done this way?
    Thank you,
    Milan

  • Read from sql task and send to data flow task - [OLE DB Source [1]] Error: A rowset based on the SQL command was not returned by the OLE DB provider.

    I have created a execut sql task -
    In that, i have a created a 'empidvar' variable of string type and put sqlstatement = 'select distinct empid from emp'
    Resultset=resultname=0 and variablename=empidvar
    I have added data flow task of ole db type and I put this sql statement under sql command - exec emp_sp @empidvar=?
    I am getting an error.
    [OLE DB Source [1]] Error: A rowset based on the SQL command was not returned by the OLE DB provider.
    [SSIS.Pipeline] Error: component "OLE DB Source" (1) failed the pre-execute phase and returned error code 0xC02092B4.

    shouldnt setting be Result
    Set=Full Resultset as your query returns a resultset? also i think variable to be mapped should be of object type.
    Then for data flow task also you need to put it inside a ForEachLoop based on ADO.NET recordset and map your earlier variable inside it so as to iterate for every value the sql task returns.
    Also if using SP in oledb source make sure you read this
    http://consultingblogs.emc.com/jamiethomson/archive/2006/12/20/SSIS_3A00_-Using-stored-procedures-inside-an-OLE-DB-Source-component.aspx
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • 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

  • Read data from SharePoint using ABAP sql command

    We need to read data from a SharePoint site and update the sap object services with the information. There is a lot of information on how to put data into Sharepoint from SAP, but we need to get data from SharePoint and put it into SAP. Is it possible to retrieve data from SharePoint using sql command in ABAP program? If it is possible, what do we need to do to have SAP recognize where to get the SharePoint data?
    Richard Newman

    Hi Newman,
    You can use native sql in your abap code to read data from SharePoint's database. But I would suggest you to generate a SharePoint webservice which can provide you the neccessary data so that you can consume this webservice in ABAP
    (Will be quite faster than native sql).
    Regards,
    Ozcan.

  • Password keystrokes won't register in Run SQL Command

    I'm sorry if this has been answered before. I searched but I couldn't find this particular problem. I'm new to Oracle and I'm trying to install it on my computer. I'm used to using the Enterprise Edition that is available at school, so the Express Edition seems so much different.
    In case it is important, I'm running Windows Vista Home Premium (64-bit). When I go to Start > All Programs > Oracle Database 10g Express Edition > Run SQL Command Line, I enter "connect", then it prompts me for a username. I enter "SYSDBA", then it asks me for a password and my keystrokes are not recognized. I tried to just go ahead and enter the password I created when I installed and press ENTER but that didn't work.
    I tried going to the Database Homepage, and I can log in with SYSTEM and my password, but my SQL commands and scripts (from school, that work with the Enterprise Edition) don't work. I get this pop-up window with the title "Enter Bind Variables" and the page itself has a SUBMIT button, but there is nothing else there.
    I'm totally lost. Any help is greatly appreciated.
    Edited by: user10823568 on Apr 1, 2009 11:56 PM

    sysdba is a privilege, not a user. SYS and SYSTEM users have the DBA role privileges, SYS owns the catalog (database, tables, datafile, user and object info, all the metadata).
    The sys and system users can manipulate just about anything in the instance, using a connect sys as sysdba grants the ability to do a few more management tasks (i.e. shut down the database). Its best to only use those database logins when they're really needed (backups, startups, etc) and create other database users for all the other stuff. A quick way to get started is
    connect sys as sysdba; -- or connect / as sysdba;
    create user joe identified by joepasswd;
    grant resource to joe;
    grant connect to joe;
    grant create session to joeThe resource privilege is a quick way to get all the rights needed to create tables, indexes, procedures. There are a couple of rights in resource that most admins don't like to hand out to just anyone but it'll get the joe database user rolling.
    Now on to that "bind variables" dialog, the script that is running needs some input, take a look at the .sql file and there's probably an ampersand in there somewhere- maybe it wants a user name name, just have to figure out what it wants.
    And sqlplus does not echo characters typed in at the password prompt, that's normal.

  • Using Crystal Reports formulas in Command Objects

    Post Author: Hamish
    CA Forum: Formula
    Is this possible?
    When I try and reference a formula in a command object
    something like
    select * from tablenamewhere id in (@testFormula)
    @testFormula prints out as 1,2 on the report if I remove the reference in the command object
    I get an error Incorrect syntax near @testFormula from SQL Server
    (I'm using CR XI and SQL Server 2005)

    Post Author: bryanflora
    CA Forum: Formula
    In a matter of fact, Formula is for you to calculate the result you get from DB.And if there's anything you want to pass to DB before you get result, it's Parameter.

  • SQL Workshop - SQL Commands - Saved SQL:  Saved set of commands

    Has any thought been given to this, or perhaps this has already been done.....
    A saved set of SQL commands as a template
    For example, when I'm in Excel and I start writing a lookup formula, a guide appears below the cell, reminding me of the format of what comes next. When I know what I'm doing, I simply ignore the guide. When I don't know what I'm doing, the guide is helpful - even linkable to more information.
    Perhaps there are too many variables here to do that....
    In the meantime, I'm creating my own 'set' as I learn - perhaps that's even better.
    Marion in NY

    Hi Kirsten,
    this could be controlled at the database level whereby you create a schema that doesn't own the objects your users are querying but has the appropriate grants and privileges made to it and synonyms or views created to represent the objects. This schema then becomes the parsing schema for the workspace you let your users use. This wont prevent them from creating update statements, but at the database level it will not allow them to be executed.
    Regards
    Andre

  • Multiple queries in single command object

    Hi All,
    My report uses a command object, which executes an insert query. I want to do 'collect' statistics after the insert query. How to do this in a single command object. Kindly suggest me the possibilities.
    Thanks in advance!
    Meena

    Ido, when I attempt to nest an insert statement followed by a select statement in the same command object, I get a "SQL Command not properly ended" error.
    Here is the SQL:
    insert into testing123 values (sysdate, 4)
    select * from testing123
    If use semicolons to separate the two statement, I get an "Invalid Character" error.
    Here is the SQL:
    insert into testing123 values (sysdate, 4);
    select * from testing123
    Any thoughts on what I might be doing wrong here?
    Thanks!
    Chad

Maybe you are looking for