Select data from database tables with high performance

hi all,
how to select data from different database tables with high performance.
im using for all entries instead of inner joins, even though burden on data base tables is going very high ( 90 % in se30)
hw to increase the performance.
kindly, reply.
thnks

Also Check you are not using open sql much like distict order by group by , use abap techniques on internal table to acive the same.
also Dont use select endselect.
if possible use up to n rows claus....
taht will limit the data base hits.
also dont run select in siode any loops.
i guess these are some of the trics oyu can use to avoid frequent DATA BASE HITS AND ABVOID THE DATA BASE LAOD.

Similar Messages

  • Selecting data from single table with different condition in single query

    Hi everybody...
    I have one table with col1, col2, col3, col4, col5... as columns.
    I want to select col1, col2, col3 with condition (x=y and a=b and c=d)
    I want to select col4, col5 with condition (x=y and a=b and m=n )
    in single query...
    Thanx for ur help

    Given this data set...
    SQL> select * from oddity
      2  /
          COL1       COL2       COL3       COL4       COL5 A X C M
             1          2          3          4          5 B Y   M
             1          2          3          4          5 A Y C N
             1          2          3          4          5 A Y D M
             1          2          3          4          5 A Y D N
             1          2          3          4          5 B Y D N
             1          2          3          4          5 B Y D U
    6 rows selected.
    SQL>The following query meets the requirements. Of course, the requirements as stated are incomplete. I ahave assumed that we select all five columns if C=D andM=N.
    SQL> SELECT decode(c, 'D', col1, '0') AS col1
      2         , decode(c, 'D', col2, '0') AS col2
      3         , decode(c, 'D', col3, '0') AS col3
      4          , decode(m, 'N', col4, '-8') AS col4
      5           , decode(m, 'N', col5, '-8') AS col5
      6  FROM oddity
      7  WHERE a = 'B'
      8  AND  x = 'Y'
      9  /
          COL1       COL2       COL3       COL4       COL5
             0          0          0         -8         -8
             1          2          3          4          5
             1          2          3         -8         -8
    SQL> Cheers, APC

  • How do you Select data from two tables with similar data amd merge the output together.

    I have two Tables containing Sales Data. I want to read the Table a sort by date and accumulate dollars by order date. Then I want to read the second table and accumulate these dollar amounts by date and then merge the records together so that I gave 1 row
    with amounts for type A and amounts for type b.
    Here are the tables I am looking at.
    Select Cast(J.Order_Date As Varchar(11))) As [Order Date]
              ,Sum(Case when Sales_Code like '%Comm%' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [Job Comm]
              ,Sum(Case when Sales_Code = '5-Day' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [Job Auto]
              ,Sum(Case when Sales_Code like '%Auto%" then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [Job Auto]
              ,Sum(Case when Sales_Code = '' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [Job Fixed]
              ,Sum(Case when Sales_Code = 'XX' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [SO Comm)
              ,Sum(Case when Sales_Code = 'YY' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [SO Auto)
              ,Sum(Case when Sales_Code = 'ZZ' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [SO Fixed)
    from [PRODUCTION].dbo.Job As J
    union all
    Select Cast(SH.Order_Date As Varchar(11))) As [Order Date]
              ,Sum(Case when Sales_Code like '%Comm%' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [SO Comm]
              ,Sum(Case when Sales_Code = '5-Day'     then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [SO Auto]
              ,Sum(Case when Sales_Code like '%Auto%" then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [SO Auto]
              ,Sum(Case when Sales_Code = ''          then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [SO Fixed]
              ,Sum(Case when Sales_Code = 'XX' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [Job Comm)
              ,Sum(Case when Sales_Code = 'YY' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [Job Auto)
              ,Sum(Case when Sales_Code = 'ZZ' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [Job Fixed)
    from [PRODUCTION].dbo.SO_Detail As SD
    Inner Join [PRODUCTION].dbo.SO_Header As SH
        on SD.Sales_Order = SH.Sales_Order
    Group by J.Order_Date
    Order by J.Order_Date Desc
    Looking for output like
    Order Date   Job Comm   Job AUto   Job Fixed    SO Comm  SO AUto  SO Fixed
    Mar-11-2014    100.00     250.00       50.00     200.00   300.00    400.00
    Mar-10-2014    500.00     340.00        0.00     110.00   400.00    500.00
    Mar-09-2014    600.00     333.00       56.00     210.00   500.00    300.00
    Thanks for your help
    SWProduction

    Seeing the output it looks like what you need is this
    select COALESCE(p.[Order Date],q.[Order Date]) AS [Order Date],
    COALESCE([Job Comm],0) AS [Job Comm],
    COALESCE([Job AUto],0) AS [Job AUto],COALESCE([Job Fixed],0) AS [Job Fixed],COALESCE([SO Comm],0) AS [SO Comm],COALESCE([SO AUto],0) AS [SO AUto],COALESCE([SO Fixed],0) AS [SO Fixed]
    from
    Select Cast(J.Order_Date As Varchar(11))) As [Order Date]
    ,Sum(Case when Sales_Code like '%Comm%' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [Job Comm]
    ,Sum(Case when Sales_Code = '5-Day' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [Job Auto]
    ,Sum(Case when Sales_Code like '%Auto%" then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [Job Auto]
    ,Sum(Case when Sales_Code = '' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [Job Fixed]
    ,Sum(Case when Sales_Code = 'XX' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [SO Comm)
    ,Sum(Case when Sales_Code = 'YY' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [SO Auto)
    ,Sum(Case when Sales_Code = 'ZZ' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [SO Fixed)
    from [PRODUCTION].dbo.Job As J
    )p
    full join
    Select Cast(SH.Order_Date As Varchar(11))) As [Order Date]
    ,Sum(Case when Sales_Code like '%Comm%' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [SO Comm]
    ,Sum(Case when Sales_Code = '5-Day' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [SO Auto]
    ,Sum(Case when Sales_Code like '%Auto%" then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [SO Auto]
    ,Sum(Case when Sales_Code = '' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [SO Fixed]
    ,Sum(Case when Sales_Code = 'XX' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [Job Comm)
    ,Sum(Case when Sales_Code = 'YY' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [Job Auto)
    ,Sum(Case when Sales_Code = 'ZZ' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [Job Fixed)
    from [PRODUCTION].dbo.SO_Detail As SD
    Inner Join [PRODUCTION].dbo.SO_Header As SH
    on SD.Sales_Order = SH.Sales_Order
    Group by J.Order_Date
    )q
    on p.[Order Date] = q.[Order Date]
    Order by COALESCE(p.[Order Date],q.[Order Date]) Desc
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Select max date from a table with multiple records

    I need help writing an SQL to select max date from a table with multiple records.
    Here's the scenario. There are multiple SA_IDs repeated with various EFFDT (dates). I want to retrieve the most recent effective date so that the SA_ID is unique. Looks simple, but I can't figure this out. Please help.
    SA_ID CHAR_TYPE_CD EFFDT CHAR_VAL
    0000651005 BASE 15-AUG-07 YES
    0000651005 BASE 13-NOV-09 NO
    0010973671 BASE 20-MAR-08 YES
    0010973671 BASE 18-JUN-10 NO

    Hi,
    Welcome to the forum!
    Whenever you have a question, post a little sample data in a form that people can use to re-create the problem and test their ideas.
    For example:
    CREATE TABLE     table_x
    (     sa_id          NUMBER (10)
    ,     char_type     VARCHAR2 (10)
    ,     effdt          DATE
    ,     char_val     VARCHAR2 (10)
    INSERT INTO table_x (sa_id,  char_type, effdt,                          char_val)
         VALUES     (0000651005, 'BASE',    TO_DATE ('15-AUG-2007', 'DD-MON-YYYY'), 'YES');
    INSERT INTO table_x (sa_id,  char_type, effdt,                          char_val)
         VALUES     (0000651005, 'BASE',    TO_DATE ('13-NOV-2009', 'DD-MON-YYYY'), 'NO');
    INSERT INTO table_x (sa_id,  char_type, effdt,                          char_val)
         VALUES     (0010973671, 'BASE',    TO_DATE ('20-MAR-2008', 'DD-MON-YYYY'), 'YES');
    INSERT INTO table_x (sa_id,  char_type, effdt,                          char_val)
         VALUES     (0010973671, 'BASE',    TO_DATE ('18-JUN-2010', 'DD-MON-YYYY'), 'NO');
    COMMIT;Also, post the results that you want from that data. I'm not certain, but I think you want these results:
    `    SA_ID LAST_EFFD
        651005 13-NOV-09
      10973671 18-JUN-10That is, the latest effdt for each distinct sa_id.
    Here's how to get those results:
    SELECT    sa_id
    ,         MAX (effdt)    AS last_effdt
    FROM      table_x
    GROUP BY  sa_id
    ;

  • Cartesian of data from two tables with no matching columns

    Hello,
    I was wondering – what’s the best way to create a Cartesian of data from two tables with no matching columns in such a way, so that there will be only a single SQL query generated?
    I am thinking about something like:
    for $COUNTRY in ns0: COUNTRY ()
    for $PROD in ns1:PROD()
    return <Results>
         <COUNTRY> {fn:data($COUNTRY/COUNTRY_NAME)} </COUNTRY>
         <PROD> {fn:data($PROD/PROD_NAME)} </PROD>
    </Results>
    And the expected result is combination of all COUNTRY_NAMEs with all PROD_NAMEs.
    What I’ve noticed when checking query plan is that DSP will execute two queries to have the results – one for COUNTRY_NAME and another one for PROD_NAME. Which in general results in not the best performance ;-)
    What I’ve noticed also is that when I add something like:
    where COUNTRY_NAME != PROD_NAME
    everything is ok and there is only one query created (it's red in the Query plan, but still it's ok from my pov). Still it looks to me more like a workaround, not a real best approach. I may be wrong though...
    So the question is – what’s the suggested approach for such queries?
    Thanks,
    Leszek
    Edited by xnts at 11/19/2007 10:54 AM

    Which in general results in not the best performanceI disagree. Only for two tables with very few rows, would a single sql statement give better performance.
    Suppose there are 10,000 rows in each table - the cross-product will result in 100 million rows. Sounds like a bad idea. For this reason, DSP will not push a cross-product to a database. It will get the rows from each table in separate sql statements (retrieving only 20,000 rows) and then produce the cross-product itself.
    If you want to execute sql with cross-products, you can create a sql-statement based dataservice. I recommend against doing so.

  • How to select data from a table using a date field in the where condition?

    How to select data from a table using a date field in the where condition?
    For eg:
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
                                                      and bdatu = '31129999'.
    thanks.

    Hi Ramesh,
    Specify the date format as YYYYMMDD in where condition.
    Dates are internally stored in SAP as YYYYMMDD only.
    Change your date format in WHERE condition as follows.
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
    and bdatu = <b>'99991231'.</b>
    I doubt check your data base table EQUK on this date for the existince of data.
    Otherwise, just change the conidition on BDATU like below to see all entries prior to this date.
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
    and <b> bdatu <= '99991231'.</b>
    Thanks,
    Vinay
    Thanks,
    Vinay

  • Reading Data from a Table With an Expert

    Hi all - I'm trying to write an Expert in OWB that would read data from a table and create a new table based on that information. I have the table creation part down, but how can I read data from a table with an Expert? From what I've read, Experts only deal with metadata, and there is no mechanism in Experts to actually read data in the tables. Does OraTcl work in Experts? Has anyone ever came across this problem, and if so, how did you solve it? Thanks in advance for your time! - Don

    Hi Don
    Can also use Java and JDBC from within Tcl, see the routines in this file below, take modify or whatever;
    http://blogs.oracle.com/warehousebuilder/ombora.tcl
    source <dir>\ombora.tcl
    set g_user scott
    set g_upwd zzzzzz
    set g_hostname localhost
    set g_port 1521
    set g_srvname ora111
    oraconnect $g_user $g_upwd $g_hostname:$g_port:$g_srvname
    oraselect "select * from emp" ""
    As well as dumping the results to stdout (you probably want to comment that part out and change any other part you don't like), g_res is a ResultSet object you can use to do whatever.
    Cheers
    David

  • Select data from two tables...!

    HI Experts...!
    i m a beginner user and i want to select data from two tables proj and prps.....using joins.....and internal tables i have written a code...
    SELECT prps~pspnr
           prps~objnr
           prps~psphi
           proj~ernam
           proj~erdat
           proj~pspnr
    INTO  table itab   -
    itab is internal table
    FROM prps inner join proj
    WHERE pspnr in p_no and prpspsphi = projpspnr.
    but there is error in from clause ..please help me....
    Advance thanx....

    Hi,
    check the sample code bellow above two reply will solve out your problem but one more extra line in your code pointed out bellow.
    TABLES: prps, proj.
    TYPES:  BEGIN OF ty_test,
            pspnr LIKE prps-pspnr,
            objnr LIKE prps-objnr,
            psphi LIKE prps-psphi,
            ernam LIKE proj-ernam,
            erdat LIKE proj-erdat,
            END OF ty_test.
    DATA: itab TYPE STANDARD TABLE OF ty_test WITH HEADER LINE.
    SELECT-OPTIONS: p_no FOR prps-pspnr.
    SELECT  prps~pspnr
            prps~objnr
            prps~psphi
            proj~ernam
            proj~erdat
    *        proj~pspnr " No need for this you have selected this in
    *     the first line because it is commone so you only need to select from any one
            INTO TABLE itab
    FROM prps INNER JOIN proj ON ( prps~pspnr = proj~pspnr  )
    WHERE prps~pspnr IN p_no.
    Best Regards,
    Faisal
    Edited by: Rob Burbank on Dec 24, 2009 12:24 PM

  • Extract data from database tables and download in pdf and csv

    extract data from database tables and download in pdf and csv
    hi how can i re-write my old form procedure in adf java. the procedure used to extract data from diffirent table and dowload the data in pdf and csv.am not downloading image, i what to extract data from diffirent tables in my database and download that data in pdf and csv. i would like to write this in java adf.i just what direction am not asking anyone to do my work this is my learning curve
    the form code is
    function merge_header3 return varchar2 is
    begin
         return '~FACILITY DESCRIPTION~ACCOUNT NO~BRANCH CODE~BANK REF NO.~P/P/ AMOUNT~Postal Address 1~Postal Address 2~Box Postal Code~Dep. Date~Month~BANK NAME~BRANCH NAME~ACCOUNT TYPE~DESCRIPTION~OBJECTIVE DESCRIPTION';
    end;
    procedure download_file (i_pbat integer) is
      dir varchar2(80);
      file_name1 varchar2(80);
      file_name2 varchar2(80);
      appl_code varchar2(80);
      fil1 client_text_io.file_type;
      fil2 client_text_io.file_type;
      dat varchar2(1000);
      DATA VARCHAR2(1000);
      bvspro varchar2(100);
      ssch   varchar2(100);
      bvspro_total number(20,2);
      ssch_total   number(20,2);
      grand_total  number(20,2);
      cnt    integer;
      cursor pbat is
           select *
           from sms_payment_batches
           where id = i_pbat
      cursor pay  (pb_id integer) is
           select *
           from sms_payment_vw
           where pbat_id = pb_id
           order by subsidy ASC,programme,beneficiary_name
      cursor cgref (low varchar2) is
           select *
           from cg_ref_codes
           where rv_domain ='SMS'
           and rv_low_value = low
      success boolean;     
      begin  
           set_application_property(cursor_style,'busy');
           appl_code := sms_global.ref_code('SMS','APP_CODE','SMS',0);
        dir       := sms_global.ref_code('SMS','PAY_DIR','c:\sms\batch_payments',0);
             success := webutil_file.create_directory(dir);
         if webutil_file.file_is_directory(dir) then
             null;
    --         message ('directory exists');
        else
    --                  message ('create directory ');
             success := webutil_file.create_directory(dir);
    --         if success then        message ('directory exists');    end if;
        end if;     
        for c_pbat in pbat loop
             file_name1 := dir ||'\' || appl_code||c_pbat.batch_number||'-'||to_char(c_pbat.batch_dt,'yyyymmdd')||'pay.txt';
             file_name2 := dir ||'\' || appl_code||c_pbat.batch_number||'-'||to_char(c_pbat.batch_dt,'yyyymmdd')||'merge.txt';
    --message('create files ');
    --         fil1  := client_text_io.fopen (file_name1,'W');
    --         fil2  := client_text_io.fopen (file_name2,'W');
        fil1  := client_text_io.fopen (file_name1,'W','');
        fil2  := client_text_io.fopen (file_name2,'W','');
                   dat :=                       'FROM ACCOUNT NUMBER'
                                                                ||'~'||'FROM ACCOUNT DESCRIPTION'
                                                                ||'~'||'MY STATEMENT DESCRIPTION'
                                                                ||'~'||'BENEFICIARY ACCOUNT NUMBER'
                                                                ||'~'||'BENEFICIARY SUB ACCOUNT NUMBER'        
                                                                ||'~'||'BENEFICIARY BRANCH CODE'
                                                                ||'~'||'BENEFICIARY NAME'
                                                                ||'~'||'BENEFICIARY STATEMENT DESCRIPTION'
                                                                ||'~'||'AMOUNT';
             --     client_text_io.put_line(fil1,dat);
             bvspro:= null;
             ssch  := null;
             cnt := 0;     
             dat := '~'||lpad('~',16,'~');
             for c_pay in pay(c_pbat.id) loop
    --message('cpay loop ' || cnt);              
               if bvspro is null then
                     dat := lpad('~',16,'~');
                     dat := utility.put_field(1,c_pay.programme,dat,'~');     
               client_text_io.put_line(fil2,dat);
               dat := utility.put_field(1,c_pay.subsidy,dat,'~');
               client_text_io.put_line(fil2,dat);
               dat := merge_header3;
                     client_text_io.put_line(fil2,dat);
                     bvspro := c_pay.programme;
                     ssch := c_pay.subsidy;
                     grand_total := 0;
                     bvspro_total := 0;
                     ssch_total := 0;
               end if;
               if bvspro <> c_pay.programme then
                     dat := lpad('~',16,'~');
                     dat := utility.put_field(5,ssch_total,dat,'~');
                     dat := lpad('~',16,'~');
                     dat := utility.put_field(5,bvspro_total,dat,'~');
               dat := utility.put_field(1,'Total:' || bvspro,dat,'~');
                     client_text_io.put_line(fil2,dat);
                     dat := lpad('~',16,'~');
               client_text_io.put_line(fil2,dat);
                     dat := utility.put_field(1,c_pay.programme,dat,'~');     
               client_text_io.put_line(fil2,dat);
                     bvspro := c_pay.programme;
               dat := utility.put_field(1,c_pay.subsidy,dat,'~');
               client_text_io.put_line(fil2,dat);
               dat := merge_header3;
                     client_text_io.put_line(fil2,dat);
                     bvspro := c_pay.programme;
                     ssch := c_pay.subsidy;
                     bvspro_total := 0;
                     ssch_total := 0;
                     cnt :=0;
             end if;                           
               if ssch <> c_pay.subsidy then
                     dat := lpad('~',16,'~');
                     dat := utility.put_field(5,ssch_total,dat,'~');
                     dat := lpad('~',16,'~');
               client_text_io.put_line(fil2,dat);
               dat := utility.put_field(1,c_pay.subsidy,dat,'~');
               client_text_io.put_line(fil2,dat);
               dat := merge_header3;
                     client_text_io.put_line(fil2,dat);
                     ssch := c_pay.subsidy;
                     ssch_total := 0;
                     cnt :=0;
             end if;                           
            bvspro_total := bvspro_total + c_pay.amount;
            ssch_total   := ssch_total   + c_pay.amount;              
                  grand_total  := grand_total  + c_pay.amount;              
            cnt := cnt +1;
    --message('bfore write file 2 ' );              
            client_text_io.put_line(fil2
                                   ,cnt
                            ||'~'|| c_pay.beneficiary_name
                                                                ||'~'||c_pay.BENEFICIARY_ACCOUNT_NUMBER ||''            
                                                                ||'~'||c_pay.BRANCH_CODE             ||''           
                                                                ||'~'|| c_pay.BENEFICIARY_STATEMENT_DESC            
                                                                ||'~'|| c_pay.AMOUNT                                
                            ||'~'|| c_pay.address_line1
                            ||'~'|| c_pay.address_line2
                                                    ||'~'|| c_pay.postal_code
                                                    ||'~'|| TO_CHAR(c_pay.deposit_date,'DD-Mon-YYYY')
                                                    ||'~'|| c_pay.month
                                                    ||'~'|| c_pay.bank
                                                    ||'~'|| c_pay.bank_branch
                                                    ||'~'|| c_pay.account_type
                                                    ||'~'|| c_pay.subsidy
                                                    ||'~'|| c_pay.programme)
                  DATA :=                                  c_pay.FROM_ACCOUNT_NUMBER                   
                                                                ||'~'||c_pay.FROM_ACCOUNT_DESCR                    
                                                                ||'~'||c_pay.MY_STATEMENT_DESCR                    
                                                                ||'~'||c_pay.BENEFICIARY_ACCOUNT_NUMBER
                                                                ||'~'
                                                                ||'~'||c_pay.BRANCH_CODE            
                                                                ||'~'||c_pay.BENEFICIARY_NAME                      
                                                                ||'~'||c_pay.BENEFICIARY_STATEMENT_DESC            
                                                                ||'~'||c_pay.AMOUNT;                                
            DATA := REPLACE(DATA, ',' , ' ' );
            DATA := REPLACE(DATA, '~' , ',' );
    --message (cnt ||' ' || data);       
    --message('bfore write file 1 ' );              
                  client_text_io.put_line(fil1, data);
             end loop;
    --message ('end of write');         
                 dat := lpad('~',16,'~');
                 dat := utility.put_field(6,ssch_total,dat,'~');
                 dat := lpad('~',16,'~');
           dat := utility.put_field(1,'Total:' || bvspro,dat,'~');
                 dat := utility.put_field(5,bvspro_total,dat,'~');
              client_text_io.put_line(fil2,dat);
              dat := lpad('~',16,'~');
           client_text_io.put_line(fil2,dat);
           dat := utility.put_field(1,'Grand Total:' ,dat,'~');
                 dat := utility.put_field(5,grand_total,dat,'~');
              client_text_io.put_line(fil2,dat);
             -- close file
    for i in 1..50 loop  
           if substr(i,-1) = 0 then
                 message ('flush ' || i);
           end if;                 
                  client_text_io.put_line(fil1, lpad(' ',2000));
                  client_text_io.put_line(fil2, lpad(' ',2000));
                  client_text_io.put_line(fil1, lpad(' ',2000));
                  client_text_io.put_line(fil2, lpad(' ',2000));
    end loop;
             client_text_io.fclose(fil1);
             client_text_io.fclose(fil2);
        end loop;
       set_application_property(cursor_style,'default');
        exception
             when others then
                  message(sqlcode ||' ' ||sqlerrm);
       end download_file;    i try this but this code onlydownload image not data from database tables
        public void downloadImage(FacesContext facesContext, OutputStream outputStream)
            BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
            // get an ADF attributevalue from the ADF page definitions
            AttributeBinding attr = (AttributeBinding) bindings.getControlBinding("DocumentImage");
            if (attr == null)
                return;
            // the value is a BlobDomain data type
            BlobDomain blob = (BlobDomain) attr.getInputValue();
            try
            {   // copy the data from the BlobDomain to the output stream
                IOUtils.copy(blob.getInputStream(), outputStream);
                // cloase the blob to release the recources
                blob.closeInputStream();
                // flush the output stream
                outputStream.flush();
            catch (IOException e)
                // handle errors
                e.printStackTrace();
                FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, e.getMessage(), "");
                FacesContext.getCurrentInstance().addMessage(null, msg);
            }

    You should ask your forum in the ADF-forum.

  • How to select data from cluster table

    hi experts,
                   I have a report which picks data from bseg (cluster table ) for a month report it is taking around 4 minutes to process.I feel it is not good when take the report after some months.
    how to select data from these table???how to declare itab for these cluster tables????can we include any search condition or any other kind of internal table???
    please advice.
    mani

    Hi Manikandan,
    The following code may be helpful to understand how to select the data from cluster table.
    Types: Begin of ty_kna1,
    Kunnr type kna1-kunnr,
    adrnr type kna1-adrnr,
    end of ty_kna1,
    begin of ty_bseg,
    belnr type bseg-belnr,
    kunnr type bseg-kunnr,
    end of ty_bseg,
    begin of ty_final,
    belnr type bseg-belnr,
    kunnr type kna1-kunnr,
    adrnr type kna1-adrnr,
    end of ty_final.
    Data: it_kna1 type table of ty_kna1,
    wa_kna1 type ty_kna1,
    it_bseg type table of ty_bseg,
    wa_bseg type ty_bseg,
    it_final type table of ty_final,
    wa_final type ty_final.
    Select kunnr adrnr from kna1 into table it_kna1 where....
    if sy-subrc = 0.
    select belnr kunnr into table it_bseg for all entries in it_kna1 where kunnr = it_kna1-kunnr.
    endif.
    sort it_kna1 by kunnr.
    Loop at it_bseg into wa_bseg.
    move wa_bseg-belnr to wa_final-belnr.
    read table it_kna1 into wa_kna1 with kunnr = wa_bseg-kunnr binary search.
    if sy-subrc = 0.
    move: wa_kna1-kunnr to wa_final-kunnr,
    wa_kna1-belnr to wa_final-belnr.
    endif.
    append wa_final to it_final.
    clear wa_final.
    endloop.
    Loop at it_final into wa_final.
    write: / wa_final-belnr, wa_final-kunnr, wa_final-adrnr.
    endloop.
    Reward if useful.
    Thankyou,
    Regards.

  • Error while selecting date from external table

    Hello all,
    I am getting the follwing error while selecting data from external table. Any idea why?
    SQL> CREATE TABLE SE2_EXT (SE_REF_NO VARCHAR2(255),
      2        SE_CUST_ID NUMBER(38),
      3        SE_TRAN_AMT_LCY FLOAT(126),
      4        SE_REVERSAL_MARKER VARCHAR2(255))
      5  ORGANIZATION EXTERNAL (
      6    TYPE ORACLE_LOADER
      7    DEFAULT DIRECTORY ext_tables
      8    ACCESS PARAMETERS (
      9      RECORDS DELIMITED BY NEWLINE
    10      FIELDS TERMINATED BY ','
    11      MISSING FIELD VALUES ARE NULL
    12      (
    13        country_code      CHAR(5),
    14        country_name      CHAR(50),
    15        country_language  CHAR(50)
    16      )
    17    )
    18    LOCATION ('SE2.csv')
    19  )
    20  PARALLEL 5
    21  REJECT LIMIT UNLIMITED;
    Table created.
    SQL> select * from se2_ext;
    SQL> select count(*) from se2_ext;
    select count(*) from se2_ext
    ERROR at line 1:
    ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    ORA-29400: data cartridge error
    KUP-04043: table column not found in external source: SE_REF_NO
    ORA-06512: at "SYS.ORACLE_LOADER", line 19

    It would appear that you external table definition and the external data file data do not match up. Post a few input records so someone can duplicate the problem and determine the fix.
    HTH -- Mark D Powell --

  • How to select data from a table by passing document number from another tab

    How to select data from a table by passing document number from another table.
    for eg:-
    I want to display name, adres, region from ADRC table
    by using field delivery document number
    Kind Regards,
    Shanbagavalli.S

    Hi Shanbagavalli,
    There are multiple solutions to this questions a few i will try to answer and then you can take the best required for your requirements.
    **Consider that you have a Internal table having document number from other table..
    SELECT NAME ADRES REGION FROM ADRC
           INTO IT_ADRC
           FOR ALL ENTRIES IN IT_DOC
           WHERE DOCUMENT_NO = IT_DOC-DOCUMENT_NO.
    **Consider that you have 1 document number then
    SELECT NAME ADRES REGION FROM ADRC
         INTO IT_ADRC
         WHERE DOCUMENT_NO = W_DOCUMENT_NO.
    Hope this solves your problem.
    Regards,
    Kunjal

  • Select data from DataBase

    Hi;
    I try to select data from DataBase, But I get the following error, Could anyone help? thanks.
    Exception in thread "main" java.lang.ClassNotFoundException: oracle.jdbc.driver.
    OracleDriver
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at Lookup.main(Lookup.java:12)
    import java.sql.*;
    import java.io.*;
    import java.util.*;
    public class Lookup {
        public static void main(String[] args)
            throws SQLException, ClassNotFoundException {
            String dbUrl = "jdbc:oracle:thin:@augur.scms.waikato.ac.nz:1521:comp319";
            String user = "group029";
            String password = "group029";
            // Load the driver (registers itself)
            Class.forName("oracle.jdbc.driver.OracleDriver");
            Connection c = DriverManager.getConnection(dbUrl, user, password);
            Statement s = c.createStatement();
            //SQL code:
            ResultSet r =
                s.executeQuery("SELECT * " +"FROM movie");
         StringBuffer results= new StringBuffer();
            ResultSetMetaData metaData = r.getMetaData();
         int numberOfColumns = metaData.getColumnCount();
         for(int i=1; i<=numberOfColumns; i++)
             results.append(metaData.getColumnName(i)+"\t");
         results.append("\n");
         while (r.next()){
             for( int i=1; i <=numberOfColumns; i++)
              results.append(r.getObject(i)+"\t");
             results.append("\n");
         s.close();
    }

    It's a classpath problem. Either you mistyped the class name, or you don't have the class in your classpath. I think Oracle's drivers come in db12.zip or db12.jar or some such. Whatever that jar or zip file is, it has to be in your classpath, but it's not.
    Or it is in your classpath, but you're in an appserver context where the classloader that the container provides for your app uses something other than the classpath variable. For instance, in tomcat, the jar file would be uder webapps/yourApplication/WEB-INF/lib I think.

  • Selecting data from two tables

    I am trying to select data from two tables.  The only problem that I am running into, is that i am only seeing results from my 'uploads' table.  there is also a record in documents where user = 1 that should show up.  here is my sql:
    $userIDNum = 1;
    $sql="Select *
    from uploads, documents
    WHERE uploads.user = documents.user AND uploads.user = $userIDNum
    ORDER BY uploads.title ASC, documents.title ASC";

    You'll need to explain a little more about your data and what you are trying to accomplish. Your current sql will select all columns from both the uploads and documents tables but only rows where the user id in both tables match, AND the user id equals 1. Is that not what you are seeing? Where's the code that outputs the results?

  • Select data from a table and a view: field with same content and different type

    hi all,
    I need data from a table hrp1001 and a view V_USR_NAME. What they have in common are the content of the fields SOBID and BNAME .
    It will be easier if those fields add a same type but they dont.
    Any suggestions for a workaround?
    Thanks

    Hi Ramesh,
    Specify the date format as YYYYMMDD in where condition.
    Dates are internally stored in SAP as YYYYMMDD only.
    Change your date format in WHERE condition as follows.
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
    and bdatu = <b>'99991231'.</b>
    I doubt check your data base table EQUK on this date for the existince of data.
    Otherwise, just change the conidition on BDATU like below to see all entries prior to this date.
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
    and <b> bdatu <= '99991231'.</b>
    Thanks,
    Vinay
    Thanks,
    Vinay

Maybe you are looking for

  • Error while activationg BI content for BI admin cockoit for data sources

    Hi all, I am doing BI content activation for BI admin cockpit, from SPRO -- Activation of BI content of BI admin cockpit , i ran the activation but it got failed. The error message says: DataSource 0TCTBWOBJCT_ATTR from source system BWQCLNT500 could

  • XI CRM Scenario

    Can anyone please tell me how to do CRM-XI scenario? Regards, N.S

  • Unicode issue for keyword SEARCH

    Hi All... In a report keyword SEARCH is used to find entry in internal table. basically this will find any value in internal table and will return sy-tabix as line number where the value exists. Syntax:     SEARCH itab FOR seek. where itab is interna

  • ABAP error in virtual characteristics & key-figures BADI

    Hi experts, I created a BADI for feeding a virtual characteristicand when I launch the query, this message appears: Subroutine call failed: The index specified had the value 6.288, which was either too large or too small An exception with the type CX

  • How to configure number of concurrent iTunes downloads?

    You know, I never realized just how lucky I was to have access to broadband internet in the US. Now that I am traveling abroad I see that the rest of the world has no idea what true broadband speeds really are. Case in point, Jakarta, Indonesia. Thei