Creation of sequence and trigger for each table!!!!!!!1

Hi
I am new to trigger and Sequence field. In one of my database we have many tables with fields for specifing ID numbers. Iam planning to insert the ID field with help of a Sequence and trigger...that trigger fires by adding the sequence value from the dual table. Now the point is here we r having around *60* table with ID field. And i am planning use the above process for each table by creating sequences and trigger for each table.
Will this affects the performance of database.
Is there any other option other than the above process, I mean other than creating sequences and trigger for each table.
PLzz help to resolve this issuee......
Shiyas
Edited by: user13170361 on Jun 7, 2010 12:37 AM

Tiger, I didn't mind about your comment, but the point is try to use
select NVL(max(a) + 1,1) into i from p1_temp;This line in your trigger code and see what is happening. The problem is with your trigger. You are using group by function and you will not get no_data_found !
For more help, this is some modification of your code.
SQL> create table p1_temp (a number(10) primary key, b number(10));
Table created.
SQL> create or replace trigger trg_p1_temp
  2  before insert on p1_temp for each row
  3  declare
  4  i number(10);
  5  begin
  6  begin
  7  select NVL(max(a) + 1,1) into i from p1_temp;
  8  exception
  9  when no_data_found then
10  i := 1;
11  end;
12  :new.a := i;
13  end;
14  /
Trigger created.
SQL> insert into p1_temp(b) values (1);
1 row created.
SQL> insert into p1_temp(b) values (2);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from p1_temp;
         A          B
         1          1
         2          2
SQL> Edited by: Saubhik on Jun 7, 2010 2:30 AM

