SQL command length

I am kind of tired searching for solution on web. Let us hope some expert help.
Is there a limit on command length in sql prompt? I am using Oracle 10g and found that sql prompt doesnt take command line longer than 256 char.
SQL> update oe_order_headers_all set attribute19 = (select attribute19 from xx_quote_additional_info where username = 'DTUKADIABjk') where order_number = 14502 and attribute19 = (select attribute19 from xx_quote_additional_info where username = 'DTUKADIABjk') ;
This are 256 char if I want to add something to this line, it wont take.....have to add to next line and then run.
Only issue is I have to devide long query into multiple lines and then run. can not directly copy from code and run.

user11032875 wrote:
Thanks 009,
That solve partial of my issue. I set following command,
DEFINE _EDITOR=vi
Now this opens vi editor and I can paste my long command. then / , But for each change again have to go to vi editor doesnt sound good to me. Using an editor to edit your query doesn't sound good? ?:|
Sounds ideal to me.
I tried sqlplus on my local desktop with Oracle 11g database. It allow you to enter as may characters as command. But my sqlplus with Oracle 9i database allows only 258.You intially said you were using 10g, not 9i. That makes a difference. Upgrade your SQL*Plus client to 10g or 11g.

Similar Messages

  • SQL Maximum Command Length

    I have created a MySQL database and a LabView 8.6 application which inserts data into the database, using the SQL toolkit.  I'm having trouble inserting very long character data into a LONGTEXT field.  I've determined that the issue occurs when either the length of the SQL command exceeds 1,048,574 characters or the length of one particular field exceeds 1,048,326 characters (can't tell which).
    The error I get is "Error -2147467259 occurred at NI_Database_API.lvlib:Conn Execute.vi.  Exception occured in Microsoft OLE DB Provider for ODBC Drivers: [MySQL][ODBC 5.1 Driver][mysqld-5.1.35-community]MySQL server has gone away in NI_Database_API.lvlib:Conn Execute.vi"
    According to the MYSQL documentation, a LONGTEXT can hold 4,294,967,295 characters, so length shouldn't be an issue.  The documentation also states "The effective maximum length of LONGTEXT columns also depends on the configured maximum packet size in the client/server protocol and available memory", but I'm not sure how to configure the packet size in LabView. 
    I'm attaching example code which replicates the problem, although it depends upon a particular table structure to actually execute.  The table definition is included on the diagram. 
    Solved!
    Go to Solution.
    Attachments:
    ExampleInsertError.VI ‏40 KB

    This setting would be configured outside of LabVIEW (UDL or DSN).
    You need to configure both the server and the client:
    I found this link by searching on stackoverflow
    http://dev.mysql.com/doc/refman/5.1/en/packet-too-large.html
    You may need to select/configure a specific (different) provider in order to set this variable.
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness

  • 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 use lengthy query in a "SQL Command from Variable"

    My oracle SQL Query length is more than 14000 characters, so how can i use this for "SQL command from variable".
    Sarvan

    Either create a view or a table valued UDF. Using stored procedure in OLEDB source has some gotchas it will not pick up metadata information by default due to late binding.
    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

  • SQL Command conversion in abap code

    Hi,
    I want to implement the UNION, INTERSECT and MINUS SQL commands in abap code. Please give me the appropriate solutions asap.
    For Example:
    select field1, field2, . field_n
    from tables
    <b>UNION</b>
    select field1, field2, . field_n
    from tables;
    select field1, field2, . field_n
    from tables
    <b>MINUS</b>
    select field1, field2, . field_n
    from tables;
    select field1, field2, . field_n
    from tables
    <b>INTERSECT</b>
    select field1, field2, . field_n
    from tables;
    Thanks,
    Ravi

    Hi Ravi
    Check out this procedure...
    DATA: FRANKFURT(4) TYPE X,
          FRISCO(4)    TYPE X,
          INTERSECT(4) TYPE X,
          UNION(4)     TYPE X,
          BIT          TYPE I.
    DATA: CARRID TYPE SPFLI-CARRID,
          CARRIER LIKE SORTED TABLE OF CARRID
                              WITH UNIQUE KEY TABLE LINE.
    DATA WA TYPE SPFLI.
    SELECT CARRID FROM SCARR INTO TABLE CARRIER.
    SELECT CARRID CITYFROM FROM SPFLI
                           INTO CORRESPONDING FIELDS OF WA.
      WRITE: / WA-CARRID, WA-CITYFROM.
      READ TABLE CARRIER FROM WA-CARRID TRANSPORTING NO FIELDS.
      CASE WA-CITYFROM.
        WHEN 'FRANKFURT'.
          SET BIT SY-TABIX OF FRANKFURT.
        WHEN 'SAN FRANCISCO'.
          SET BIT SY-TABIX OF FRISCO.
      ENDCASE.
    ENDSELECT.
    INTERSECT = FRANKFURT BIT-AND FRISCO.
    UNION     = FRANKFURT BIT-OR  FRISCO.
    SKIP.
    WRITE 'Airlines flying from Frankfurt and San Francisco:'.
    DO 32 TIMES.
      GET BIT SY-INDEX OF INTERSECT INTO BIT.
        IF BIT = 1.
          READ TABLE CARRIER INDEX SY-INDEX INTO CARRID.
          WRITE CARRID.
        ENDIF.
    ENDDO.
    SKIP.
    WRITE 'Airlines flying from Frankfurt or San Francisco:'.
    DO 32 TIMES.
      GET BIT SY-INDEX OF UNION INTO BIT.
        IF BIT = 1.
          READ TABLE CARRIER INDEX SY-INDEX INTO CARRID.
          WRITE CARRID.
        ENDIF.
    ENDDO.
    This produces the following output list:
    The program uses four hexadecimal fields with length 4 - FRANKFURT, FRISCO, INTERSECT, and UNION. Each of these fields can represent a set of up to 32 elements. The basic set is the set of all airlines from database table SCARR. Each bit of the corresponding bit sequences representes one airline. To provide an index, the external index table CARRIER is created and filled with the airline codes from table SCARR. It is then possible to identify an airline using the internal index of table CARRIER.
    In the SELECT loop for database table SPFLI, the corresponding bit for the airline is set either in the FRANKFURT field or the FRISCO field, depending on the departure city. The line number SY-TABIX is determined using a READ statement in which no fields are transported.
    The intersection and union of FRANKFURT and FRISCO are constructed using the bit operations BIT-AND and BIT-OR.
    The bits in INTERSECT and UNION are read one by one and evaluated in two DO loops. For each position in the fields with the value 1, a READ statement retrieves the airline code from the table CARRIER.
    Comparing Bit Sequences
    Use the following three operators to compare the bit sequence of the first operand with that of the second:
    <operator>
    Meaning
    O
    bits are one
    Z
    bits are zero
    M
    bits are mixed
    The second operand must have type X. The comparison takes place over the length of the second operand. The first operand is not converted to type X.
    The function of the operators is as follows:
    O (bits are one)
    The logical expression
    <f> O <hex>
    is true if the bit positions that are 1 in <hex>, are also 1 in <f>. In terms of set operations with bit sequences, this comparison is the same as finding out whether the set represented by <hex> is a subset of that represented by <f>.
    Z (bits are zero)
    The logical expression
    <f> Z <hex>
    is true if the bit positions that are 1 in <hex>, are 0 in <f>.
    M (bits are mixed)
    The logical expression
    <f> M <hex>
    is true if from the bit positions that are 1 in <hex>, at least one is 1 and one is 0 in <f>.
    Caution: The following programs are no longer supported in Unicode systems:
    REPORT demo_log_expr_bits .
    DATA: text(1) TYPE c VALUE 'C',
          hex(1) TYPE x,
          i TYPE i.
    hex = 0.
    DO 256 TIMES.
      i = hex.
      IF text O hex.
        WRITE: / hex, i.
      ENDIF.
      hex = hex + 1.
    ENDDO.
    The output is as follows:
    00          0
    01          1
    02          2
    03          3
    40         64
    41         65
    42         66
    43         67
    Here, the bit structure of the character 'C' is compared to all hexadecimal numbers HEX between '00' and 'FF' (255 in the decimal system), using the operator O. The decimal value of HEX is determined by using the automatic type conversion during the assignment of HEX to I. If the comparison is true, the hexadecimal number and its decimal value are displayed on the screen. The following table shows the bit sequences of the numbers:
    Thanks
    Ashok

  • Restrictions for using sql commands and operators in loader control file

    Hi ,
    It suppose that there is a lot of restrictions and limitations when using sql commands and operators in the loader control files, same as it seems I cannot use (or) when with case statement, also it seems there is certain length for the case,
    So guys, what are the common limitations and restrictions to be avoided in the loader control file ?
    Your efforts are highly appreciated
    Ash

    Hi Ash,
    if you need to do more complicated logic its better to define the file to be loaded as an external table. You can then use any sql function you like against the external table rather than messing around with what you can and can;t do in a sqlldr control file.
    You can use the external_table option of sqldr to generate the definition.
    Regards,
    Harry
    http://dbaharrison.blogspot.com/

  • Crystal Reports for Enterprise - SQL Command - Array Fetch Size

    We're attempting to migrate a report created in Crystal Reports 2013 Support Pack 3  Version 14.1.3.1257 to...
    Crystal Reports for Enterprise Version 14.1.3.1300 Build: 2013 Support Pack 3 Patch 1
    The originating report is successfully connecting and returning data from MySQL through the MySQL ODBC 3.51 Driver (3.51.30.00), using a SQL Command
    When opening up this report in CR for E and running the report against the same database and the same version of database driver, we get the following Crystal Reports error:
    Crystal Reports
    A problem was encountered
    The following error has occurred while trying to retrieve the data:
    Error on Fetch : Largevarchar and Largevarbinary data cannot retrieved as variable-length data if the array fetch size is not set to 1.
    Please check with your System Administrator that the data source is correctly configured.
    How would we check and where would we adjust the array fetch size within Crystal Report for Enterprise?
    Thank you

    Hi Vitaly,
    I had not yet tried creating a new report based on the query, within CR for E, but I did now upon your request\suggestion.  Yes, it fails as well with a brand new report..same new error as above: "Non Supported Datatype"
    I've pasted the SQL we are using below.  I just tried running this exact query natively through MyPHPAdmin, and also creating a brand new report with Crystal Reports 2013 against the same ODBC driver that I am trying to use within CR for E.  In both cases the query was accepted and ran successfully.
    Driver info:
    MySQL ODBC 3.51 Driver -  Version 3.51.30.00
    I have also tried 2 newer versions of the driver:
    MySQL ODBC 5.3 ANSI - Version 5.03.02.00
    MySQL ODBC 5.3 Unicode - Version 5.03.02.00
    ...where I also configure each within the Information Design Tool so that the "Array Fetch Size"=  1
    I receive the same "Non Supported Datatype" error for these drivers as well.  The MySQL server version is:  5.1.73-0ubuntu0.10.04.1-log
    Protocol Version: 10
    MySQL charset:  UTF-8
    Here is the query:
    SELECT ft.seq_id, ft.ticket_date, ft.posttotal,
    wl.name as current_approval_level,
    TIMESTAMPDIFF(DAY,ft.ticket_date,NOW()) AS Days_Since_TicketDate,
    TIMESTAMPDIFF(DAY,ft.date_created,NOW()) AS Days_Since_Created,
    TIMESTAMPDIFF(DAY,wph.workflow_date,NOW()) AS Days_Waiting_Your_Approval,
    ft.internal_comments
    FROM ticket AS ft
    LEFT JOIN unit AS unit ON (ft.unit_id = unit.id)
    LEFT JOIN unit_district AS udist ON (udist.unit_id = unit.id AND (udist.effective_date IS NULL OR udist.effective_date = 0 OR udist.effective_date <= ft.ticket_date)
           AND (udist.expiry_date IS NULL OR udist.expiry_date = 0 OR udist.expiry_date >= ft.ticket_date))
    LEFT JOIN workflow_document_process_map AS wdpm ON (ft.id = wdpm.document_id AND wdpm.document_type_id = 1)
    LEFT JOIN workflow_process AS wp ON (wp.id = wdpm.workflow_process_id)
    LEFT JOIN workflow_rule AS wr ON (wp.workflow_schema_id = wr.workflow_schema_id AND wp.workflow_level_id = wr.workflow_level_id AND wr.workflow_activity_id = 2  AND (wr.effective_date IS NULL OR wr.effective_date = 0 OR wr.effective_date <= ft.ticket_date) AND (wr.expiry_date IS NULL OR wr.expiry_date = 0 OR wr.expiry_date >= ft.ticket_date))
    LEFT JOIN workflow_rule AS wr2 ON (wp.workflow_schema_id = wr2.workflow_schema_id AND wp.workflow_level_id = wr2.workflow_level_id AND wr2.workflow_activity_id = 4 AND (wr2.effective_date IS NULL OR wr2.effective_date = 0 OR wr2.effective_date <= ft.ticket_date) AND (wr2.expiry_date IS NULL OR wr2.expiry_date = 0 OR wr2.expiry_date >= ft.ticket_date))
    LEFT JOIN workflow_process_history AS wph ON (wph.workflow_process_id = wp.id)
    LEFT JOIN ticket_attachment AS ftattach ON (ft.id = ftattach.ticket_id AND ftattach.attachment_type_id = 2)
    LEFT JOIN person AS p ON (ft.supervisor_id = p.id)
    LEFT JOIN person AS p2 ON (ft.head_office_contact_id = p2.id AND (p2.effective_date IS NULL OR p2.effective_date = 0 OR p2.effective_date <= ft.ticket_date)
           AND (p2.expiry_date IS NULL OR p2.expiry_date = 0 OR p2.expiry_date >= ft.ticket_date))
    LEFT JOIN person AS p3 ON (ft.sales_person_id = p3.id)
    LEFT JOIN person_company_sales AS pcs ON (p2.id = pcs.client_person_id AND pcs.company_id = ft.client_company_id)
    LEFT JOIN person AS p4 ON (ft.created_by = p4.id)
    LEFT JOIN person AS p5 ON (ft.well_site_supervisor_id = p5.id)
    LEFT JOIN division AS d ON (ft.division_id = d.id)
    LEFT JOIN district AS dist1 ON (ft.district_id = dist1.id)
    LEFT JOIN district AS dist2 ON (udist.district_id = dist2.id)
    LEFT JOIN company AS c ON (ft.client_company_id = c.id)
    LEFT JOIN province AS prov ON (ft.job_province_id = prov.id)
    LEFT JOIN ticket_attachment AS ftattach2 ON (ft.id = ftattach2.ticket_id AND ftattach2.attachment_type_id != 2)
    LEFT JOIN locale_currency AS lc ON (lc.id = ft.locale_currency_id)
    LEFT JOIN operation_type AS ot ON (ot.id = ft.operation_type_id)
    LEFT JOIN incident AS i ON (i.ticket_id = ft.id)
    LEFT JOIN invoice_type AS it ON (it.id = ft.invoice_type_id)
    LEFT JOIN workflow_level AS wl ON (wl.id = wp.workflow_level_id)
    LEFT JOIN company AS dist1_company ON (dist1_company.id = dist1.internal_company_id)
    WHERE 1
    AND ( pcs.sales_person_id = 2113 AND pcs.effective_date <= ft.ticket_date AND ( pcs.expiry_date >= ft.ticket_date OR pcs.expiry_date = '0000-00-00 00:00:00' OR pcs.expiry_date IS NULL) )
    AND ft.closed_flag <> 1 AND (wr2.id IS NOT NULL OR wr2.id != 0)
    AND ft.commit_flag = 1
    AND ft.dispatch_status = 0
    AND dist1_company.country_id = 1
    AND wr2.role_id = 2
    GROUP BY ft.id
    ORDER BY ticket_date ASC, ft.id ASC
    Thanks you for your help.

  • 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

  • Query help in sql commands

    using apex 4.1 i'm entering the following query in the sql command window and I keep getting a pop-up for Entering Bind Variable. I'm not using bind variables though, anyone else see this issue before?
    SELECT A.FIRST,A.LAST,A.COMPANY AS CNAME,
    J.TOT_MAN_HOURS,
    J.ACREAGE,
    W.NUM_WORKERS,
    W.START_DT
    FROM EW_ACCOUNTS A, EW_WORK_ORDER W, EW_JOBS J
    WHERE A.ID = J.ACCT_ID
    AND J.JOB_ID = W.JOB_ID
    AND W.START_DT >= SYSDATE
    AND W.START_DT < SYSDATE+1
    ORDER BY W.START_DT

    I tried that and it didn't seem to help either.
    Funny though, if I write a new query against just one of the tables and write out each column name. it works. If I use the * instead of writing each column name, I have the same issue.
    This is in apex.appshosting.com free demo environment. I sent them an email asking about it and they told me it was a code issue and they don't support the demo environment.

  • Delete table in SQL command

    Hello,
    As part of my report I populate a table then reference it in several following subreports.
    The issue I'm having is that I need to clear all the data from my table after using it to allow the report to run again (and not get multiple results)
    To do this I have tried to add a sub report at the very end (and start) of my report with the SQL command truncate table <tablename> or delete <tablename> or delete <tablename> where 1 = 1.
    When I try truncate I get an error saying that I don't have permission (despite granting it but hey...) which is why I switched to delete, this runs fine but the table doesn't get deleted...
    Any thoughts as to why this isn't working/how I can clear my table? I have thought of setting up a separate scheduled job to delete the table contents however I do also need to run the report several times with different parameters so this isn't an ideal solution.
    I have tried adding a select after my delete statement as I thought if it had something to display on the report it would have to look at it but this didn't make any difference.
    Any help will be much appreciated!
    Thanks
    Chris

    Thanks for that!
    I have had a go at this and I can see how it will work although I have limited access on the Crystal userid I have so will need to have the SP created as part of our nightly refresh script I think.
    Is there no way of getting crystal to run my delete statement otherwise?
    Thanks again
    Chris

  • Crystal Report performance - subreports or sql command?

    Hello,
    bit of quandary, I've an existing report that contains six subreports all sharing the same parameter to the main report, a 'projectID' field.
    The main report approximately returns 300 records/projects and each of the 6 subreports are passed the corresponding 'projectID' field 300 times.
    Now, I've succesfully incorporated the main report query and corresponding subreports into a TSQL command containing a number of subqueries in the Select clause:
    SELECT   PROJECT.PROJECTID, PROJECT.TITLE, PROJECT.REFERENCE, PROJECTSTATUS.PROJECTSTATUS, PROJECT.INPUT_DATE
    ,(SELECT max(INPUT_DATE) FROM V_PROJECT_NOTE AS VPN
    WHERE PROJECT.PROJECTID = VPN.PROJECTID) AS LastHeadline
    ,(SELECT
    MAX(CASE
         WHEN MODIFIED_DATE IS NULL THEN INPUT_DATE
         WHEN INPUT_DATE > MODIFIED_DATE THEN INPUT_DATE
              ELSE MODIFIED_DATE
    END) FROM ISSUE WHERE PROJECT.PROJECTID = ISSUE.PROJECTID) AS LastNewIssue
    ,(SELECT max(ISSUENOTE.INPUT_DATE) FROM ISSUE
    INNER JOIN ISSUENOTE ON ISSUE.ISSUEID = ISSUENOTE.ISSUEID
    WHERE PROJECT.PROJECTID = ISSUE.PROJECTID ) AS LastIssueNote 
    ,(SELECT max(modified_date) FROM V_PROJECT_RISK_LAST_AMMENDED AS VPR
    WHERE PROJECT.PROJECTID = VPR.PROJECTID) AS LastRiskLogUpdate
    ,(SELECT max(INPUT_DATE) FROM PROJECT_CHECKLIST AS PC
    WHERE PROJECT.PROJECTID = PC.PROJECTID) AS LastChecklistUpdate
    ,(SELECT max(input_date) FROM V_PROJECT_ACTIVITY_LAST_AMMENDED AS VPA
    WHERE PROJECT.PROJECTID = VPA.PROJECTID) AS LastGANTTUpdate 
    ,V_PROJECT_KEYCONTACT.USERNAME AS KeyContact
    ,(SELECT     USERPROFILE.USERNAME AS Supervisor
    FROM         USERPROFILE INNER JOIN
                          PROJECT_MEMBER AS SUPERVISOR ON USERPROFILE.USERID = SUPERVISOR.USERID RIGHT OUTER JOIN
                          PROJECT_MEMBER AS KEYCONTACT ON SUPERVISOR.PROJECT_MEMBERID = KEYCONTACT.PARENTID
    WHERE PROJECT.PROJECTID = KEYCONTACT.PROJECTID
    AND KEYCONTACT.KEY_CONTACT =1) AS Supervisor
    FROM         PROJECT INNER JOIN
                          PROJECTSTATUS ON PROJECT.PROJECTSTATUSID = PROJECTSTATUS.PROJECTSTATUSID LEFT OUTER JOIN
                          V_PROJECT_KEYCONTACT ON PROJECT.PROJECTID = V_PROJECT_KEYCONTACT.PROJECTID
    WHERE V_PROJECT_KEYCONTACT.USERNAME IN ('aaa','bbb','ccc')
    AND (PROJECTSTATUS.PROJECTSTATUS IN ('111', '222', '333'))
    AND ((PROJECT.TITLE NOT LIKE 'xxx%') AND (PROJECT.TITLE NOT LIKE 'yyy%') AND (PROJECT.TITLE NOT LIKE 'zzz%'))
    ORDER BY V_PROJECT_KEYCONTACT.USERNAME, PROJECT.INPUT_DATE
    Now, I've run both SQL Server Profiler and looked at the Performance Information in Crystal and the SQL command method is an order of magnitude less efficient!!
    I may have to post my query on a TSQL forum but was wondering if anyone on here can possible shed any light on it?
    Thanks in advance,
    Dom

    Dom,
    I assume that the last edit was to remove a few curse words...
    The reality is that we can give a good explanation as to why the sub-report version would execute faster that the command version w/o seeing the report (with the sub-reports included).
    Looking at the SQL, I can tell that it's a fairly expensive query, firing several sub-queries for every row returned by the outer query. That said, I sounds like the same thing is taking place with the sub-report version too... So I would think that the performance would be similar.
    The only thing that I can think of, and this is just a guess... With the sub-report version, each all queries are being run independently and then combined locally by CR, whereas the command version, everything is combined. The more complex the query, the harder the optimizer has to work to come up with the best execution plan... and the greater the likelihood that that the resulting plan isn't as optimized as it could be.
    That said, I'd still think the command version would be faster over all. Are you seeing real differences between the two reports, in the amount of time that it takes from refresh to final render?
    Either way, I think moving all of those sub-queries from the select list (where they are executing once for every row) down to the FROM area (where they only have to execute once) should increase the speed dramatically and surpass the sub-report version by a decent margin.
    Give this version of your SQL a test drive and see if it yields an improvement.
    SELECT  
    PROJECT.PROJECTID,
    PROJECT.TITLE,
    PROJECT.REFERENCE,
    PROJECTSTATUS.PROJECTSTATUS,
    PROJECT.INPUT_DATE,
    VPN.LastHeadline,
    ISSUE.LastNewIssue,
    ISSUE_NOTE.LastIssueNote,
    VPR.LastRiskLogUpdate,
    PC.LastChecklistUpdate,
    VPA.LastGANTTUpdate,
    V_PROJECT_KEYCONTACT.USERNAME AS KeyContact,
    Supervisor.Supervisor
    FROM PROJECT
    INNER JOIN PROJECTSTATUS ON PROJECT.PROJECTSTATUSID = PROJECTSTATUS.PROJECTSTATUSID
    LEFT OUTER JOIN V_PROJECT_KEYCONTACT ON PROJECT.PROJECTID = V_PROJECT_KEYCONTACT.PROJECTID
    LEFT OUTER JOIN (
         SELECT PROJECTID,
         max(INPUT_DATE) AS LastHeadline
         FROM V_PROJECT_NOTE
         GROUP BYPROJECTID) AS VPN ON PROJECT.PROJECTID = VPN.PROJECTID
    LEFT OUTER JOIN (
         SELECT PROJECTID,
         MAX(CASE
              WHEN MODIFIED_DATE IS NULL THEN INPUT_DATE
              WHEN INPUT_DATE > MODIFIED_DATE THEN INPUT_DATE
              ELSE MODIFIED_DATE END) AS LastNewIssue
         FROM ISSUE
         GROUP BY PROJECTID) AS ISSUE ON PROJECT.PROJECTID = ISSUE.PROJECTID
    LEFT OUTER JOIN (
         SELECT ISSUE.PROJECTID,
         max(ISSUENOTE.INPUT_DATE) AS LastIssueNote
         FROM ISSUE
         INNER JOIN ISSUENOTE ON ISSUE.ISSUEID = ISSUENOTE.ISSUEID
         GROUP BY ISSUE.PROJECTID) AS ISSUE_NOTE ON PROJECT.PROJECTID = ISSUE_NOTE.PROJECTID
    LEFT OUTER JOIN (
         SELECT PROJECTID,
         max(modified_date) AS LastRiskLogUpdate
         FROM V_PROJECT_RISK_LAST_AMMENDED
         GROUP BY PROJECTID) AS VPR ON PROJECT.PROJECTID = VPR.PROJECTID
    LEFT OUTER JOIN (
         SELECT PROJECTID,
         max(INPUT_DATE) AS LastChecklistUpdate
         FROM PROJECT_CHECKLIST
         GROUP BY PROJECTID) AS PC ON PROJECT.PROJECTID = PC.PROJECTID
    LEFT OUTER JOIN (
         SELECT PROJECTID,
         max(input_date) AS LastGANTTUpdate
         FROM V_PROJECT_ACTIVITY_LAST_AMMENDED
         GROUP BY PROJECTID) AS VPA ON PROJECT.PROJECTID = VPA.PROJECTID
    LEFT OUTER JOIN (
         SELECT PROJECTID,
         USERPROFILE.USERNAME AS Supervisor
         FROM USERPROFILE
         INNER JOIN PROJECT_MEMBER AS SUPERVISOR ON USERPROFILE.USERID = SUPERVISOR.USERID RIGHT
         OUTER JOIN PROJECT_MEMBER AS KEYCONTACT ON SUPERVISOR.PROJECT_MEMBERID = KEYCONTACT.PARENTID
         WHERE KEYCONTACT.KEY_CONTACT =1) AS Supervisor ON PROJECT.PROJECTID = Supervisor.PROJECTID
    WHERE V_PROJECT_KEYCONTACT.USERNAME IN ('aaa','bbb','ccc')
    AND (PROJECTSTATUS.PROJECTSTATUS IN ('111', '222', '333'))
    AND ((PROJECT.TITLE NOT LIKE 'xxx%')
    AND (PROJECT.TITLE NOT LIKE 'yyy%')
    AND (PROJECT.TITLE NOT LIKE 'zzz%'))
    ORDER BY V_PROJECT_KEYCONTACT.USERNAME, PROJECT.INPUT_DATE
    HTH,
    Jason

  • Query running on sql commands prompt not running on report region

    Hi All,
    Facing a weird issue now. I have written a report query which is running absolutely fine in sql command prompt but when i trying to run this as a report it is just processing and the report is not loading. What could be the reason behing this?
    Thanks in Advance
    Regards

    Hi,
    With no other information about the problem is hard to know what's happening. If you could at least provide us with the query then I think it would be easier for us to help you.
    Regards,
    Sergio

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

  • Without using SubReport or SQL Command in Main Report, get desired results without duplicating

    It seems so simple.  I just need the cost, at a certain time (based on a parameter), for each item.  I wrote a SQL Command that works beautifully, but when it connects to the existing report, it slows to a horrible crawl and cannot be used for tables with over 4 million records.  Here is the SQL Command that provides the desired results:
    SELECT TOP 1 WITH TIES "INVENTITEMPRICE"."ITEMID", "INVENTITEMPRICE"."PRICETYPE", "INVENTITEMPRICE"."MARKUP", "INVENTITEMPRICE"."PRICEUNIT", "INVENTITEMPRICE"."PRICE", "INVENTITEMPRICE"."PRICEQTY", "INVENTITEMPRICE"."ACTIVATIONDATE", "INVENTITEMPRICE"."DATAAREAID"
    FROM ("AX09PROD"."dbo"."INVENTITEMPRICE" "INVENTITEMPRICE" INNER JOIN "AX09PROD"."dbo"."INVENTTABLE" "INVENTTABLE" ON (("INVENTITEMPRICE"."ITEMID"="INVENTTABLE"."ITEMID") AND ("INVENTITEMPRICE"."DATAAREAID"="INVENTTABLE"."DATAAREAID")))
    WHERE  ("INVENTITEMPRICE"."DATAAREAID"=N'TMC' AND "INVENTITEMPRICE"."PRICETYPE"=0 AND "INVENTITEMPRICE"."ACTIVATIONDATE"<={?As Of Date})
    ORDER BY ROW_NUMBER () OVER(PARTITION BY "INVENTITEMPRICE"."ITEMID" ORDER BY "INVENTITEMPRICE"."ACTIVATIONDATE" DESC)
    I've attached the report with saved data.  However, when I remove the restrictions of just certain items, it is unusable as it is SO SLOW!
    I can also get the desired results from using a subreport but it takes forever to export due to the number of records/items.  Whenever possible, I avoid subreports for this reason.  I've attached that report with data as well.
    Please be patient as I'm not savvy in SQL, but decent in generating reports.  What am I doing wrong?  This seems SO simple.  The premise is that I want the corresponding information based on the date entered:  If the date entered is 3/15/2014, the result should be 91.15 as indicated below.  I'd simply like this value to be placed in a formula per item.
    Item 80014:
    Activation Date
    Cost Price
    6/2/2014
    104.43
    4/1/2014
    91.58
    3/1/2014
    91.15
    2/1/2014
    92.89
    1/1/2014
    93.57
    Any assistance would be GREATLY appreciated!
    Thanks!
    Teena
    Update:  I was unable to attach the reports with .rpt or .txt extensions.  There were well under 1MB.  Any suggestions?

    hi Teena,
    if you're going the inline subquery route, try something like the following...the last line in the sub-query 'where' clause should in theory take care of matching the correct price based on relating the item id's between your cost price & inventory data. this should leave you with distinct values for each itemid then. hopefully it won't error out as i'm just guessing on the syntax.
    SELECT DISTINCT
    "INVENTTABLE"."ITEMID",
    "INVENTTRANS"."DATAAREAID",
    "INVENTTRANS"."DATEPHYSICAL",
    "INVENTTRANS"."QTY",
    "INVENTTABLE"."ITEMGROUPID",
    "INVENTTABLE"."ITEMNAME",
    "INVENTTRANS"."TRANSREFID",
    "INVENTTRANS"."STATUSISSUE",
    "INVENTTABLE"."ITEMTYPE",
    "INVENTTRANS"."TRANSTYPE",
    "INVENTTRANS"."RECID",
    "INVENTTRANS"."DIRECTION",
    SELECT TOP 1 "INVENTITEMPRICE"."PRICE"
    FROM "AX09PROD"."dbo"."INVENTITEMPRICE" "INVENTITEMPRICE"
    WHERE  "INVENTITEMPRICE"."DATAAREAID" LIKE 'TMC%'
    AND "INVENTITEMPRICE"."PRICETYPE"=0
    AND "INVENTITEMPRICE"."ACTIVATIONDATE"<={?As Of Date}
    AND "INVENTITEMPRICE"."ITEMID" = "INVENTTABLE"."ITEMID"
    ORDER BY "INVENTITEMPRICE"."ACTIVATIONDATE" DESC
    ) AS ITEMPRICE
    FROM  
    "AX09PROD"."dbo"."INVENTTABLE" "INVENTTABLE"
    LEFT OUTER JOIN "AX09PROD"."dbo"."INVENTTRANS" "INVENTTRANS"
    ON ("INVENTTABLE"."DATAAREAID"="INVENTTRANS"."DATAAREAID")
    AND ("INVENTTABLE"."ITEMID"="INVENTTRANS"."ITEMID")
    WHERE 
    "INVENTTRANS"."DATAAREAID" LIKE 'TMC%'
    AND (("INVENTTABLE"."ITEMGROUPID" LIKE 'RAW%') OR ("INVENTTABLE"."ITEMGROUPID" BETWEEN '000' AND '999') OR ("INVENTTABLE"."ITEMGROUPID" LIKE 'Ship_Box'))
    AND "INVENTTABLE"."ITEMTYPE" IN (0,1)
    ORDER BY 
    "INVENTTABLE"."ITEMGROUPID",
    "INVENTTABLE"."ITEMID",
    "INVENTTRANS"."DATEPHYSICAL" ASC
    Message was edited by: Jamie Wiseman

  • 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

