Combining data from SQL query

Hoping there is a SQL guru out there that can help me with this
I have two tables that I want to pull data from and display a report, based on a particular date range, for this example let's say 08/01/2011 to 08/31/2011
In one table there would be an affiliate ID - AFF_UID and also the date and a counter for that date, IMP_COUNTER , now there may only be a few records not every day might be covered, say
TABLE IMP
date,aff_uid,imp_counter
08/01/2011,999,2000
08/02/2011,999,2050
08/20/2011,999,2030
etc
I then have another date, similar set up only there are multiple records in here for a single day, again not all days covered, I would need to total up each row for each day to get a count. So it might be:
TABLE LEAD
date,aff_uid
08/01/2011,999
08/01/2011,999
08/01/2011,999
08/01/2011,999
08/12/2011,999
So we have different dates covered, sometimes the same date, I need the counter from the first table, and from the second table I need to add them up for a total, and then display any date that has a value and put both counter and lead count together
Result from above
date,imp total,lead total
08/01/2011,2000,4
08/02/2011,2050,0
08/12,2011,0,1
08/20/2011,2030,0
I am sure there must be a SQL command that can gel all of this together with some grouping? Last thing I need is a ton of SQL statements in a loop!
My alternative is to add a counter to the IMP table for each lead, so every time I update the lead table with a record, I will also update the counter, but that's unncessary storage of data I already have an an extra update statement that I might be able to do without, but maybe it would make generating reports faster, just pulling to counters with no 'addition' required.
Appreciate any feedback
Thanks
Mark

