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>

Similar Messages

  • How to get count of rows for a table?

    Hi,
    How to get count of rows for a table and secondly, how can i have access to a particular cell in a table?
    Regards,
    Devashish

    Hi Devashish,
    WdContext.node<Your_node_name>().size() will give you the no: of rows.
    This should be the node that is bound to the table's datasource property.
    WdContext.node<Your_node_name>().get<node_name>ElementAt(index_value); will select the row at that particular index.
    You can access an attribute of a particular row as
    WdContext.node<Your_node_name>().get<node_name>ElementAt(index_value).get<attribute_name>();
    Hope this helps,
    Best Regards,
    Nibu.
    Message was edited by: Nibu Wilson

  • Multiple header rows for one table?

    Using html it's possible to set up multiple table header rows for one table but with APEX Reports I don't see how to implement this. Any ideas?
    I want to use the second header row to provide links to data for the column only (not a row). But I still want sortable columns so I want to maintain the default column header behavior too.
    Thanks,
    Linda

    Mike,
    I tried that and found that indeed the substitution string is working and shows in both debug regions I set up on each page I tested.
    I have tried this on two kinds of pages. It works correctly on standard pages with PPR report regions.
    It is not working correctly on a page based on Carl's tabbed regions with PPR reports. One click and the header disappears. This is the version I really want to get working.
    I'd like to post something but have asked twice for a space on apex.oracle.com and have yet to receive even an email acknowledging my request.
    Perhaps you can help me get a space?
    My new problem on the tabbed page where my multiple headers are working is that when I click on a link in the header, it loads that page below the tab. But if I now click on the tab again, rather than return to the original tab page, I get error "ERR-1777: Page 4042 provided no page to branch to. Please report this error to your application administrator. " This happens on both the tabbed regions pages and on the standard tabbed pages. I guess I need to provide a differently formatted url? It is currently like this -
    -----------------------"<th id="opt-details1" [a href="f?p=&APP_ID.:3001:&APP_SESSION.:::::"] View Details</a></th>" --------------[not really square brackets but I didn't know how to make this show in the forum with proper <> brackets ----------------------
    Thanks again,
    Linda 
    ---sorry for the lack of white space. It seems to happen when I post on forums on Sunday nights - all white space is removed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • What is authorization object and how to create it for a table

    Hi All,
    What is authorization object and how to create it for a table?
    Thanks

    Hi
    Authorization
    For authorization checks, there are many ways of linking authorization objects with user actions in an SAP system. The following discusses three possibilities in the context of ABAP programming.
    Authorization Check for Transactions
    You can directly link authorization objects with transaction codes. You can enter values for the fields of an authorization object in the transaction maintenance. Before the transaction is executed, the system compares these values with the values in the user master record and only starts the transaction if the appropriate authorization exists.
    Authorization Check for ABAP Programs
    For ABAP programs, the two objects S_DEVELOP (program development and program execution) and S_PROGRAM (program maintenance) exist. They contains a field P_GROUP that is connected with the program attribute authorization group. Thus, you can assign users program-specific authorizations for individual ABAP programs.
    Authorization Check in ABAP Programs
    A more sophisticated, user-programmed authorization check is possible using the Authority-Check statement. It allows you to check the entries in the user master record for specific authorization objects against any other values. Therefore, if a transaction or program is not sufficiently protected or not every user that is authorized to use the program can also execute all the actions, this statement must be used.
    AUTHORITY-CHECK OBJECT object
                            ID name1 FIELD f1
                            ID name2 FIELD f2
                            ID namen FIELD fn.
    object is the name of an authorization object. With name1, name2 ... , and so on, you must list all fields of the authorization object object. With  f1, f2 ... , and so on, you must specify the values that the system is to check against the entries in the relevant authorization of the user master record. The AUTHORITY-CHECK statement searches for the specified object in the user profile and checks the useru2019s authorizations for all values of f1, f2 ... . You can avoid checking a field name1, name2 ... by replacing FIELD f1  FIELD f2 with DUMMY.
    After the FIELD addition, you can only specify an elementary field, not a selection table. However, there are function modules available that execute the AUTHORITY-CHECK statement for all values of selection tables. The AUTHORITY-CHECK statement is supported by a statement pattern.
    Only if the user has all authorizations, is the return value sy-subrc of the AUTHORITY-CHECK statement set to 0. The most important return values are:
    ·        0: The user has an authorization for all specified values.
    ·        4: The user does not have the authorization.
    ·        8: The number of specified fields is incorrect.
    ·        12: The specified authorization object does not exist.
    A list of all possible return values is available in the ABAP keyword documentation. The content of sy-subrc has to be closely examined to ascertain the result of the authorization check and react accordingly.
    REPORT demo_authorithy_check.
    PARAMETERS pa_carr LIKE sflight-carrid.
    DATA wa_flights LIKE demo_focc.
    AT SELECTION-SCREEN.
      AUTHORITY-CHECK OBJECT 'S_CARRID'
                      ID 'CARRID' FIELD pa_carr
                      ID 'ACTVT' FIELD '03'.
      IF sy-subrc = 4.
        MESSAGE e045(sabapdocu) WITH pa_carr.
      ELSEIF sy-subrc <> 0.
        MESSAGE e184(sabapdocu) WITH text-010.
      ENDIF.
    START-OF-SELECTION.
      SELECT  carrid connid fldate seatsmax seatsocc
        FROM  sflight
        INTO  CORRESPONDING FIELDS OF wa_flights
        WHERE carrid = pa_carr.
        WRITE: / wa_flights-carrid,
                 wa_flights-connid,
                 wa_flights-fldate,
                 wa_flights-seatsmax,
                 wa_flights-seatsocc.
      ENDSELECT.
    Regards
    Hitesh

  • How to create view for xmltype table in oracle

    hi:
    Can some one help me how to create view for xmltype table in oracle?
    XMLType do not have column
    Sem

    Thank you !!
    I read it and become very hard to implement what I want to do.
    Can you give me example please?
    My main goal to create view for xmltype table is to XQuery the XML data?
    Do you have any other suggestion?
    Please help
    Ali_2

  • How to change tablespace for a table in 10g?

    Does anyone know how to change tablespace for a table (like changing tablespace for an index [alter index ... rebuild tablespace ... ])? Many thanks in advance.

    alter table tablename move tablespace newtsname;
    You need to rebuild the indexes after the move.

  • What is the maximum number of row for a table control in LabWindows/CVI ?

    I use LabWindows CVI 8.5.1 (MMI first developped in version 6.0).
    In one of our many MMI, a table control contains a list of aircraft parameters.
    We can add as many parameters (row) as we want but over 40 000 we observe a crash of the LabWindows CVI runtime.
    Our client want to inscrease the number of parameters (row) up to 200 000 !!!
    So my questions are:
    What is the real maximum number of row for the table control ?
    Is this maximum number of row different on LabWindows 2010 version ?
    Or is there an other solution ?
    Thanks

    Greetings,
    Can you clarify what you mean by "crash"? Is there an error message thrown? Is it possible that you've consumed all of the available memory?
    Please let me know.
    Thanks, James Duvall
    Product Support Engineer
    National Instruments

  • How to find rows in F table of a cube for a given request ID

    Can someone tell me how to find the rows in the F table of a cube for a given request id?

    Hi,
    Copy the Request ID number of that cube and go to manage of the cube and select contents tab, select Infocube content,
    select list of objects to be displayed with results and in that screen give Request ID at Request ID row and at bottom Max no. of Hits keep blank and execute at the top.
    this will display all the data rows loaded with that request. this is records from cube.
    from Fact table, go to SE11, give /BIC/FXXXX "XXXX" is cube name for custom cube.
    get the SID of that cube from the Cube contents as mentioned above, for field select for output along with Request ID select Request SID also.
    from SE11 give table /BIC/DXXXXXP "XXXX" is cube name for custom cube. P for Packet Dimension. here pass reqest SID in 'SID_0REQUID' and get value for DIMID.
    pass this DIMID into KEY_XXXXP, this give the fact table rows for that request DIM ID.
    hope this helps
    Regards
    Daya Sagar

  • SQL Developer - how to limit rows in output

    I want to look at a record (Select * ), but only want to view the first 10 rows, for field info. How do I limit the row output to 10 rows?

    Welcome to the forum!
    >
    I want to look at a record (Select * ), but only want to view the first 10 rows, for field info. How do I limit the row output to 10 rows?
    >
    What does that have to do with SQL Developer?
    You can limit the rows a query returns by using ROWNUM
    SELECT * FROM myTable where rownum < 11If you just need column info you can describe the table
    SQL> set serveroutput on
    SQL> desc dept
    Name                                      Null?    Type
    DEPTNO                                    NOT NULL NUMBER(2)
    DNAME                                              VARCHAR2(14)
    LOC                                                VARCHAR2(13)
    SQL>If you have SQL questions you need to post them in the SQL and PL/SQL forum
    PL/SQL

  • How to define selectedRowKeys for a table?

    Hi,
    I have a table defined in jsff page and it is not defined using searchResultsIterator. Instead it is defined using CollectionModel.
    How can I define the selectedRowKeys attribute for this table?
    Table code:
    <af:table value="#{pageFlowScope.PipeProvidesListBean.pipeProvidesCollectionModel}"
    var="row" emptyText="#{inventoryUIBundle.TABLE_EMPTY_TEXT_NO_ROWS_YET}"
    selectionListener="#{pageFlowScope.PipeProvidesListBean.providesPipeSelectionListener}"
    rowBandingInterval="0" id="t1"
    rowSelection="#{pageFlowScope.PipeProvidesListBean.rowSelection}"
    binding="#{pageFlowScope.PipeProvidesListBean.resultsTable}">
    <af:column sortProperty="id" sortable="false" headerText="#{inventoryUIBundle.ID}" id="c5">
    <af:commandLink action="summary" id="cl1" actionListener="#{bindings.openSubTaskForSummary.execute}">
    <af:setActionListener from="#{row.oid}" to="#{objectId}"/>
    <af:outputText value="#{row.id}" id="ot1"/>
    </af:commandLink>
    </af:column>
    <af:column headerText="#{inventoryUIBundle.NAME}" id="c1">
    <af:outputText value="#{row.name}" id="ot5"/>
    </af:column>
    </af:table>
    Thanks
    Ravi

    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 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 populate rows from another table in new blank rows of other table

    I have to convert an oracle form 6i to Jdeveloper application. In forms 6i we use create a cursor for other table and then populate the current table data block row using create record and assigning its values from cursor and then issuing next record until all cursor records are written in data block. After some manual editing we save the whole form and then all block records are saved as new rows in table.
    Now how to create this functionality in jdeveloper application.
    Kindly help.

    two steps-
    1. get row from first VO.iterate them - like below -
    DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
                                    DCIteratorBinding dcIteratorBindings = bindings.findIteratorBinding("ViewObj1Iterator");
                                    HSSFRow  excelrow = null;
                                            // Get all the rows of a iterator
                                            oracle.jbo.Row[] rows = dcIteratorBindings.getAllRowsInRange();
                                        int i = 0;
                                                for (oracle.jbo.Row row : rows) {
                                                                                                                    row.getAttribute(colName).toString());  // by this you can get row attribute value..
    2. inside iteration create row for VO 2 for example-
    ViewObject employee= findViewObject("EmployeeVO");
    // Create a row and fill in the columns.
    Row row = employee.createRow();
    row.setAttribute("Name", "Vinay");
    row.setAttribute("EmpId", 1);
    //Insert row in to the default row set
    employee.insertRow(row);
    Read more: http://www.techartifact.com/blogs/2012/12/creating-new-row-of-view-object-in-adf-techartifact.html#ixzz2iL978UOD
    http://www.techartifact.com/blogs/2012/12/creating-new-row-of-view-object-in-adf-techartifact.html

  • 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 extract .csv for each table

    Hi All,
    I have a query:
    select distinct 'SELECT * FROM BILL_M.'|| TABLE_NAME||';' from all_tab_columns t
    where t.owner = 'BILL_M'
    and table_name like '%DICT'
    The query return 80 table s...How can I extract these 80 table to 80 csvs?
    ANy help is appreciated.
    Regards.

    Just an example as a starting point...
    As sys user:
    CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
    GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
    /As myuser:
    CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
                                         ,p_dir IN VARCHAR2
                                         ,p_header_file IN VARCHAR2
                                         ,p_data_file IN VARCHAR2 := NULL) IS
      v_finaltxt  VARCHAR2(4000);
      v_v_val     VARCHAR2(4000);
      v_n_val     NUMBER;
      v_d_val     DATE;
      v_ret       NUMBER;
      c           NUMBER;
      d           NUMBER;
      col_cnt     INTEGER;
      f           BOOLEAN;
      rec_tab     DBMS_SQL.DESC_TAB;
      col_num     NUMBER;
      v_fh        UTL_FILE.FILE_TYPE;
      v_samefile  BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
    BEGIN
      c := DBMS_SQL.OPEN_CURSOR;
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      d := DBMS_SQL.EXECUTE(c);
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      FOR j in 1..col_cnt
      LOOP
        CASE rec_tab(j).col_type
          WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
          WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
          WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
        END CASE;
      END LOOP;
      -- This part outputs the HEADER
      v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
      FOR j in 1..col_cnt
      LOOP
        v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
      END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
      UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      IF NOT v_samefile THEN
        UTL_FILE.FCLOSE(v_fh);
      END IF;
      -- This part outputs the DATA
      IF NOT v_samefile THEN
        v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
      END IF;
      LOOP
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        EXIT WHEN v_ret = 0;
        v_finaltxt := NULL;
        FOR j in 1..col_cnt
        LOOP
          CASE rec_tab(j).col_type
            WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                        v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
            WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                        v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
            WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                        v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
          ELSE
            DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
            v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
          END CASE;
        END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
        UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      END LOOP;
      UTL_FILE.FCLOSE(v_fh);
      DBMS_SQL.CLOSE_CURSOR(c);
    END;This allows for the header row and the data to be written to seperate files if required.
    e.g.
    SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
    PL/SQL procedure successfully completed.Output.txt file contains:
    empno,ename,job,mgr,hiredate,sal,comm,deptno
    7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
    7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
    7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
    7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
    7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
    7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
    7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
    7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
    7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
    7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
    7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
    7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
    7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
    7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
    Adapt to output different datatypes and styles are required.
    You can then call that procedure for all the tables you want to extract, with appropriate filenames for each.

Maybe you are looking for