Maybe you are looking for

  • How do I disable all add-ons so add-on pop-ups do not occur in Firefox?

    When I am using an web-based application in firefox, I keep getting pop-up windows for add-ons to firefox. How can I stop these from occuring if I do not want any add-ons ever? == This happened == Not sure how often == User Agent == Mozilla/4.0 (comp

  • How to migrate catehery and chat room from one lync 2013 PR pool to other

    Looks weired question, But i am working on to moveing chat room anmd catagory from one lync 2013 PR pool to other persietenc pool in different site. Any one has nay idea or any post talking about ?? Anil MCC 2011,ITIL V3,MCSA 2003,MCTS 2010, My Blog

  • Sap/hr/ number  range

    FOR HIRING PERMANENAT EMPLOYEES I WANT TO USE 1 RANGE . IT IS UNCHECKED . EG. I WANT TO MAKE NEW HIRING there are already 5 intervals for different category in transaction pa04 . In this case for hiring (pa40) per. no should start from 0000003352 NO 

  • Search page to database list results

    I need to add a search form to a database list don't know how with Dreamweaver Thanks Dave

  • How to do a simple recording using macbook?

    I quickly need to make an audition CD - and it was suggested that I just use Garage band (which I have never even opened!)..... I don't have an external mic - so how do I make a simple recording on the Macbook of voice and piano and then burn it to a