How to convert rows of internal table to columns of another internal table?

Hi,
Experts,
test_data.xls:
one two three four five
one two three four
one two three
one two
one
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
  EXPORTING
    FILENAME                      = 'c:/test_data.xls'
    I_BEGIN_COL                   = '1'
    I_BEGIN_ROW                   = '1'
    I_END_COL                     = '10'
    I_END_ROW                     = '10'
  TABLES
    INTERN                        = it_tab
EXCEPTIONS
   INCONSISTENT_PARAMETERS       = 1
   UPLOAD_OLE                    = 2
   OTHERS                        = 3
output:
0001 0001 one
0001 0002 two
0001 0003 three
0001 0004 four
0001 0005 five
0002 0001 one
0002 0002 two
0002 0003 three
0002 0004 four
0003 0001 one
0003 0002 two
0003 0003 three
0004 0001 one
0004 0002 two
0005 0001 one
but i want this format:
  one two three four five
one two three four
one two three
one two
one
i don't want this type of output display i want to display in ABAP report as in file format how can i achieve this post some ideas on it.
Thank U,
Shabeer ahmed.

Hi,
Use this piece of code :
parameters:  p_flname type rlgrap-filename.
  data:
         li_filecontent  type standard table of alsmex_tabline ,
         lwa_filecontent type  alsmex_tabline ,
         lv_begin_col    type i value 1,
         lv_begin_row    type i value 1,
         lv_end_col      type i value 17,
         lv_end_row      type i value 65000,
         li_fieldlist    type lvc_t_fcat,
         li_data         type ref to data,
         dy_line         type ref to data.
  field-symbols:<dyntable> type standard table,
                <fs_data> type ref to data,
                <fs_1>,
                <dyn_wa>,
                <dyn_field>.
*Transfer excel file contents to internal table
  call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    exporting
      filename                = p_flname
      i_begin_col             = lv_begin_col
      i_begin_row             = lv_begin_row
      i_end_col               = lv_end_col
      i_end_row               = lv_end_row
    tables
      intern                  = li_filecontent
    exceptions
      inconsistent_parameters = 1
      upload_ole              = 2
      error_message           = 3
      others                  = 4.
  if sy-subrc = 0.
*Creating the list of fields in the table
    perform f_create_tab_field tables li_fieldlist using 'BUKRS'      4 .
    perform f_create_tab_field tables li_fieldlist using 'ZPOC_KUNNR' 10 .
    perform f_create_tab_field tables li_fieldlist using 'RANL'       13.
    perform f_create_tab_field tables li_fieldlist using 'ZPEDAT'     10 .
    perform f_create_tab_field tables li_fieldlist using 'KWERT'      15 .
    perform f_create_tab_field tables li_fieldlist using 'BONUS'      2 .
    perform f_create_tab_field tables li_fieldlist using 'WAERS'      5 .
    perform f_create_tab_field tables li_fieldlist using 'ZVAL'       15 .
    perform f_create_tab_field tables li_fieldlist using 'ZQTY'       15 .
    perform f_create_tab_field tables li_fieldlist using 'KMEIN'      3 .
    assign li_data to <fs_data>.
*CREATING INTERNAL TABLE TO store data
    call method cl_alv_table_create=>create_dynamic_table
      exporting
        it_fieldcatalog           = li_fieldlist
      importing
        ep_table                  = <fs_data>
      exceptions
        generate_subpool_dir_full = 1
        others                    = 2.
    if sy-subrc = 0.
      assign <fs_data>->* to <fs_1>.
      assign <fs_1> to <dyntable>.
Create dynamic work area and assign to FS
      create data dy_line like line of <dyntable>.   " creating a line type of the table just created above
      assign dy_line->* to <dyn_wa>.                 " creating the work area with reference to the line type
      loop at li_filecontent into lwa_filecontent.
        assign component  lwa_filecontent-col     "accessing corresponding field in the field catalog
            of structure <dyn_wa> to <dyn_field>. "and assigning this field to a field symbol
        if sy-subrc = 0.
          <dyn_field> = lwa_filecontent-value.     " filling value for this field
        endif.
        at end of row.
          append  <dyn_wa> to <dyntable>.
          clear <dyn_wa>.
        endat.
        clear lwa_filecontent.
      endloop.
      i_input_file[] =  <dyntable>.
    endif.
  elseif sy-subrc <> 0.
    message s027 display like c_error with text-001.
    stop.
  endif.