Well I thought that I had this one up and running, but once it went into production I found that it didn't give the desired results.
I have an account that has 3 'tracking'/aff accounts, so what it's doing is giving out 3 lines for each date rather than join them together into one. The values are also incorrect, I'm still trying to figure out just where it's even getting those numbers, I manually added up the numbers in the dbase and it didn't match
Here's the command
<CFQUERY name="GetStats" DATASOURCE="#datasource#">
SELECT
COALESCE(IMP.imp_date, LEAD.lead_date) AS report_date
, COALESCE(IMP.imp_counter,0) AS imp_counter
, COALESCE(LEAD.lead_count,0) AS lead_count
, COALESCE(LEAD.lead_aff_payment,0) AS lead_aff_payment
FROM
SELECT
imp_date
, imp_counter
FROM impressions
WHERE imp_date BETWEEN #createODBCdate(form_from)# AND #createODBCdate(form_to)#
<CFIF #val(ListGetAt(form_aff_UID,1))# IS "3">
AND imp_aff_uid  IN (SELECT aff_uid FROM aff WHERE aff_master_uid = #session.aff_uid#)
<CFELSEIF #val(ListGetAt(form_aff_UID,1))# IS "2">
AND imp_aff_uid  = #val(ListGetAt(form_aff_UID,2))#
<CFELSE>
AND imp_aff_uid  IN (SELECT aff_uid FROM aff WHERE aff_sub_uid = #val(ListGetAt(form_aff_uid,2))# AND aff_master_uid = #session.aff_uid#)
</CFIF>
) AS IMP
FULL OUTER JOIN
SELECT
lead_date, COUNT(*) AS lead_count, SUM(lead_aff_payment) AS lead_aff_payment
FROM leads
WHERE lead_date BETWEEN #createODBCdate(form_from)# AND #createODBCdate(form_to)#
AND lead_data_status = 1
<CFIF #val(ListGetAt(form_aff_UID,1))# IS "3">
AND lead_aff_uid  IN (SELECT aff_uid FROM aff WHERE aff_master_uid = #session.aff_uid#)
<CFELSEIF #ListGetAt(form_aff_UID,1)# IS "2">
AND lead_aff_uid = #val(ListGetAt(form_aff_uid,2))#
<CFELSE>
AND lead_aff_uid  IN (SELECT aff_uid FROM aff WHERE aff_sub_uid = #val(ListGetAt(form_aff_uid,2))# AND aff_master_uid = #session.aff_uid#)
</CFIF>
GROUP BY lead_date
) AS LEAD
ON ( IMP.imp_date = LEAD.lead_date )
ORDER BY report_date;
</CFQUERY>
and here are the results
TRAFFIC REPORT: 01/01/2012 - 01/21/2012
All Accounts
Date
Offers
Served
Total
Leads
Revenue
  01/19/2012
249
1
$0.38       
  01/19/2012
11
1
$0.38       
  01/19/2012
30
1
$0.38       
  01/20/2012
1,006
7
$2.66       
  01/20/2012
40
7
$2.66       
  01/20/2012
1,090
7
$2.66       
  01/21/2012
582
6
$2.28       
  01/21/2012
33
6
$2.28       
  01/21/2012
515
6
$2.28       
Total
3,556
42
Sub-Total
$15.96       
Referral Revenue
$0.00       
Total
$15.96  
$15.96 is NOT correct, I need to find out whats going on there, but the other issue is look how it's duplicating the dates, it's one line for each account by the look of it
Can anybody help! This SQL command already got a little beyond me
Thanks
Mark

Similar Messages

  • How to compare result from sql query with data writen in html input tag?

    how to compare result
    from sql query with data
    writen in html input tag?
    I need to compare
    user and password in html form
    with all user and password in database
    how to do this?
    or put the resulr from sql query
    in array
    please help me?

    Hi dejani
    first get the user name and password enter by the user
    using
    String sUsername=request.getParameter("name of the textfield");
    String sPassword=request.getParameter("name of the textfield");
    after executeQuery() statement
    int exist=0;
    while(rs.next())
    String sUserId= rs.getString("username");
    String sPass_wd= rs.getString("password");
    if(sUserId.equals(sUsername) && sPass_wd.equals(sPassword))
    exist=1;
    if(exist==1)
    out.println("user exist");
    else
    out.println("not exist");

  • Report from sql query invalid date condition

    Hi, I created a Reports From SQL Query. My sql is like
    "select column1, column2
    from myschema.tablename
    where mydate > :p_date1 and mydate < :p_date2"
    I am using portal with turkish and english option. If I pass p_date paramaters 'dd-MON-yyyy' format
    (for example p_date1 = 23-MAR-2003 p_date2 = 26-APR-2003) in english mode portlet is return correct result,
    in turkish mode 'No Row Returned'. I changed my sql statement with
    "select column1, column2
    from myschema.tablename
    where to_date(mydate,'dd/mm/yyy') > to_date(:p_date1,'dd/mm/yyy') and to_date(mydate) < to_date(:p_date2,'dd/mm/yyyy')"
    and I pass p_date parameters 'dd/mm/yyyy' format (for example p_date1 = 23/03/2003 p_date2 = 26/04/2003)
    but now turkish and english mode No row returned.
    How may I write correct sql statament. My database NLS_DATE_FORMAT=DD/MM/YYYY and NLS_LANGUAGE=TURKISH.
    thanks.

    Hi,
    Try this for turkish mode:
    Case 1: the 'mydate' column has a kind of a char data type (like char, varchar or varchar2)
    and a value like '30/03/2003'
    "select column1, column2
    from myschema.tablename
    where
    to_date(mydate,'DD/MM/YYYY') > :p_date1
    and
    to_date(mydate,'DD/MM/YYYY') < :p_date2"
    Case 2: the mydate column has a date type:
    "select column1, column2
    from myschema.tablename
    where
    mydate > :p_date1
    and
    mydate < :p_date2"
    In both cases use the following parameter values:
    p_date1 = 23/03/2003
    p_date2 = 26/04/2003
    This should work
    Thanks
    Peter

  • The SQL statement is not valid - when importing data from SQL Server using a query

    Hi there,
    I am trying to import data from SQL to Power Pivot using a SQL query like below:
    SELECT Score.FieldCount, Score.Record.GetAt(0), Score.Record.GetAt(1),  Score.Record.GetAt(2),  Score.Record.GetAt(3),  Score.Record.GetAt(4)
    FROM 
    SELECT * FROM dbo.CLR1(
    dbo.CLR2('c:\FILES\Test.xml'), 
    'SELECT * FROM [dbo].[CXCustomer_Small]') Input
    ) Score
    And when I tried to validate it, it returns
    The SQL statement is not valid. A column name cannot be blank.
    I ran the above SQL statement in Management Studio and it works without problem. Any idea?
    Thanks!
    Chu
    -- Predict everything. http://www.predixionsoftware.com

    Never mind, I figured out - I need to give each column a name.
    -- Predict everything. http://www.predixionsoftware.com

  • How to aggregate data in SQL Query

    Hi,
    I have Table1 field1 and field2. Combination of these fields form the key of this table.
    Next I have Table2 with field3 and field4. field1 is the unique key for this table.
    My query is:
    select T2.field4||','||T1.field2 from T1 inner join T2 on T1.field1 = T2.field3;
    In the result I want to aggregate the data by T2.field4
    How do I that? Please help
    Thanks in advance,
    Raja

    How to aggregate data in SQL Query By using aggregate functions and group by:
    SQL> select object_type, count(*), sum(decode(status,'VALID',0,1)) inv_obs
      2  from all_objects
      3  group by object_type;
    OBJECT_TYPE                     COUNT(*)              INV_OBS
    CONSUMER GROUP                         2                    0
    INDEX PARTITION                      970                    0
    TABLE SUBPARTITION                    14                    0
    SEQUENCE                             226                    0
    SCHEDULE                               1                    0
    TABLE PARTITION                      349                    0
    PROCEDURE                             21                    0
    OPERATOR                              57                    0
    WINDOW                                 2                    0
    PACKAGE                              313                    0
    PACKAGE BODY                          13                    0
    LIBRARY                               12                    0
    PROGRAM                                9                    0
    INDEX SUBPARTITION                   406                    0
    LOB                                    1                    0
    JAVA RESOURCE                        771                    0
    XML SCHEMA                            24                    0
    JOB CLASS                              1                    0
    TRIGGER                                1                    0
    TABLE                               2880                    0
    INDEX                               4102                    0
    SYNONYM                            20755                  140
    VIEW                                3807                   72
    FUNCTION                             226                    0
    WINDOW GROUP                           1                    0
    JAVA CLASS                         16393                    0
    INDEXTYPE                             10                    0
    CLUSTER                               10                    0
    TYPE                                1246                    0
    EVALUATION CONTEXT                     1                    0

  • Query based Report (Reports From SQL Query)

    Hi All,
    I am facing a problem with a report. I need your help.
    I am creating a Report From SQL Query (Portal) with some arguments passed at runtime. I am able to view the output, if the query returns few rows ( arount 1000 rows). But for some inputs it needs to generate >15000 records, at this point the page is getting time out (i think!) and showing error page. I am able to execute query from the SQL Plus console ot using TOAD editor. Here the query is not taking more that 2 mins time to show the result.
    If i am executing from Portal i observed that, once i give the appropriate input and hit submit button a new oracle process is getting created for the query on UNIX (I am usign "TOP" command to check processes). The browser page will be shown error page after 5 minutes (i am assuming session time out!) , but on the backend the process will be executed for more than 30 mins.
    Can i increase a timeout of portal page, how i can do this?
    The data returned as a result of the query is sized more than 10 MB. Is caching this much data is possible by the browser page? is the returned data is creating any problem here.
    Please help me to find appropriate reasone for the failure?

    Can you post the URL that is giving you the page not found error ? I am not sure if I can be of much help though.
    In order to increase your chances to get a reply you should also post your question in the Portal Forum - Oracle Application Server Portal
    Edited by: Rodolfo Ferrari on Jun 16, 2009 3:49 PM

  • Getting zero-sized reply error when running report from SQL query

    Hi,
    I have a Report from SQL Query in Portal. When I select Excel in Output Format and then run the report, it works properly, but when I select HTML in Output Format, the report works if the rows returned are not so many (I've been able to display the report for up to 701 rows), but when I try selecting a value from the LOV that selects many rows, I get the following error:
    ERROR
    The requested URL could not be retrieved
    While trying to retrieve the URL: <data suppressed>
    The following error was encountered:
    Zero Sized Reply
    Squid did not receive any data for this request.
    Any ideas on how to fix this? Why does the number of rows returned affect the report this way?
    Thanks,
    Lorena

    Problem comes when any of the filter is applied in any one of the cases selected from the GUI.Do you mean that the problems only shows when you run the report in your browser via 9iAS?
    Which version are you using?
    Can you post the before report trigger?

  • Getting Zero Sized Reply error in report from SQL query

    Hi,
    I have a Report from SQL Query in Portal 3.0.9. When I select Excel in Output Format and then run the report, it works properly, but when I select HTML in Output Format, the report works if the rows returned are not so many (I've been able to display the report for up to 701 rows), but when I try selecting a value from the LOV that selects many rows, I get the following error:
    ERROR
    The requested URL could not be retrieved
    While trying to retrieve the URL: <data suppressed>
    The following error was encountered:
    Zero Sized Reply
    Squid did not receive any data for this request.
    Any ideas on how to fix this? Why does the number of rows returned affect the report this way?
    Thanks,
    Lorena

    Hi,
    I have a Report from SQL Query in Portal 3.0.9. When I select Excel in Output Format and then run the report, it works properly, but when I select HTML in Output Format, the report works if the rows returned are not so many (I've been able to display the report for up to 701 rows), but when I try selecting a value from the LOV that selects many rows, I get the following error:
    ERROR
    The requested URL could not be retrieved
    While trying to retrieve the URL: <data suppressed>
    The following error was encountered:
    Zero Sized Reply
    Squid did not receive any data for this request.
    Any ideas on how to fix this? Why does the number of rows returned affect the report this way?
    Thanks,
    Lorena

  • Width of field in Report From SQL Query

    I have created a report from SQL query with 15 columns being selected. However, no matter what column width and column type (pixel, char, percent) I enter in the column formatting tab of the report, I cannot get the report to format the column to the width I desire. It is always a fixed width. Does anyone have any suggestions?
    Thanks,
    Martin

    Hi,
    Char (used for ASCII format)
    Displays the output in the specified number of
    characters per line. For example, if you enter 20
    in Width, the report displays 20 characters of the
    column data in each line. If the number of
    characters per line exceeds the specified
    number, the remaining characters are wrapped
    to the next line.
    Pixel
    Displays the output in the specified number of
    pixels per row. For example, if you enter 10 in
    Width, the column data displays 10 pixels of
    data per line of the displayed table.
    Percent
    Displays the output in the specified percentage
    of the table. For example, if you enter 25 in
    Width, the column data displays in 25% of the
    displayed table.
    Thanks,
    Sharmila

  • Need help in Report From SQL Query

    Hi All,
    I am facing a problem with a report. I need your help.
    I am creating a Report From SQL Query (Portal) with some arguments passed at runtime. I am able to view the output, if the query returns few rows ( arount 1000 rows). But for some inputs it needs to generate >15000 records, at this point the page is getting time out (i think!) and showing error page. I am able to execute query from the SQL Plus console ot using TOAD editor. Here the query is not taking more that 2 mins time to show the result.
    If i am executing from Portal i observed that, once i give the appropriate input and hit submit button a new oracle process is getting created for the query on UNIX (I am usign "TOP" command to check processes). The browser page will be shown error page after 5 minutes (i am assuming session time out!) , but on the backend the process will be executed for more than 30 mins.
    I tried also increase the page time out in httpd.conf, but no use.
    The data returned as a result of the query is sized more than 10 MB. Is caching this much data is possible by the browser page? is the returned data is creating any problem here.
    Please help me to find appropriate reasone for the failure?

    user602513 wrote:
    Hi All,
    I am facing a problem with a report. I need your help.
    I am creating a Report From SQL Query (Portal) with some arguments passed at runtime. I am able to view the output, if the query returns few rows ( arount 1000 rows). But for some inputs it needs to generate >15000 records, at this point the page is getting time out (i think!) and showing error page. I am able to execute query from the SQL Plus console ot using TOAD editor. Here the query is not taking more that 2 mins time to show the result.
    If i am executing from Portal i observed that, once i give the appropriate input and hit submit button a new oracle process is getting created for the query on UNIX (I am usign "TOP" command to check processes). The browser page will be shown error page after 5 minutes (i am assuming session time out!) , but on the backend the process will be executed for more than 30 mins.
    I tried also increase the page time out in httpd.conf, but no use.
    The data returned as a result of the query is sized more than 10 MB. Is caching this much data is possible by the browser page? is the returned data is creating any problem here.
    Please help me to find appropriate reasone for the failure?Do you get any errors or warnings or it is just the slow speed which is the issue?
    There could be a variety of reasons for the delayed processing of this report. That includes parameter settings for that page, cache settings, network configurations, etc.
    - explore best optimization for your query;
    - evaluate portal for best performance configuration; you may follow this note (Doc ID: *438794.1* ) for ideas;
    - third: for that particular page carrying that report, you can use caching wisely. browser cache is neither decent for large files, nor practical. instead, explore the page cache settings that portal provides.
    - also look for various log files (application.log and apache logs) if you are getting any warnings reflecting on some kind of processing halt.
    - and last but not the least: if you happen to bring up a portal report with more than 10000 rows for display then think about the usage of the report. Evaluate whether that report is good/useful for anything?
    HTH
    AMN

  • Report from SQL Query -Excel format only show the first page

    Hi,
    I have some Reports from SQL Query. In the display options, I choose Excel as default format. The Excel documents only show the first page. If I choose HTML as default format, it shows every rows.
    Please advise on how to have a complete Excel document as HTML format does.
    Thanks a lot.
    Lina Han

    I beleive when you export Oracle reports to Excel it is the Data that is transferred along with Column Names.
    You cannot export the variables defined on the report.
    Hence you will not be able to export the Footer to excel. (Still looking into it will let you know if i find anything interesting)
    Regards,
    Bhushan Salgar

  • Error while exporting data from sql server to excel

    Hi,
    I am trying to export data from sql server to excel.
    The query that I used is s follows
    INSERT INTO OPENROWSET( 'Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=C:\Folder1\abc.xls','select * from [Sheet1$A1:IV65000]')
    select 
    column1,column2.... from Table1
    I get the following error message while doing so..
    String or binary data would be truncated.
    The statement has been terminated.
    One of the column's holds data more than 225 characters.
    What is the way to correct this, i want the whole data of the colum in the excel sheet.

    I haven't had great luck with the INSERT INTO OPENROWSET method.  Can you try one of the many samples from one of these 3 links?
    http://www.excel-sql-server.com/excel-sql-server-import-export-using-vba.htm#Excel%20Data%20Export%20to%20SQL%20Server%20Test%20Code 
    http://www.mssqltips.com/sqlservertip/1540/insert-update-or-delete-data-in-sql-server-from-excel/
    https://www.simple-talk.com/sql/database-administration/getting-data-between-excel-and-sql-server-using-odbc--/
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

  • To fatch the data from sql to excel ??? any idea....

    dear all,
    my problem is - i want to retrive the data from sql server to excel sheet... can any one suggest the idea what to do ???
    thanks.

    You can open two connections. One to SQL Server (you can use a thin or JDBC-ODBC bridge), the other to your Excel spreadsheet using the JDBC-ODBC bridge. You could query the SQL Server database, massage and format your data, then write it to Excel. Excel works with a very limited set of SQL. Here is a program from a post by Tim Vickers that others sounded happy to have. I'm reposting here for your convenience. I have not personally run this program, so please use it at your own risk.
    import java.sql.*;
    import java.io.*;
    import java.util.*;
    import java.text.*;
    * Name: Excel.java
    * Purpose: To demonstrate how to use ODBC and Excel to create
    * a table,
    * insert data into it, and select it back out.
    * Version: Developed using JDK 1.3, but also works with JDK
    * 1.2.2
    * Instructions:
    * 1) Create a new Excel spreadsheet
    * 2) Create a new ODBC data source that points to this
    * spreadsheet
    * a) Go to Control Panel
    * b) Open "ODBC Data sources (32-bit) (wording may be
    * slightly
    * different for different platforms)
    * c) Under "User DSN" tab, press "Add" button
    * d) Select the "Microsoft Excel Driver (*.xls)" and
    * press
    * "Finish" button
    * e) Enter "Data Source Name" of "TestExcel"
    * f) Press "Select Workbook" button
    * g) Locate and select the spreadsheet you created in
    * Step 1
    * h) Unselect the "Read Only" checkbox
    * i) Press "Ok" button
    * 3) Compile and run Excel.java
    * 4) Open Excel spreadsheet and you will find a newly
    * created
    * sheet, GOOD_DAY, with three rows of data.
    * Notes:
    * If you want to select data from a spreadsheet that was
    * NOT
    * created via JDBC-ODBC (i.e. you entered data manually
    * into
    * a spreadsheet and want to select it out), you must
    * reference
    * the sheet name as "[sheetname$]".
    * When you create the table and insert the data using
    * Java, you
    * must reference the sheet name as "sheetname".
    * Also, do not have the spreadsheet open when you are
    * running
    * the program. You can get locking conflicts.
    public class Excel {
        public Excel() {
            setDefaults();
        private static void m(String pMessage) {
            System.out.println(pMessage);
        private void setDefaults() {
            setDriver("sun.jdbc.odbc.JdbcOdbcDriver");
            setUrl("jdbc:odbc");
            // ODBC data source named "TestExcel" defined from
            Control Panel
            setDataSource("TestExcel");
            setTableName("GOOD_DAY");
        public void openDatabase() {
            String lConnectStr = getUrl()+":"+getDataSource();
            try {
                Class.forName(getDriver());
                gConnection = DriverManager.getConnection(lConnectStr);
            catch (Exception e) {
                m("openDatabase(): "+e.getMessage());
        private void closeDatabase() {
            try {
                getConnection().close();
            catch (Exception e) {
                m("closeDatabase(): "+e.getMessage());
        private void createTable() {
            m("createTable() begin");
            Statement lStat = null;
            try {
                lStat = getConnection().createStatement();
                lStat.execute("CREATE TABLE "+getTableName()+" ("
                +" ID INTEGER"
                +" ,NAME VARCHAR"
                +")");
            catch (Exception e) {
                m("createTable(): "+e.getMessage());
            m("createTable() end");
        private void doInsert() {
            m("doInsert() begin");
            Statement lStat = null;
            try {
                lStat = getConnection().createStatement();
                lStat.executeUpdate("INSERT INTO "
                +getTableName()+"(ID,NAME) VALUES
                (10,'KANGAROO')");
                lStat.executeUpdate("INSERT INTO "
                +getTableName()+"(ID,NAME) VALUES (20,'KOALA')");
                lStat.executeUpdate("INSERT INTO "
                +getTableName()+"(ID,NAME) VALUES (30,'PAUL
                HOGAN')");
                lStat.close();
            catch (Exception e) {
                m("doInsert(): "+e.getMessage());
            m("doInsert() end");
        private void doQuery() {
            m("doQuery() begin");
            try {
                Statement lStat = getConnection().createStatement();
                ResultSet lRes = lStat.executeQuery(
                "SELECT * FROM "+getTableName()
                ResultSetMetaData lMeta = lRes.getMetaData();
                // print out the column headers separated by commas
                for (int i = 1; i <= lMeta.getColumnCount(); ++i) {
                    if (i > 1)
                        System.out.print(", ");
                    String lValue = lMeta.getColumnName(i);
                    System.out.print(lValue);
                System.out.println("");
                // print out the data separated by commas
                while (lRes.next()) {
                    for (int i=1; i<=lMeta.getColumnCount(); ++i) {
                        if (i > 1)
                            System.out.print(", ");
                        String lValue = lRes.getString(i);
                        System.out.print(lValue);
                    System.out.println("");
                lRes.close();
                lStat.close();
            catch (Exception e) {
                m("doQuery(): "+e.getMessage());
            m("doQuery() end");
        private void run() {
            openDatabase();
            createTable();
            doInsert();
            doQuery();
            closeDatabase();
        public static void main(String args[]) {
            m("main() begin");
            Excel lExcel = new Excel();
            lExcel.run();
            m("main() end");
            System.exit(0);
        public void setTableName(String pValue) {
            gTableName = pValue;
        public String getTableName() {
            return(gTableName);
        public void setSql(String pValue) {
            gSql = pValue;
        public String getSql() {
            return(gSql);
        public Connection getConnection() {
            return(gConnection);
        public String getDataSource() {
            return(gDataSource);
        public void setDataSource(String pValue) {
            gDataSource = pValue;
        public void setDriver(String pValue) {
            gDriver = pValue;
        public void setUrl(String pValue) {
            gUrl = pValue;
        public String getDriver() {
            return (gDriver);
        public String getUrl() {
            return (gUrl);
        private Connection
        gConnection = null
        private String
        gDataSource = null
        ,gTableName = null
        ,gSql = null
        ,gDriver = null
        ,gUrl = null
    }

  • Slow Speed While fetching data from SQL 2008 using DoQuery.

    Hello,
    I am working for an AddOn and tried to use DoQuery for fetching data from SQL 2008 in C#.
    There are around 148 records which full fill this query condition but it takes much time to fetch the data.
    I wanna know that is there any problem in this code by which my application is getting slower.
    I used break Points and checked it, I founds that while connecting to the server it is taking time.
    Code:
    // Get an initialized SBObob object
    oSBObob = (SAPbobsCOM.SBObob)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge);
    //// Get an initialized Recordset object
    oRecordset = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
    string sqlstring = "select DocEntry,ItemCode From OWOR  where OWOR.Status='R' and DocEntry not in ( Select distinct(BaseRef) from IGE1 where IGE1.BaseRef = OWOR.DocEntry)";
    oRecordset.DoQuery(sqlstring);
    var ProductList = new BindingList<KeyValuePair<string, string>>();
    ProductList.Add(new KeyValuePair<string, string>("", "---Please Select---"));
    while (!(oRecordset.EoF))
    ProductList.Add(new KeyValuePair<string, string>(oRecordset.Fields.Item(0).Value.ToString(), oRecordset.Fields.Item(0).Value.ToString() + " ( " + oRecordset.Fields.Item(1).Value.ToString() + " ) "));
    oRecordset.MoveNext();
    cmbProductionOrder.ValueMember = "Key";
    cmbProductionOrder.DisplayMember = "Value";
    Thanks and Regards,
    Ravi Sharma

    Hi Ravi,
    your code and query look correct. But can you ellaborate a little bit.
    It seems to be a DI API program ( no UI API ) ?
    When you say "I founds that while connecting to the server it is taking time." do you mean the recordset query or the DI API connection to SBO ? The later would be "normal" since the connection can take up to 30 seconds.
    To get data it is usually better to use direct SQL connections.
    regards,
    Maik

  • How to extract incremental data from SQL server to oracle tables in ODI

    HI All,
    In my ODI sql server is install.My Source is in SQL server and my target is in Oracle.
    I need to create a interface mapping where i need to extract incremental data from sql server to oracle.
    There is a datetime(with Timestamp) field in sql server .I need to pull incremental data based on dateime.
    Example = tablename.DateTime > (select '1-jan-11' from dual) .....i am using this query but its not woking.the error is Invalid object name"dual".
    We are not going to use Incremental in IKM and LKM.
    Request you to please provide any suggestion ASAP.
    Thanks,
    Lony

    You can do that via Variable.
    In the interface mapping create a filter on Tablename.DateTime
    and put the condition like this
    Tablename.DateTime BETWEEN #VAR and in the variable use this query in refreshing tab with oracle schema
    SELECT max(start_time)||' AND '||max(END_TIME)+1 from audit_table where ETL_JOB_CODE = '20'In the package call the above variable in refresh mode and then interface.
    This way you will pass from the query between and condition date and pass to interface so that SQL Server fetches the data between those too range.
    Note:- You might need to tweak the date format so that SQL Server can understand.
    Hope this helps.

Maybe you are looking for