Setting the sql statement

http://www.egbolig.dk/drift_bo_syd.rpt (HERE IS THE REPORT)
We are using SAP Crystal Report .NET Runtime files (http://scn.sap.com/docs/DOC-7824 newest version 13.0.9.1312) in our web asp.net application. Everything have been working fine, but we have can into problems when showing the certain kinda reports.
In our code get the reports sql statement using getSQLStatement.
Dim gp As New GroupPath() Dim sql As String = report.ReportClientDocument.RowsetController.GetSQLStatement(gp)
This will get the sql, and we use this sql (getSqlStatement) and attach a sql WHERE clause from the code to only get a certain number of records.
The report Drift_bo_syd.rpt has 5 tables, and the following sql statement. 
Database/Show Sql Statement
SELECT "rekvstam"."Sel", "rekvstam"."Afd", "rekvstam"."Levadresse", "rekvstam"."Rekvisition", "rekvstam"."Lejemaal", "rekvstam"."Lejer", "rekvstam"."Udfoertaf", "rekvstam"."Udfoertdato", "rekvstam"."Krit", "Selskab"."Adresse", "Selskab"."Postby", "Selskab"."Tlf", "Selskab"."Fax", "rekvstam"."Kontor", "rekvstam"."Hjemme", "rekvstam"."Rekvdato", "rekvstam"."Aftale", "rekvstam"."InitialRet", "rekvstam"."Arbejde", "kreditor"."Att", "rekvstam"."Konto", "Selskab"."Navn", "Selskab"."Email", "Interessentadresse"."Navn", "Interessentadresse"."Adresse", "Interessentadresse"."Postby", "Interessentadresse"."Email1", "Interessentadresse"."Telefon_Fax", "Interessentadresse"."Type", "Interessentadresse"."Tlf1", "rekvstam"."tlfLejer", "kreditor"."Kred", "Interessentadresse"."Interessentnr" FROM  (("Rekvstam" "rekvstam" INNER JOIN "Selskab" "Selskab" ON "rekvstam"."Sel"="Selskab"."Sel") LEFT OUTER JOIN "Kreditor" "kreditor" ON "rekvstam"."Kred"="kreditor"."Kred") INNER JOIN "Interessentadresse" "Interessentadresse" ON "kreditor"."Interessentnr"="Interessentadresse"."Interessentnr" WHERE  "Interessentadresse"."Type"='K' 
But if we run the report from our asp.net code, we get the following error: 
Cannot determine the queries necessary to get data for this report. Failed to retrieve data from the database. Error in File Drift_Bo_Syd {97FED382-1BAC-4DB1-970F-9E098ECE28F1}.rpt: Failed to retrieve data from the database.
After a long time searching for a solution, we found out that if we place the column kred from the kreditor table on the report, the report will work. (field explorer / database fields / kreditor (table) / kred (column)
Very important is that the field "kreditor.kred" is a primary key of the table kreditor, and also used in the linking.!
(We can get the report to work if we call the sql statement with the "kreditor"."kred" in the SELECT statement.
SELECT "kreditor"."kred", "rekvstam"."Sel", "rekvstam"."Afd", "rekvstam"."Levadresse", "rekvstam"."Rekvisition", "rekvstam"."Lejemaal", "rekvstam"."Lejer", "rekvstam"."Udfoertaf", "rekvstam"."Udfoertdato", "rekvstam"."Krit", "Selskab"."Adresse", "Selskab"."Postby", "Selskab"."Tlf", "Selskab"."Fax", "rekvstam"."Kontor", "rekvstam"."Hjemme", "rekvstam"."Rekvdato", "rekvstam"."Aftale", "rekvstam"."InitialRet", "rekvstam"."Arbejde", "kreditor"."Att", "rekvstam"."Konto", "Selskab"."Navn", "Selskab"."Email", "Interessentadresse"."Navn", "Interessentadresse"."Adresse", "Interessentadresse"."Postby", "Interessentadresse"."Email1", "Interessentadresse"."Telefon_Fax", "Interessentadresse"."Type", "Interessentadresse"."Tlf1", "rekvstam"."tlfLejer", "kreditor"."Kred", "Interessentadresse"."Interessentnr" FROM  (("Rekvstam" "rekvstam" INNER JOIN "Selskab" "Selskab" ON "rekvstam"."Sel"="Selskab"."Sel") LEFT OUTER JOIN "Kreditor" "kreditor" ON "rekvstam"."Kred"="kreditor"."Kred") INNER JOIN "Interessentadresse" "Interessentadresse" ON "kreditor"."Interessentnr"="Interessentadresse"."Interessentnr" WHERE  "Interessentadresse"."Type"='K'
But it should not be necessary to include this field (which is the primary key and used in linking the report) in the sql statement,
BECAUSE it is not used in the report. So maybe this is a bug?
It has not been necessary in RDC Crystal Report or RAS Crystal Report in a classic asp envoriment.
Here is the code we use to set the reports SQL Statement)
Try
Dim conn As New SqlConnection(connString)
conn.Open()
Dim sd As New SqlDataAdapter(New SqlCommand(nySQL, conn))
Dim ds As New Data.DataSet()
Dim navn As String = report.Database.Tables.Item(0).Name
sd.Fill(ds, navn)
report.SetDataSource(ds)
conn.Close()
Catch ex As Exception
Throw
End Try

Hi Jan
I understand your problem completely but we have asked  R&D to be able to edit the SQL and they explained due to how the report Engine works it's simply not possible anymore. It would take a complete rewrite in all of our DB drivers and query dll's to be able to allow it. They did that in CR 9 when they rewrote the DB drivers and removed the SQL part of the code into separate dll's and that is when the ability was removed, it's been that way ever since.
One possibility is to get the SQL from the Report and then connect to your DB using a .NET and if the results from the SQL is less than 5K rows and not too many columns you could then set the Report data source to a Dataset.
As long as all of the field names are the same CR will run the report using this work flow.
For data larger than 5K rows, limit is due to memory resources, you could save the DS to an XML file and then set the reports data source to the XML file. We've seen 100meg XML's used so the amount of data should not be a problem, but of course there are limits to everything so test...
This should not affect performance much.
So the work flow would be:
Load the report
Get the SQL Statement
Paste it into a Dataset Query
Something like this should get you started:
//string connString = "Provider=SQLOLEDB;Data Source=MySQLServer;Database=xtreme;User ID=sa;Password=pw";
string connString = "Provider=SQLNCLI10;Server=MySQLServer;Database=xtreme;User ID=sa;Password=pw";
Detail"".""Quantity"" FROM   ""xtreme"".""dbo"".""Orders Detail"" ""Orders Detail""";
string sqlString = @"SELECT top 10*  FROM  ""xtreme"".""dbo"".""Financials"" ""Financials""";
System.Data.OleDb.OleDbConnection oleConn = new System.Data.OleDb.OleDbConnection(connString);
System.Data.OleDb.OleDbCommand cmd = oleConn.CreateCommand();
cmd.CommandText = sqlString;
System.Data.DataSet ds = new System.Data.DataSet();
OleDbDataAdapter oleAdapter = new OleDbDataAdapter(sqlString, oleConn);
//OleDbDataAdapter oleAdapter2 = new OleDbDataAdapter(sqlString2, oleConn);
DataTable dt1 = new DataTable("Financials");
//DataTable dt2 = new DataTable("Orders Detail");
oleAdapter.Fill(dt1);
//oleAdapter2.Fill(dt2);
ds.Tables.Add(dt1);
//ds.Tables.Add(dt2);
ds.WriteXml("c:\\reports\\sc2.xml", XmlWriteMode.WriteSchema);
// as long as the field names match exactly Cr has no problems setting report to a DS.
try
    rpt.SetDataSource(ds.Tables[0]); // incremtent [0] for more than 1 table.
    rpt.SetDataSource(ds);
catch (Exception ex)
    MessageBox.Show("ERROR: Schema Mismatch. Error reported by CR: " + ex.Message);
//Now check for subreport and set to same DS
foreach (CrystalDecisions.CrystalReports.Engine.Section section in rpt.ReportDefinition.Sections)
    foreach (CrystalDecisions.CrystalReports.Engine.ReportObject reportObject in section.ReportObjects)
        if (reportObject.Kind == ReportObjectKind.SubreportObject)
            CrystalDecisions.CrystalReports.Engine.SubreportObject subReport = (CrystalDecisions.CrystalReports.Engine.SubreportObject)reportObject;
            CrystalDecisions.CrystalReports.Engine.ReportDocument subDocument = subReport.OpenSubreport(subReport.SubreportName);
            subDocument.SetDataSource(ds);
And for XML it would use this part, not above I am saving the data and structure in the XML file so it should match what is in the report:
foreach (CrystalDecisions.CrystalReports.Engine.Table rptTable in rpt.Database.Tables)
    try
        rptTable.Location = btrDataFile.ToString(); // @"D:\Atest\" + rptTable.Location + ".xml";
    catch (Exception ex)
        MessageBox.Show("ERROR: " + ex.Message);
Only issue you may run into is sometimes XML does not have a direct field type and your original data source but you'll get an error if that happens which could be trapped and handled.
If you have a report that only uses 2 tables I do have code that will convert it to use a Command Object. That is the limit the engine is capable of, there is a lot of logic to be able to do this in CRD and the SDK so that is all we could get for now.
I hope that helps
Don

Similar Messages

  • Get an set the SQL statement from a report at runtime

    i know there is an opportunity to filter the records by using setRecordSelectionFormula() method...but i wondered if you can anyhow get the whole SQL statement that is in the report. i think it would be very useful for many developers to maipulate the SQL directly like you were able to using the PE-functions in the old CRPE32.DLL...
    but in CR XI the CRPE32.DLL is no longer supported. now we have to substitute these functions with the JRC but i am not sure if it provides everything we had in the CRPE32.DLL...
    after all i do not understand why the CRPE32.DLL is still delivered but not supported. in my CR XI R2 installtion i found this file signed with version 11.5.3.438
    by the way it is a question of performance...a query would be faster if you could directly query the database by changing the reports sql statement instead of allowing the report to retrieve all data and then performing the filtering.
    so please, for the next version of the JRC give us the opportunity to get an set the sql statement of a report directly!

    Not an option. crpe32 is proprietory and the SQL we generate is to complex to assume it will be done correctly. Which is why the ability was removed

  • How to use presentaion variable in the SQL statement

    Is there any special syntax to use a presentation variable in the SQL Statement?
    I am setting a presentation variable (Fscl_Qtr_Var)in the dashboard prompt.
    If i set the filter as ADD->VARIABLE->PRESENTATION, it shows the statement as 'Contract Request Fiscal Quarter is equal to / is in @{Fscl_Qtr_Var} '.
    And this works fine but when i convert this to SQL, it returns
    "Contract Request Date"."Contract Request Fiscal Quarter" = 'Fscl_Qtr_Var'
    And this does not work.It is not being set to the value in the prompt.
    I need to combine this condition with other conditions in the SQL Statement. Any help is appreciated. Thanks

    Try this: '@{Fscl_Qtr_Var}'

  • How to set Query SQL Statement parameter dynamically in Sender JDBCAdpter

    Hi All,
    I have one scenario in which we are using JDBC Sender Adapter.
    Now in this case,we need to set Query SQL Statement with a SELECT statement based on some fields.
    This SQL statement is not constant, it would need to be changed.
    Means sometimes receiver will want to execute SQL statement with these fields and sometimes they will want to execute it with different fields.
    We can create separate channels for each SQL statement but again that is not an optimum solution.
    So ,I am looking out for a way to set these parameters dynamically or set SQL statement at Runtime.
    Can you all please help me to get this?

    Shweta ,
    <i>Sometimes receiver will want to execute SQL statement dynamically</i>....
    How you will get the query dynamically? Ok Let me assume, consider they are sending the query through file, then its definitely possible. But u need BPM and also not sender JDBC receiver adapter instead, receiver JDBC adapter.
    SQL Query File ->BPM>Synchronous send [Fetch data from DB]--->Response -
    >...............
    Do u think the above design will suit's ur case!!!!
    Best regards,
    raj.

  • Display the sql statement with arguments with ojdbc14_g.jar

    Hi,
    I'd like to display the sql statements with ojdbc14_g.jar.
    So I've followed the documentation and set an OracleLog.properties file which is linked to my java program.
    The problem is the trace generated is huge and I only need the SQL requests wich are made with the arguments but I don't know how to configure that.
    Have you got a sample file which handle that ?
    I've tried that :
    oracle.jdbc.handlers=java.util.logging.ConsoleHandler
    java.util.logging.ConsoleHandler.level=CONFIG
    java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
    oracle.level=INFO
    oracle.jdbc.driver.level=OFF
    oracle.jdbc.driver.OraclePreparedStatement.level=OFF
    oracle.jdbc.pool.level=OFF
    oracle.jdbc.util.level=OFF
    oracle.sql.level=INFO
    But that doesn't display only the SQL and args :(
    Regards.

    The fact is the statement are made by ejb entities on JBoss so I don't have a way to make specific logger to display the sql order. The only thing I can do is to set the log4j org.jboss.ejb.plugins.cmp to a trace level in order to see the sql order but without the arguments.
    I tried those traces however I see stuff like that without any SQL orders :
    <<
    10:10:53,833 INFO [STDOUT] NFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:52 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:52 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:52 oracle.jdbc.driver.PhysicalConnection getDefaultFixedString
    INFO: PhysicalConnection.getDefaultFixedString() returning false
    29 nov. 2007 10:10:52 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=1, x=%)
    29 nov. 2007 10:10:52 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=2, x=VIEW_ACTION_NAMES)
    29 nov. 2007 10:10:52 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:52 oracle.jdbc.driver.T4CPreparedStatement allocateTmpByteArray
    GRAVE: oracle.jdbc.driver.T4CPreparedStatement.allocateTmpByteArray : Re-allocate byte array of size : 4000
    29 nov. 2007 10:10:52 oracle.jdbc.driver.OracleResultSetImpl close
    INFO: OracleResultSetImpl.close()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
    INFO: PhysicalConnection.getMetaData()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getCatalog
    INFO: PhysicalConnection.getCatalog()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getDefaultFixedString
    INFO: PhysicalConnection.getDefaultFixedString() returning false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=1, x=%)
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=2, x=PROCESS_TYPE_HIERARCHY)
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.T4CPreparedStatement allocateTmpByteArray
    GRAVE: oracle.jdbc.driver.T4CPreparedStatement.allocateTmpByteArray : Re-allocate byte array of size : 4000
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OracleResultSetImpl close
    INFO: OracleResultSetImpl.close()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
    INFO: PhysicalConnection.getMetaData()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
    INFO: PhysicalConnection.getMetaData()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getCatalog
    INFO: PhysicalConnection.getCatalog()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getDefaultFixedString
    INFO: PhysicalConnection.getDefaultFixedString() returning false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=1, x=%)
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=2, x=PROCESS_TYPE_HIERARCHY)
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.T4CPreparedStatement allocateTmpByteArray
    GRAVE: oracle.jdbc.driver.T4CPreparedStatement.allocateTmpByteArray : Re-allocate byte array of size : 4000
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OracleResultSetImpl close
    INFO: OracleResultSetImpl.close()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
    INFO: PhysicalConnection.getMetaData()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getCatalog
    INFO: PhysicalConnection.getCatalog()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getDefaultFixedString
    INFO: PhysicalConnection.getDefaultFixedString() returning false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=1, x=%)
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=2, x=FORM_EMBEDDED_VIEWS)
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.T4CPreparedStatement allocateTmpByteArray
    GRAVE: oracle.jdbc.driver.T4CPreparedStatement.allocateTmpByteArray : Re-allocate byte array of size : 4000
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OracleResultSetImpl close
    INFO: OracleResultSetImpl.close()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
    INFO: PhysicalConnection.getMetaData()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
    INFO: PhysicalConnection.getMetaData()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getCatalog
    INFO: PhysicalConnection.getCatalog()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getDefaultFixedString
    INFO: PhysicalConnection.getDefaultFixedString() returning false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=1, x=%)
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=2, x=FORM_EMBEDDED_VIEWS)
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.T4CPreparedStatement allocateTmpByteArray
    GRAVE: oracle.jdbc.driver.T4CPreparedStatement.allocateTmpByteArray : Re-allocate byte array of size : 4000
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OracleResultSetImpl close
    INFO: OracleResultSetImpl.close()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
    INFO: PhysicalConnection.getMetaData()
    29 nov. 20>>

  • Sqlplus - hiding the SQL statement

    When I run sqlplus to spool a report, it always prints out the original SQL statement in the report, but I only want the results. For example, the following script:
    SET PAGESIZE 0
    SET FEEDBACK OFF
    SPOOL report.log
    SELECT * FROM employees;
    SPOOL OFF
    prints out not only the results, but also the SQL statement "SELECT * FROM employees;" in the report. How do I hide the SQL statement from the report?
    Thanks.

    the set echo off will work if you run your select-script from a batch-file.
    (the batch-file call an other file with the select statement)
    ~
    pascal

  • Log for all the sql statement executed

    Hi,
    I would like to know how to see the log for all the sql statement executed starting from connection to all the database related actions.
    Is it something that i need to set it up in the driver?
    I'm using Tomcat and JDBC driver.
    Please reply.
    Thanks,
    Anjana

    Make your own.
    Calendar cal = new GregorianCalendar();
    int year = cal.get(Calendar.YEAR);
    int month = cal.get(Calendar.MONTH) + 1;
    int day = cal.get(Calendar.DAY_OF_MONTH);
    //use calendar object to get other infos such as time of query
    //append your query string
    File f  =new File ("c:\\jakarta-tomcat-3.2.4\\webapps\\ASD\\LOGS\\log" + df.format(day) + df.format(month) + year + ".txt");
                   if (! f.exists())
                        f.createNewFile();
                   FileWriter fw = new FileWriter (f, true);
                   // append new log to end of file
                   fw.write(buf.toString());
                   fw.write("\n");
                   fw.flush();
                   fw.close();
              catch (IOException ioe)
                   System.out.println(ioe.toString());

  • How could I find the SQL statement who get this message ?

    ORA-01555 caused by SQL statement below (Query Duration=11191 sec, SCN: 0x0854.723b9c32)
    ... How could I find the SQL statement who got this message ?
    Thanks, Paul

    ORA-01555 means that the UNDO/ROLLBACK space is not large enough.
    This occurs because the SELECT statement is attempting to read the UNDO, but the UNDO has been released (transactions have committed or rolled back) and reused.
    The following are SOME of the reasons I have seen this to occur:
    1) Updates in a loop, with commits happening in the same loop
    - this will mark the UNDO available quickly and quickly reuse it. Then when the SELECT wants to rebuild a block, the UNDO used to rebuild the block has been reused (solution, make the UNDO bigger)
    2) A SELECT cursor used to control a loop in which updates are performed, and a 'done' flag is marked against the current cursor record, and commits are performed at the end of each loop, prior to fetching the next record
    - same problem as above, but it hits the current process. Same solution
    3) A 'month end' activity spike occurs, and all sorts of transactions create updates. There is a report that reports the activity - amusingly it needs to start at the beginning of all the work and updates periodically by doing a huge SELECT up front. This is then used to drive a loop which attempts to get information from the various transactions that have been updated and committed. After a while, the SELECT gets an ORA-01555
    - same problem as above and same solution. Get a bigger UNDO segment.
    You say this only happens once a month. That should give a hint.
    I wouldn't bother with which SELECT statement, as much as which APPLICATIONs are being run when it happens.
    One way around this - use 10g and set the guaranteed retention period. All sorts of other things will break, by no more 1555. <g>

  • What would be the SQL statement?

    What would be the SQL statement to pull data from the current week that the data was queried, regardless of what day of the current week that you queried the data?

    WHERE Date_Col >= TRUNC(SYSDATE, 'DY')
    Note that the first day of the week depends on national settings:
    SQL> alter session set nls_territory = 'AMERICA';
    Session altered.
    SQL> SELECT TRUNC(SYSDATE, 'DY') FROM DUAL;
    TRUNC(SYS
    20-JAN-08
    SQL> alter session set nls_territory = 'GERMANY';
    Session altered.
    SQL> SELECT TRUNC(SYSDATE, 'DY') FROM DUAL;
    TRUNC(SY
    21.01.08Regards,
    Dima

  • How to Run SQL Tuning Advisor on the SQL statement with SQL_ID?

    Can you give the steps to run the SQL tuning advisor on the SQL statement with SQL_ID?
    Database version: 10g Release 2

    Hi,
    You can use either the automatic SQL tuning features that are accessible from Enterprise Manager Database Console on the "Advisor Central" page or trough SQL*PLUS using the DBMS_SQLTUNE pakage:
    -- creating the tuning task
    set serveroutput on
    declare
      l_sql_tune_task_id  varchar2(100);
    begin
      l_sql_tune_task_id := dbms_sqltune.create_tuning_task (
                              sql_id      => '<your_sql_id>',
                              scope       => dbms_sqltune.scope_comprehensive,
                              time_limit  => 60,
                              task_name   => '<your_tuning_task_name>',
                              description => 'tuning task for statement your_sql_id.');
      dbms_output.put_line('l_sql_tune_task_id: ' || l_sql_tune_task_id);
    end;
    -- executing the tuning task
    exec dbms_sqltune.execute_tuning_task(task_name => '<your_tuning_task_name>');
    -- displaying the recommendations
    set long 100000;
    set longchunksize 1000
    set pagesize 10000
    set linesize 100
    select dbms_sqltune.report_tuning_task('<your_tuning_task_name>') as recommendations from dual;For more information, take a look at link provided by Jaffy.
    Cheers
    Legatti

  • OpenSQLException - The SQL statement "INSERT INTO "KMC_SUB_RCPT"...

    Hallo,
    We have the problem that subscriptions cannot be sent. In defaultTrace I have found following entry:
    #1.5 #32B150008004002400001641000710B80004539FE52B4274#1217846116565#com.sapportals.wcm.repository.service.subscription.wcm.SubscriptionsOpenSQL#sap.com/irj#com.sapportals.wcm.repository.service.subscription.wcm.SubscriptionsOpenSQL#LI01736#118449##iscp63.isc.aok.de_LFP_399377450#LI01736#03186780621111ddb4c432b150008004#SAPEngine_Application_Thread[impl:3]_10##0#0#Fatal##Plain###Cannot unsubscribe user. Context: ResourceContext: user=LI01736, creationTime=1217846116420, locale=de. User: LI01736. ID: 50cdd784-51ac-2810-2393-ea9709f50de3. Recipient: com.sapportals.wcm.util.channels.wcm.Recipient@ce9b7f70. Step: Executing SQL INSERT. . Trying to rollback transaction.#
    #1.5 #32B150008004002400001643000710B80004539FE52B989A#1217846116586#com.sap.sql.jdbc.common.StatementAnalyzerImpl#sap.com/irj#com.sap.sql.jdbc.common.StatementAnalyzerImpl#LI01736#118449##iscp63.isc.aok.de_LFP_399377450#LI01736#03186780621111ddb4c432b150008004#SAPEngine_Application_Thread[impl:3]_10##0#0#Error#1#/System/Database/sql/jdbc/common#Java#com.sap.sql_0019##Exception of type com.sap.sql.log.OpenSQLException caught: The SQL statement "INSERT INTO "KMC_SUB_RCPT" ("ID","RECIPIENT","RCPTTYPE","UNSUBSCRIBED") VALUES ('50cdd784-51ac-2810-2393-ea9709f50de3','LI01736','0','X')" contains the semantics error[s]: - 1:27 - the column >>ID<< is undefined in the current scope
    [EXCEPTION]
    #3#com.sap.sql.log.OpenSQLException#The SQL statement "INSERT INTO "KMC_SUB_RCPT" ("ID","RECIPIENT","RCPTTYPE","UNSUBSCRIBED") VALUES ('50cdd784-51ac-2810-2393-ea9709f50de3','LI01736','0','X')" contains the semantics error[s]: - 1:27 - the column >>ID<< is undefined in the current scope
    #com.sap.sql.log.OpenSQLException: The SQL statement "INSERT INTO "KMC_SUB_RCPT" ("ID","RECIPIENT","RCPTTYPE","UNSUBSCRIBED") VALUES ('50cdd784-51ac-2810-2393-ea9709f50de3','LI01736','0','X')" contains the semantics error[s]: - 1:27 - the column >>ID<< is undefined in the current scope
         at com.sap.sql.jdbc.common.StatementAnalyzerImpl.check(StatementAnalyzerImpl.java:38)
         at com.sap.sql.jdbc.common.StatementAnalyzerImpl.preprepareStatement(StatementAnalyzerImpl.java:101)
         at com.sap.sql.jdbc.common.StatementAnalyzerImpl.preprepareStatement(StatementAnalyzerImpl.java:87)
         at com.sap.sql.jdbc.common.CommonStatementImpl.executeUpdate(CommonStatementImpl.java:159)
         at com.sap.engine.services.dbpool.wrappers.StatementWrapper.executeUpdate(StatementWrapper.java:162)
         at com.sapportals.wcm.repository.service.subscription.wcm.SubscriptionsOpenSQL$SqlCommand.executeUpdate(SubscriptionsOpenSQL.java:3834)
         at com.sapportals.wcm.repository.service.subscription.wcm.SubscriptionsOpenSQL.unsubscribe(SubscriptionsOpenSQL.java:2127)
         at com.sapportals.wcm.repository.service.subscription.wcm.SubscriptionManager.unsubscribe(SubscriptionManager.java:3226)
         at com.sapportals.wcm.repository.service.subscription.wcm.SubscriptionManager.unsubscribe(SubscriptionManager.java:3205)
         at com.sapportals.wcm.repository.service.subscription.wcm.ActionInboxItemProducer.executeItemAction(ActionInboxItemProducer.java:222)
         at com.sapportals.wcm.service.actioninbox.wcm.ActionInboxService.executeItemAction(ActionInboxService.java:610)
         at com.sapportals.wcm.service.actioninbox.wcm.ActionInboxService.executeItemActions(ActionInboxService.java:1221)
         at com.sapportals.wcm.control.actioninbox.ActionInboxDetailsControl.onClick(ActionInboxDetailsControl.java:396)
    Any Idea?
    Regards,
    Gerhard

    Statement statement = connection.createStatement();
    //createing a statement object
    String query= "INSERT INTO table......"
    output.append("\nSending query:" + connection.nativeSQL(query));
    int result = statement.executeUpdate(query);//updates database wit record
    if (result==1)
    output.append("\ninsertation successfull");
    JOptionPane.showMessageDialog(null,"Insertation successfull ",
    JOptionPane.INFORMATION_MESSAGE);
    else
    output.append("\ninsertation unsuccessfull");
    JOptionPane.showMessageDialog(null,"Insertation unsuccessfull",
    JOptionPane.WARNING_MESSAGE);
    statement.close();
    have left out the trys and catches and some other bits and pieces that i dont think ud need its the bare bones but it might help or at least give u an idea. have used this code before to do something similar.

  • Error when generating the SQL statement while running the Query

    Hello SDN Mates,
    Am using three cubes in one infoset and build a query on that. Intially it was running fine, but now am getting error generating the SQL statement. Can you please throw some light on this. Your idea would be highly appreciated.
    Thanks and Regards
    Arun S

    Hi Arun
    is there any change in the objects (Check also the consistency of infoobject ) included in infoset, just make sure those are active, open the query in designer and check if no error/warning message are present
    Thanks
    Tripple k

  • How to view the SQL statement generated during execution of the BW Query?

    Dear Experts,
    I am trying to retrieve data in a SAP BW Query from a Non-SAP system.
    I think if I am able to see the complete SQL statement that was generated when I executed the BW Query, I may be able to use it to retrieve the data.
    Do you know how and where I can see the SQL statement of a BW Query's SQL statement?
    I tried RSRT options to execute the Query but still could not find the SQL statement.
    Thanks in advance.
    Regards,
    Shunhui.

    hi
    goto rsrt
    give your query name
    select execute + debug option
    in the debug option under data manager check the check box "display SQL/BIA query
    selcet continue
    you can see the sql statement
    thanq

  • How can I set the United States as my country when opening PSE 10?

    How can I set the United States as my country when opening PSE 10 so I don't have to scroll down every time?

    Why do you have to scroll down every time? You should only see the country window the very first time you launch PSE after installing it.

  • How to pass the bind variable value to the sql statement of the LOV

    Hi,
    I am using Forms 10g builder.
    I have a text item which will be populated by a LOV when i press a button, but i have a bind variable in the SQL statement of the LOV. That bind variable should be replaced by a value which is derived from a radio group in the same data block.
    For Ex: ( )radio1 ( )radio2
    before i click on the push button, I'll select one of the radio button above,so my question is how to assign this radio group value to the bind variable in the sql statement in the LOV?
    Pl any hint is appreciated!
    Thanks
    Reddy

    The variable can be taken into account in the SELECT order contained in the Record Group used by the LOV.
    e.g. Select ... From ... Where column = :block.radio_group ...Francois

Maybe you are looking for