Similar Messages

  • Single Trigger for muliple tables

    Hi All,
    I have one requirement to create a trigger to populate a table (X) based on the any insert or update on few tables (A,B,C,D,E,F).
    Do I need to create trigger for each table ??. any idea of using all tables in one trigger.

    Hi,
    this is not possible.
    but you can use multiple trigger on single table
    if you can use view, then you can use INSTEAD OF Trigger on view
    for example
    CREATE OR REPLACE VIEW manager_info AS
        SELECT e.ename, e.empno, d.dept_type, d.deptno, p.prj_level,
               p.projno
            FROM   Emp_tab e, Dept_tab d, Project_tab p
            WHERE  e.empno =  d.mgr_no
            AND    d.deptno = p.resp_dept;
    CREATE OR REPLACE TRIGGER manager_info_insert
    INSTEAD OF INSERT ON manager_info
    REFERENCING NEW AS n                 -- new manager information
    FOR EACH ROW
    DECLARE
       rowcnt number;
    BEGIN
       SELECT COUNT(*) INTO rowcnt FROM Emp_tab WHERE empno = :n.empno;
       IF rowcnt = 0  THEN
           INSERT INTO Emp_tab (empno,ename) VALUES (:n.empno, :n.ename);
       ELSE
          UPDATE Emp_tab SET Emp_tab.ename = :n.ename
             WHERE Emp_tab.empno = :n.empno;
       END IF;
       SELECT COUNT(*) INTO rowcnt FROM Dept_tab WHERE deptno = :n.deptno;
       IF rowcnt = 0 THEN
          INSERT INTO Dept_tab (deptno, dept_type)
             VALUES(:n.deptno, :n.dept_type);
       ELSE
          UPDATE Dept_tab SET Dept_tab.dept_type = :n.dept_type
             WHERE Dept_tab.deptno = :n.deptno;
       END IF;
       SELECT COUNT(*) INTO rowcnt FROM Project_tab
          WHERE Project_tab.projno = :n.projno;
       IF rowcnt = 0 THEN
          INSERT INTO Project_tab (projno, prj_level)
             VALUES(:n.projno, :n.prj_level);
       ELSE
          UPDATE Project_tab SET Project_tab.prj_level = :n.prj_level
             WHERE Project_tab.projno = :n.projno;
       END IF;
    END;see more : http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_triggers.htm
    Edited by: Mahir M. Quluzade on Oct 12, 2011 9:23 AM

  • Suppress auto sequence and trigger DDL for surrogate keys?

    Is there a way to suppress trigger and sequence creation for surrogate keys when export to DDL file?
    I know most of the time the automatic sequence and trigger creation is welcome and very handy.
    However I'm migrating from an old Designer model and there only the needed sequences are created.
    They have a different name and trigger logic is custom (and  generated outside designer).
    There is a lot of package code depending on this. So I prefer to create and use different sequences.
    Is there a way to achieve this? Any tips are welcome.Create

    Hi,
    Note that generating the DDL for Oracle 12c means that it will attempt to use your Oracle 12c Physical model.  So if you normally use Oracle 10g or 11g, you will find that any details from your Oracle 10g or 11g Physical Model will not be included.  So this approach may have other implications for you.
    If you are not using Oracle 12c, there are some relevant properties on the Auto Increment tab of the Relational Model properties dialog for the Column which may help:
    Sequence Name - allows you to specify the name of the Sequence (which can be the name of a Sequence defined in the relevant Physical Model).
    Trigger Name - allows you to specify the name of a Trigger (which can be the name of a Trigger that is defined for the Table in the Physical Model).
    Generate Trigger - unsetting this will stop the Trigger being generated.
    David

  • One trigger for Multiple tables

    Hi all,
    I want write a trigger for mutiple tables.
    For Example,
    In database schema,some user update one table.I want to capture what the table and capture old value and new value.
    the above example for all insert and delete also.
    Regards
    Fame

    Hi, Fame,
    Sorry, a trigger only works on one table, so you need a separate trigger on each separate table.
    All of those triggers can call a common procedure.
    If you'd like to give a more detailed description of what you want to do, using two or three tables, then someone can give you more detailed instructions on how to do it.
    Always say which version of Oracle you're using.

  • How to create xsd's for each table in repository instead of entire repos

    Hi Gurus,
    Is there any way i could create xsd's for each table in the repository separately instead of creating single xsd file from "Export repository schema" option which creates a single xml file for the entire repository.I need to create xsd for each table in repository...
    Any Help greatly appreciated
    Thanks
    Aravind

    Open the Lookup table you want the XSD for, in Data manger
    Export it to access.( You can select all the fields you want to export to access and then check option "open Access after export")
    Now in Access, again right click the table and export it to XML.
    Provided you have .NET frame work installed on the machine where you are doing this export, you can do the following:
    Use XSD.exe from command prompt and get the XSD.
    Use the following link as a reference for XSD stuff.
    http://msdn.microsoft.com/en-us/library/x6c1kb0s(VS.71).aspx
    (OR)
    Get the whole XML of the repository and distill the whole structure for Lookups and create XSD using any standard XML editor.

  • SDDM 3.3.EA2 one xml file for each table?

    Dear Philip!
    We'd like to have xml-files for all of our tables. To be more precise one xml file for each table so we can check it in in our configuration management system (CCC Harvest)
    Is it possible to write such a transformation script and, I really believe that can be done, can you please point us in the right direction, how to do that?
    Thanks in advance
    Guenter

    Hi Gunter,
    if you want each table to be stored in separate XML file then you needn't to do anything. Each table is stored in separate file in design directory structure - foreign keys are not included, each FK is stored in separate file.
    The ID of the table is used as file name. Each table has presentation in each physical model so you'll find file with same name (table ID) in each physical model.
    Please elaborate on that if you want something else.
    Philip

  • Create Store Procedure to Count Number of records in Database for each table

    Hello,
    I have created the code which counts the number of records for each table in database. However, I want create store procedure for this code this code that when ever use execute the Store Procedure can provide the database name to execute it and as a result
    table will display number of records in each table.
    Below you will find the code its working:
    CREATE
    TABLE #TEMPCOUNT
    (TABLENAME
    NVARCHAR(128),
    RECORD_COUNT BIGINT)
    -- Creating a TEMP table
    EXEC
    sp_msforeachtable
    'insert #tempcount select ''?'', count(*) from ? with (nolock)'
    SELECT
    * FROM
    #TEMPCOUNT
    ORDER
    BY TABLENAME
    DROP
    TABLE #TEMPCOUNT
    This code need to be convert in store procedure and user can give database name when execute the procedure in order to count the records.
    Looking forward for your support.
    Thanks.
    SharePoint_Consultant_EMEA

    Something like:
    set quoted_identifier off
    go
    create procedure usp_TableCounts
    @DBName as varchar(1000)
    as
    set nocount on
    declare @SQLToExecute varchar(1000)
    CREATE TABLE #TEMPCOUNT (TABLENAME NVARCHAR(128), RECORD_COUNT BIGINT) -- Creating a TEMP table
    set @SQLToExecute = @DBName + ".dbo.sp_msforeachtable 'insert into #tempcount select ''?'', count(*) from ? with (nolock)'"
    print @SQLToExecute
    exec (@SQLToExecute)
    SELECT * FROM #TEMPCOUNT
    ORDER BY TABLENAME
    DROP TABLE #TEMPCOUNT
    GO
    Satish Kartan www.sqlfood.com

  • I have 3 i phones.  Can I have multiple accounts on one computer where it keeps the contacta and calendar for each?

    I have 3 i phones.  Can I have multiple accounts on one computer where it keeps the contacta and calendar for each?

    My daughter and I both have iphones. I created an account (not separate itunes) for her on my computer so she could sync her phone/itunes but not have it interfere with mine since we have WAY different taste in music. Creating a different computer profile should work if you have separate itunes accounts, too.
    If you all use the same itunes account, you can turn on Home Sharing. That way you can all download the same content without having to pay for it again. Not sure how or if that works with separate itunes accounts.
    Hope that helps!

  • How do we create a a main podcast category with sub-categories similar to the way many bands have subcategories and artwork for each of their albums?

    How does a content producer create a main category with sub-categories similar to the way many bands have subcategories and artwork for each of their albums?

    I think you're talking about an 'Artist Page' in which several podcasts are 'aggregated' into one iTunes Store page?  This Apple Tech note deals with the subject (scroll to the bottom of the page):
    http://www.apple.com/itunes/podcasts/creatorfaq.html
    Although your mention of albums makes me wonder whether there you are talking about albums and songs in the music Library? - podcasts don't come in albums.
    You've also asked this in another forum:
    I have created a feed for our podcasts, but they are all under one umbrella. We would like to have subcategories under one main category.
    'A feed for your podcasts' doesn't make sense - a podcast has one feed (and vice versa). Are you confusing 'episodes' with 'podcasts'? A podcast is a collection of episodes - you can't categorize the episodes separately. The category shows only on the Store page and applies to the entire podcast. The 'Artist' page may again be what you are aiming for - if not perhaps you could post an example of what someone else is doing that you would like to.

  • Is it possible to share multiple photos from iPhoto to flickr with embedded title, description and tags for each photo?

    I use iPhoto to share my photos to different sites like facebook and flickr ... with facebook it's easy since the pics don't need much details ... however, I have some trouble with Flickr, since I need to add description, titles and tags for each picture ... is there a way to do so ?!

    Titles and descriptions are not embedded into a photo until it is exported out of iPhoto with the following settings:
    So if Facebook can read those values in an image file you'll need to export as shown above and upload to FB from outside of iPhoto or import back into iPhoto and sync the new files to FB.
    OT

  • "RUNSTATS and REORGCHK for single table" in DB13

    Hello,
    Our system is ECC 6.0, SAP_BASIS is SAPKB70011.
    "RUNSTATS and REORGCHK for single table" in DB13, I found the parameter, "Parallel Jobs".
    Why there is this parameter? Can we execute parallel runstats for single table in SAP environment?
    Thank you very much and best regards,
    Takae.

    Hi Takae,
    Although this DB13 job is named '.. for single table' it can process more than 1 table if you use wildcards. And only in this case parallelism makes sense, because the job cannot parallelize the runstats for one table but only parallelizes the runstats execution for different tables. Technically this is done be creating further background jobs in the SAP system.
    Best regards
    Ralf

  • I have a form that has multiple fields but has 5 sections. I have used mail merge to insert information but I can't get Excel to recognize that I need different names and addresses for each section. Please help.

    I have a form that has multiple fields but has 5 sections. I have used mail merge to insert information but I can't get Excel to recognize that I need different names and addresses for each section. Please help.

    Thanks for your response. I do believe I have the information needed for each form on a separate line in Excel. There is a first name, middle name, last name, city, and zip column. And field is entered on a different line for all the information. I'm really stuck.

  • How to find block free space  and PCTUSED FOR THE TABLE

    HI all,
    Due to performance issues for my database , my management ask me to reset the PCTUSED and PCTFREE values , and my doubt is
    1)How to find the current PCTUSED and PCTFREE values.
    2)How to find block free space and PCTUSED FOR THE TABLE.
    Please help me out regarding this.
    Regards,
    Vamsi.

    1)version is 10.2.0.4
    2)output of query
    tablespace extent_management allocation_type segment_space_management
    SYSTEM     LOCAL     SYSTEM     MANUAL
    UNDOTBS1     LOCAL     SYSTEM     MANUAL
    SYSAUX     LOCAL     SYSTEM     AUTO
    TEMP     LOCAL     UNIFORM     MANUAL
    USERS     LOCAL     SYSTEM     AUTO
    UNDOTBS2     LOCAL     SYSTEM     MANUAL
    INS     LOCAL     SYSTEM     AUTO
    CONFTBS     LOCAL     SYSTEM     AUTO
    REINS     LOCAL     SYSTEM     AUTO
    ANALYST     LOCAL     SYSTEM     AUTO
    BI     LOCAL     SYSTEM     AUTO
    INTRFC     LOCAL     SYSTEM     AUTO
    COGNOS     LOCAL     SYSTEM     AUTO
    TS_INDX     LOCAL     SYSTEM     AUTO
    TS_CHOLAWEB     LOCAL     SYSTEM     AUTO
    TS_DASBOARD     LOCAL     SYSTEM     AUTO

  • How to find out exact labour hour and expenses for each labour attached to

    Team,
    How to find out exact labour hour and expenses for each labour attached to machine
    We are planning to go with CATS.
    But in Cats how Production Planning department get the exact labour coust
    (which includes labour accomodation building , EB etc. paying by comp)
    How to do this in CATS
    REX

    hai
    generally  the schemas are named X000  which stands for common schema  nomination
    x replaced by respective country like for india it is IN00  for US  U000etc
    it is not given according to the group of emplyees but according to the country grouping for your org units
    time schemas are country independent they work for all the countries
    regards
    nalla

  • Oracle jdbc creating a table, sequence and trigger

    I'm trying to create a table with a sequence and with a trigger for that sequence. When I do this within Oracle Express edition I have the following SQL statements. Which DO run correctly inside Oracle Express using the same user I log in with JDBC.
    CREATE table "TEST" (
    "ID" NUMBER(10) NOT NULL,
    "NAME" VARCHAR2(20),
    constraint "TEST_PK" primary key ("ID")
    CREATE sequence "TEST_SEQ"
    CREATE trigger "BI_TEST"
    before insert on "TEST"
    for each row
    begin
    if :NEW."ID" is null then
    select "TEST_SEQ".nextval into :NEW."ID" from dual;
    end if;
    end;
    So now what I do is put each of these into a List of Strings and execute 1 by one like this:
    List<String> commands = new ArrayList<String>(4);
    commands.add("Create table ...");
    commands.add("Create sequence ...");
    commands.add("Create trigger...");
    st = con.createStatement();
    for (String command : commands) {
    st.execute(command);
    etc...
    But I get an error with the trigger statement. "Error with Oracle command: ORA-00942: table or view does not exist"
    It seems to me that Oracle has not yet seen the new table at this point. or maybe my user can create tables but not triggers? If that's the case why did it work in the express application itself?
    TIA

    SproketBoy wrote:
    But I get an error with the trigger statement. "Error with Oracle command: ORA-00942: table or view does not exist"Keep in mind: Oracle is not lying to you.
    >
    It seems to me that Oracle has not yet seen the new table at this point. or maybe my user can create tables but not triggers? If that's the case why did it work in the express application itself?No, DDL commands cause an explicit commit. As soon as you invoke them, the change is permanent. If it was a rights problem, you'd get a different ORA error stating that, it won't silently fail.
    Lets not assume it is anything difficult, perhaps there is simply a typo in a name somewhere?

Maybe you are looking for

  • SAP ITS Performance issues with integration

    Hi All, We wants to know about  performance issues if  CRM and SAP ECC6 systems connected together with SAP ITS implemented ?  What are the main things to be considered or evaluated? How the above scenario can be implemented ? Thanks in advance Ramak

  • Mac pro keeps shutting down without warning

    I have a 15 inch Macpro running Mac OS X Lion, version 10.7.3. It keeps shutting down without any warning. The screen just goes black and I have to press and hold the power button for a while till a hear a sound to turn the system off. This is happen

  • Macbook to HD TV problem?!?!?

    Please, I have 2007 2.4ghz macbook, with mini dvi out. I have apple adapter that goes mini dvi to dvi, and I have cable that goes dvi to HDMI... But it is not working. when i connect it my macbook screen goes blue, wich is good, but nothing happens o

  • Itunes freezes when i connect my 160gb ipod classic

    Hi. I have a 160gb ipod classic. Tonight i tried to put some new songs onto my ipod. Everything was fine but when i took it out, all of my music had been deleted. Now when i plug my ipod into the computer itunes freezes straightaway and i can't do an

  • Error while transfering catalog items to shoping cart...

    Hi We are on SRM4.0 and ECC5.0 and Requisite BugsEye4.0. Trying to create shopping cart with descriptive items. Item is added and then select the item to check the details before ordering. Then getting following error message. URL http://xxx:1080/sap