form f_create_tab_field  tables   p_li_fieldlist structure lvc_s_fcat
                     using    p_fname
                              p_lenght.
  data:lwa_fieldlist   type lvc_s_fcat.
  lwa_fieldlist-fieldname = p_fname.
  lwa_fieldlist-intlen = p_lenght.
  append lwa_fieldlist to  p_li_fieldlist.
  clear lwa_fieldlist.
endform.                    " F_CREATE_TAB_FIELD
Regards,
Dev.

Similar Messages

  • HOW TO CONVERT STRUCTURE INTO INTERNAL TABLE

    HOW TO CONVERT STRUCTURE INTO INTERNAL TABLE

    lets declare a structure --
    data: begin of str,
          name(10),
          age(3),
          city(10),
          end of str.
    lets now convert this to an internal table itab --
    data itab like table of str.
    I hope this helps
    regards,
    -pankaj singh

  • How to convert rows into column

    Hi,
    can any one help me how to convert rows into column by pl/sql procedure.
    Thanks and Regards

    http://www.oracle.com/technology/oramag/code/tips2004/050304.html
    -- dropping the sample table if exists
    drop table rowstocol
    -- create sample table
    create table rowstocol ( name varchar2(20));
    -- Inserting rows into sample table
    insert into rowstocol values('Amit Zhankar');
    insert into rowstocol values('Piyu Yawalkar');
    insert into rowstocol values('Piyu Yawalkar');
    insert into rowstocol values('Ashish Ghelani');
    insert into rowstocol values('Aditi Zhankar');
    insert into rowstocol values('Tom Kyte');
    insert into rowstocol values('Oracle');
    -- Following query should be run to create a sql. This result sql should be run to convert rows to column.
    -- The following query uses just the tablename (whose data is to be converted) and name of the column (which is to be converted).
    -- Example taken here is table rowstocol, column name.
    SELECT cc
    FROM (select decode(rn ,1 ,'Select ',null) ||' MAX (CASE WHEN dr = '|| rownum||' THEN DECODE (rn,1, col1) END) '||
    decode(rn,maxr,' col1 from ','||'||chr(39)||','||chr(39)||'|| ') cc,rn,maxr
    from (SELECT ROWNUM rn,count(0) over() maxr FROM rowstocol) order by rn) trows
    union all
    select '(SELECT tabs.col1, DENSE_RANK () OVER (ORDER BY col1,rowid) dr,dense_rank() OVER (order by 1) rn
    FROM (SELECT NAME col1 FROM rowstocol) tabs ) group by rn' cc from dual;
    -- The result of this query will do the reqd conversion from row to column.
    -- Replace table rowstocol by your table, column name by your column.
    CC
    Select MAX (CASE WHEN dr = 1 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 2 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 3 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 4 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 5 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 6 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 7 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 8 THEN DECODE (rn,1, col1) END) col1 from
    (SELECT tabs.col1, DENSE_RANK () OVER (ORDER BY col1,rowid) dr,dense_rank() OVER (order by 1) rn
    FROM (SELECT NAME col1 FROM rowstocol) tabs ) group by rn
    Select MAX (CASE WHEN dr = 1 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 2 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 3 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 4 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 5 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 6 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 7 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 8 THEN DECODE (rn,1, col1) END) col1 from
    (SELECT tabs.col1, DENSE_RANK () OVER (ORDER BY col1,rowid) dr,dense_rank() OVER (order by 1) rn
    FROM (SELECT NAME col1 FROM rowstocol) tabs ) group by rn;
    COL1
    Aditi Zhankar,Amit Zhankar,Ashish Ghelani,Oracle,Oracle,Piyu Yawalkar,Piyu Yawalkar,Tom Kyte
    Edited by: bhooma on Jan 20, 2009 2:44 AM

  • How to convert rows into columns

    Hi,
    How to convert rows into columns of two different tables.
    These two tables have two common columns namely (shipline,pos).
    Let me know if we have any built in functions to do this.
    thank you very much .
    Edited by: 808542 on Dec 7, 2010 8:35 PM
    Edited by: 808542 on Dec 7, 2010 8:37 PM

    Have you tried this first?
    http://forums.oracle.com/forums/search.jspa?threadID=&q=row+to+column&objID=f75&dateRange=last90days&userID=&numResults=15&rankBy=10001

  • How to convert rows into columns with decode function

    Hi,
    How to convert rows into columns with the help of decode function in oracle.
    thanks and regards
    P Prakash

    say
    col1 col2
    1 10
    2 20
    3 30
    then use
    select col1,
    sum(decode(col2,10,10)) "new1"
    sum(decode(col2,20,20))"new2"
    sum(decode(col2,30,30))"new3"
    from table_name
    group by col1;
    we used sum u can use ny function if wont u have to give the column name i.e col2 name also
    so i think u got it nw
    regards

  • How to convert rows to columns in sql server 2008

    How to convert rows to columns in sql server 2008 using the GROUP BY function? (only one query allowed)

    Lookup the Pivot transformation. From BOL:
    The Pivot transformation makes a normalized data set into a less normalized
    but more compact version by pivoting the input data on a column value. For
    example, a normalized Orders data set that lists customer name, product, and quantity purchased typically has multiple rows for any customer who purchased multiple products, with each row for that customer showing order
    details for a different product. By pivoting the data set on the product column, the Pivot transformation can output a data set with a
    single row per customer. That single row lists all the purchases by the customer, with the product names shown as column names, and the quantity shown as a value in the product column. Because not every customer purchases every product, many columns may contain
    null values.
    When a dataset is pivoted, input columns perform different roles in the pivoting process. A column can participate in the following ways:
    The column is passed through unchanged to the output. Because many input rows
    can result only in one output row, the transformation copies only the first
    input value for the column.
    The column acts as the key or part of the key that identifies a set of
    records.
    The column defines the pivot. The values in this column are associated with
    columns in the pivoted dataset.
    The column contains values that are placed in the columns that the pivot
    creates.
    Paul

  • How to convert rows to columns of a table?

    I want to convert rows to columns of a table..
    Query in SQL??

    965373 wrote:
    I want to convert rows to columns of a table..
    Query in SQL??PIVOT by Frank Help for a query to add columns
    PIVOT by TomK http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:766825833740

  • How to convert from SQL Server table to Flat file (txt file)

    I need To ask question how convert from SQL Server table to Flat file txt file

    Hi
    1. Import/Export wizened
    2. Bcp utility
    3. SSIS 
    1.Import/Export Wizard
    First and very manual technique is the import wizard.  This is great for ad-hoc and just to slam it in tasks.
    In SSMS right click the database you want to import into.  Scroll to Tasks and select Import Data…
    For the data source we want out zips.txt file.  Browse for it and select it.  You should notice the wizard tries to fill in the blanks for you.  One key thing here with this file I picked is there are “ “ qualifiers.  So we need to make
    sure we add “ into the text qualifier field.   The wizard will not do this for you.
    Go through the remaining pages to view everything.  No further changes should be needed though
    Hit next after checking the pages out and select your destination.  This in our case will be DBA.dbo.zips.
    Following the destination step, go into the edit mappings section to ensure we look good on the types and counts.
    Hit next and then finish.  Once completed you will see the count of rows transferred and the success or failure rate
    Import wizard completed and you have the data!
    bcp utility
    Method two is bcp with a format file http://msdn.microsoft.com/en-us/library/ms162802.aspx
    This is probably going to win for speed on most occasions but is limited to the formatting of the file being imported.  For this file it actually works well with a small format file to show the contents and mappings to SQL Server.
    To create a format file all we really need is the type and the count of columns for the most basic files.  In our case the qualifier makes it a bit difficult but there is a trick to ignoring them.  The trick is to basically throw a field into the
    format file that will reference it but basically ignore it in the import process.
    Given that our format file in this case would appear like this
    9.0
    9
    1 SQLCHAR 0 0 """ 0 dummy1 ""
    2 SQLCHAR 0 50 "","" 1 Field1 ""
    3 SQLCHAR 0 50 "","" 2 Field2 ""
    4 SQLCHAR 0 50 "","" 3 Field3 ""
    5 SQLCHAR 0 50 ""," 4 Field4 ""
    6 SQLCHAR 0 50 "," 5 Field5 ""
    7 SQLCHAR 0 50 "," 6 Field6 ""
    8 SQLCHAR 0 50 "," 7 Field7 ""
    9 SQLCHAR 0 50 "n" 8 Field8 ""
    The bcp call would be as follows
    C:Program FilesMicrosoft SQL Server90ToolsBinn>bcp DBA..zips in “C:zips.txt” -f “c:zip_format_file.txt” -S LKFW0133 -T
    Given a successful run you should see this in command prompt after executing the statement
    Starting copy...
    1000 rows sent to SQL Server. Total sent: 1000
    1000 rows sent to SQL Server. Total sent: 2000
    1000 rows sent to SQL Server. Total sent: 3000
    1000 rows sent to SQL Server. Total sent: 4000
    1000 rows sent to SQL Server. Total sent: 5000
    1000 rows sent to SQL Server. Total sent: 6000
    1000 rows sent to SQL Server. Total sent: 7000
    1000 rows sent to SQL Server. Total sent: 8000
    1000 rows sent to SQL Server. Total sent: 9000
    1000 rows sent to SQL Server. Total sent: 10000
    1000 rows sent to SQL Server. Total sent: 11000
    1000 rows sent to SQL Server. Total sent: 12000
    1000 rows sent to SQL Server. Total sent: 13000
    1000 rows sent to SQL Server. Total sent: 14000
    1000 rows sent to SQL Server. Total sent: 15000
    1000 rows sent to SQL Server. Total sent: 16000
    1000 rows sent to SQL Server. Total sent: 17000
    1000 rows sent to SQL Server. Total sent: 18000
    1000 rows sent to SQL Server. Total sent: 19000
    1000 rows sent to SQL Server. Total sent: 20000
    1000 rows sent to SQL Server. Total sent: 21000
    1000 rows sent to SQL Server. Total sent: 22000
    1000 rows sent to SQL Server. Total sent: 23000
    1000 rows sent to SQL Server. Total sent: 24000
    1000 rows sent to SQL Server. Total sent: 25000
    1000 rows sent to SQL Server. Total sent: 26000
    1000 rows sent to SQL Server. Total sent: 27000
    1000 rows sent to SQL Server. Total sent: 28000
    1000 rows sent to SQL Server. Total sent: 29000
    bcp import completed!
    BULK INSERT
    Next, we have BULK INSERT given the same format file from bcp
    CREATE TABLE zips (
    Col1 nvarchar(50),
    Col2 nvarchar(50),
    Col3 nvarchar(50),
    Col4 nvarchar(50),
    Col5 nvarchar(50),
    Col6 nvarchar(50),
    Col7 nvarchar(50),
    Col8 nvarchar(50)
    GO
    INSERT INTO zips
    SELECT *
    FROM OPENROWSET(BULK 'C:Documents and SettingstkruegerMy Documentsblogcenzuszipcodeszips.txt',
    FORMATFILE='C:Documents and SettingstkruegerMy Documentsblogzip_format_file.txt'
    ) as t1 ;
    GO
    That was simple enough given the work on the format file that we already did.  Bulk insert isn’t as fast as bcp but gives you some freedom from within TSQL and SSMS to add functionality to the import.
    SSIS
    Next is my favorite playground in SSIS
    We can do many methods in SSIS to get data from point A, to point B.  I’ll show you data flow task and the SSIS version of BULK INSERT
    First create a new integrated services project.
    Create a new flat file connection by right clicking the connection managers area.  This will be used in both methods
    Bulk insert
    You can use format file here as well which is beneficial to moving methods around.  This essentially is calling the same processes with format file usage.  Drag over a bulk insert task and double click it to go into the editor.
    Fill in the information starting with connection.  This will populate much as the wizard did.
    Example of format file usage
    Or specify your own details
    Execute this and again, we have some data
    Data Flow method
    Bring over a data flow task and double click it to go into the data flow tab.
    Bring over a flat file source and SQL Server destination.  Edit the flat file source to use the connection manager “The file” we already created.  Connect the two once they are there
    Double click the SQL Server Destination task to open the editor.  Enter in the connection manager information and select the table to import into.
    Go into the mappings and connect the dots per say
    Typical issue of type conversions is Unicode to non-unicode.
    We fix this with a Data conversion or explicit conversion in the editor.  Data conversion tasks are usually the route I take.  Drag over a data conversation task and place it between the connection from the flat file source to the SQL Server destination.
    New look in the mappings
    And after execution…
    SqlBulkCopy Method
    Sense we’re in the SSIS package we can use that awesome “script task” to show SlqBulkCopy.  Not only fast but also handy for those really “unique” file formats we receive so often
    Bring over a script task into the control flow
    Double click the task and go to the script page.  Click the Design script to open up the code behind
    Ref.
    Ahsan Kabir Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread. http://www.aktechforum.blogspot.com/

  • How get all rows of a table with a BAPI

    Hi,
    how is it possible to get more then one row by calling a BAPI from the WD. In my Application I need the rows of a Table coming from the r/3 System. How is it possible to get all the rows after the first call? What is the logic behind it? My purpose is also to create an own BAPI.
    regards,
    Sharam
    null

    Hi,
    If I understand, you don't want display the result into a Web Dynpro Table. If so, after the execution, the result of your request is stored into the context. Then you don't really need to transfert the data from your context to an Java Array.
    But if you want to do it, here is the code :
    guess your result node called
    nodeResult
    Vector myVector = new Vector();
    for (int i = 0; i < wdContext.nodeResult().size(); i++){
       myVector.put(wdContext.nodeResult().getElementAt(i));
    I hope this will answer to your question.
    Regards

  • How to increase row height in table control?

    Hi experts,
    We have a push button in table control created using screen painter. Since this is a touch screen transaction, the default height is very small for the worker in the plant to click on a specific row, i would like to know if there is any way to increase the row height in the table control. There is no attribute in Screen painter for increasing row height in table control. I did try "import dynpro", hoping to increase the row height and export the dynpro, but that doesn't seem to have row height attributes. Any help in this regard is highly appreciated. Thanks,
    Raj

    Using a new technology means you have to recreate your screen: you may create an HTML using CL_DD_* classes (that's called "Dynamic Documents"). See [SAP Library - DD programming guide|http://help.sap.com/saphelp_nw2004s/helpdata/en/13/12284b019511d4a73e0000e83dd863/frameset.htm]. Demos are provided in SDYNAMICDOCUMENTS package. Or I think you may create web dynpro and define a CSS style to enlarge objects.
    If you don't want to create everything, maybe you can find out a workaround with GuiXT, for example creating a big button in each row (for example, with BUTTONSIZE, but don't know if it changes the height of rows but that's worth trying).
    Well, [Synactive documentation about table controls|http://www.synactive.com/docu_e/specials/tables.html] does not seem to allow that.
    Maybe you can move your question to the "scripting" forum and ask about how to do it with GuiXT...

  • How to find row changes in table

    How can we find row changes in table and i want o find out any significant change in the row information in 11g db.

    hi thanks for ur help
    but i had one more problem
    already i tried this one
    at particular time i am getting that record
    ........................ col1 col2 col3 col4 col5
    3/17/2012 11:55 AM 10 20 30 40 50
    3/17/2012 12:00 PM 0 0 0 0 0
    3/17/2012 12:05 PM 12 22 32 42 52
    see here at 12:00 PM i got the null or zero values.so instead of null values i need consecutive record means below row like 12:05 row values i need
    output is:
    .......................... col1 col2 col3 col4 col5
    3/17/2012 11:55 AM 10 20 30 40 50
    3/17/2012 12:00 PM 12 22 32 42 52
    3/17/2012 12:05 PM 12 22 32 42 52
    its very urgent plz help to me.
    Edited by: 913672 on Mar 17, 2012 6:35 AM
    Edited by: 913672 on Mar 17, 2012 6:36 AM
    Edited by: 913672 on Mar 17, 2012 6:36 AM

  • How to get row index in table?

    I will show row no in table.
    In help,I find a example and follow it,I test:
    <bc4j:column attrName="Fdesc">
    <columnHeader>
    <bc4j:sortableHeader text="rowSetProperty"/>
    </columnHeader>
    <contents>
    <bc4j:input readOnly="true">
    <boundAttribute name="text">
    <bc4j:rowSetProperty name="estimatedRowCount"/>
    </boundAttribute>
    </bc4j:input>
    </contents>
    </bc4j:column>
    It's OK! But I couldn't get current row index.
    I test:
    <bc4j:column attrName="Fdesc">
    <columnHeader>
    <bc4j:sortableHeader text="rowSetProperty"/>
    </columnHeader>
    <contents>
    <bc4j:input readOnly="true">
    <boundAttribute name="text">
    <bc4j:rowSetProperty name="currentRowIndex"/>
    </boundAttribute>
    </bc4j:input>
    </contents>
    </bc4j:column>
    It's error! How can I do?

    Thanks
    I try:
    <bc4j:column attrName="Fdesc">
    <columnHeader>
    <bc4j:sortableHeader text="Seq No"/>
    </columnHeader>
    <contents>
    <textInput readOnly="true">
    <boundAttribute name="text">
    <bc4j:rowSetIteratorProperty name="currentRowIndex"/>
    </boundAttribute>
    </textInput>
    </contents>
    </bc4j:column>
    Nothing be showed in the table cells.
    Here, I finished using Javabean:
    public class ClsRowIndexBean
    private int _counter=0; 
    public ClsRowIndexBean()
    public int getCounter()
    return _counter++;
    public int getCurrentCounter()
    return _counter;
    public void setCounter(int counter)
    _counter = counter;       
    }

  • How to convert row into column

    Hi All,
    My oracle apps version is r12 and db is 10 and i am using Bi publisher version 10g.
    Is it possible to convert row into column in Rtf template,
    My Query is
    SELECT distinct pvs.vendor_site_code,sum(aia.invoice_amount)
    FROM ap_invoices_all aia, po_vendors po, po_vendor_sites_all pvs
    WHERE aia.org_id = pvs.org_id
    AND aia.vendor_id = po.vendor_id
    AND aia.vendor_site_id = pvs.vendor_site_id
    AND aia.org_id=204
    group by pvs.vendor_site_code
    And output is like this
    Vendor sitecode Invoiceamt
    EAM-ERS 79240
    STAR GATE - PAY 3245902.31
    UPS - HQ 10792040.9
    Like this
    So in template i need the output like this
    Vendor sitecode EAM-ERS STAR GATE - PAY UPS - HQ
    Invoiceamt 79240 3245902.31 10792040.9
    I tried to achieve the output using sql query but by hardcoding only i have achieved it, so i have tried to convert directly in RTF template.
    can any one tell me is it possible.
    And if new project is added from the front end ie(now the query will produce 4 rows but now in template i have created only three columns)
    Is it possible to add a new column dynamically.
    Can any one please guide me and tell me is there any example.
    Thanks & regards
    Srikkanth

    Take a look at this post: http://blogs.oracle.com/roller-ui/bsc/spider.jsp?entry=MT%3aENTRY%3a5001
    Thanks,
    Bipuser

  • How to limit rows for a table?

    Hi,
    does anyone knows a good way to limit the number of rows for a table?
    thanks
    aldo

    You can limit the number of rows using a trigger. Below is quick and dirty example that has not been fully tested.
    test@ORCL> create table rowlimit (col1 number);
    Table created.
    Elapsed: 00:00:00.34
    test@ORCL> create or replace trigger limit_rows
      2  before insert
      3  on rowlimit
      4  declare
      5    v_count number;
      6  begin
      7     select count(*)
      8     into v_count
      9     from rowlimit;
    10
    11     if v_count >= 4 then
    12       raise_application_error(-20000, 'Table can have no more then 4 rows');
    13     end if;
    14  end;
    15  /
    Trigger created.
    Elapsed: 00:00:00.09
    test@ORCL> insert into rowlimit values(1);
    1 row created.
    Elapsed: 00:00:00.03
    test@ORCL> insert into rowlimit values(2);
    1 row created.
    Elapsed: 00:00:00.00
    test@ORCL> insert into rowlimit values(3);
    1 row created.
    Elapsed: 00:00:00.00
    test@ORCL> insert into rowlimit values(4);
    1 row created.
    Elapsed: 00:00:00.00
    test@ORCL> insert into rowlimit values(5);
    insert into rowlimit values(5)
    ERROR at line 1:
    ORA-20000: Table can have no more then 4 rows
    ORA-06512: at "TEST.LIMIT_ROWS", line 9
    ORA-04088: error during execution of trigger 'TEST.LIMIT_ROWS'
    Elapsed: 00:00:00.04
    test@ORCL> commit;
    Commit complete.
    Elapsed: 00:00:00.00
    test@ORCL> select count(*) from rowlimit;
      COUNT(*)
             4
    Elapsed: 00:00:00.00
    test@ORCL>

  • How to fetch rows from a table like search engines do?

    Is it possible to fetch rows from a table like Google does? I want to fetch row number 20-40 after the select has ordered the rows.
    Pseudo code: select * from log where rownum > 20 and rownum < 40 order by date;
    Rownum doesn't work with ordering so I tried:
    select * from log where (select * from log order by date) and rownum <20;
    But that still doesn't do what I want. I get the "top 20" rows but I can't get rows 20-40.
    My real table has 70000 rows and I want to select 69000-70000 so I really need a SQL do fetch only the rows I need.
    Any help would be very appreciated!
    Best regards,
    Christer Nordvik

    SELECT alias_for_rownum, column_names
            FROM   (SELECT ROWNUM AS alias_for_rownum, column_names
                    FROM   (SELECT   column_names
                            FROM     table_name
                            ORDER BY columns_to_order_by)
                    WHERE  ROWNUM <= last_row_you_want)
            WHERE  alias_for_rownum >= first_row_you_want
    Example:
    -- (This example uses the Oracle dept demo table.
    SET AUTOTRACE ON EXPLAIN
    SELECT rn, deptno, dname, loc
            FROM   (SELECT ROWNUM AS rn, deptno, dname, loc
                    FROM   (SELECT   deptno, dname, loc
                            FROM     dept
                            ORDER BY deptno)
                    WHERE  ROWNUM <= 3)
            WHERE  rn >= 2
                    RN     DEPTNO DNAME          LOC
                     2         20 RESEARCH       DALLAS
                     3         30 SALES          CHICAGO

Maybe you are looking for

  • How to connect 2 or 3 externadisplays to the macbook pro 15" (mid 2010, i7)

    I have a new MacbookPro (mid 2010, i7) I have 2 HP monitors (20") and a big TV (50") I am setting up a classroom. I want to display 1 screen on the TV (which is behind me) mirroring a secondary screen I have in front of me, and also have another seco

  • NPE when tabing out of inputbox

    Hi Gurus, I have an input box whose valueChange event i am calling the below method. I am getting the following error when I tab out of the component INFO : [2011-04-19 12:16:24,183] PartyAndOpportunityPageBean - in checkNumberExist() <LifecycleImpl>

  • How to run concurrent program one after another

    hi, i have three concurrent program which are inter linked. how to set to run the concurrent program one after the another, ie.. not to run simultaneously. regards Yesukannan

  • Creator using all of the CPU

    Hello, I am running Creator version 2.1 on a Windows XP Professional machine. Whenever I open the design view, the CPU usage of my machine increases to 99% which is all allocated to the java.exe process created by running Creator. I noticed the follo

  • Two iPhones not communicating together properly??!! HELP PLEASE

    my wife's iPhone is not receiving texts from me and when she sends texts to my iPhone the number it is received comes through as my own?? Very confused. Help.