Creating triggers

Hai
I need a solution for creating the trigger ..
the problem goes like this..
i have a table with the fields
fld1 fld2 fld3
the fld1 is a primary key.
here in this table i am inserting the values ..
the resultant is
fld1 fld2 fld3
S001 SAM & CO 56432
here the fld1 should be the combination of
fld1 = first letter of the fld2 + a sequence
can any one help me how to write the trigger for this prblem
thanx
gaya3

Here's an example:
create or replace trigger t_test_trig
before insert on your_table
for each row
begin
   select substr(:new.fld2,1,1)||to_char(test_seq.nextval) into :new.fld1 from dual;
end;

Similar Messages

  • Workflow event bus1022-created triggered twice with ME21Nu200F

    Hi everybody
    The explanation to my problem is as follow: Initially I was using the Tcode AS01, ME21N, ABUMN to create fixed assets and every asset created triggers the event BUS1022-CREATED, but then I set the system to synchronizing assets with equipments (SPRO -> Financial accounting->Assets accounting->Master Data->Automatic creation of equipment master recordsu2026u2026) but the event BUS1022-CREATED didn´t triggered any more so I create the new entry in SWEC with ANLA as objet of modification and the OBJ BUS1022 and the event CREATED for the creation for any new record; It works but now the problem is that this event  is being created twice with the Tcode ME21N.
    Any suggestion?
    Thanks a lot.
    Felipe Uribe

    Hello Felipe,
    a check on the TCode during the event coupling seems to be the most effective way here. However, only checking on sy-tcode will not help you much, as you don't know the source (change document / application event).
    So what you need to round up your work-around is a flag in the event container that tells you, if the event was created through the SWEC, and if yes, by which transaction code.
    - To do so, create a subtype of BUS1022 with a system wide delegation.
    - Create two new additional event parameters: TransactionCode  (type syst-tcode) and ByChangeDocument  (type boole-boole)
    - Create a function module Z_SWEC_CONTAINER_BUS1022 copied from SWE_CD_TEMPLATE_CONTAINER_FB (or SWE_CD_TEMPLATE_CONTAINER_FB_2 depending on your ABAP OO experiences) and enter this function module under "Event container" in the maintenance entry of SWEC/BUS1022/CREATED
    - Within that event container function module, you just set the two event container elements using the value of SY-TCODE for the field TransactionCode and a fixed 'X' for the value of the field ByChangeDocument
    - Create a new check function module (or workflow start condition) -- as described earlier in this thread -- that checks on:
    ( ByChangeDocument = 'X' AND TransactionCode = 'ME21N' ) OR ( ByChangeDocument = ' ' ).
    This way you'll sort out the doubled events through the change document for all other transactions than ME21N.
    Good luck,
    Florin

  • Giving error of insufficient privileges while creating triggers

    Hi all,
    I am facing the problem of insuffcient privilege on base tables while creating triggers. I have three schemas say A, B, C in my database.
    Base tables are in schema A. I have given all the grants on base table to schema B and C.
    grant all on base_table_name to B;
    grant all on base_table_name to C;
    I have created synonym also on that base table.
    And i m creating triggers in schema B.
    When i execute the query for trigger the it giving following error :
    +AFTER INSERT OR UPDATE OR DELETE ON BASE_TBALE_NAME                                      *+
    ERROR at line 3:
    ORA-01031: insufficient privileges
    even i have checked in dba_tab_privs for that base_table.....it is showing all the grants to USER B and C.
    What should I do now?
    please suggest.......
    Regards,
    Andy.

    Hi karan,
    You are right. While searching docs i got the solution of my problem.
    Privileges Required to Use Triggers
    To create a trigger in your schema:
    +•You must have the CREATE TRIGGER system privilege+
    +•One of the following must be true:+
    +◦You own the table specified in the triggering statement+
    +◦You have the ALTER privilege for the table specified in the triggering statement+
    +◦You have the ALTER ANY TABLE system privilege+
    To create a trigger in another schema, or to reference a table in another schema from a trigger in your schema:
    +•You must have the CREATE ANY TRIGGER system privilege.+
    +•You must have the EXECUTE privilege on the referenced subprograms or packages.+
    To create a trigger on the database, you must have the ADMINISTER DATABASE TRIGGER privilege. If this privilege is later revoked, you can drop the trigger but not alter it.
    The object privileges to the schema objects referenced in the trigger body must be granted to the trigger owner explicitly (not through a role). The statements in the trigger body operate under the privilege domain of the trigger owner, not the privilege domain of the user issuing the triggering statement (this is similar to the privilege model for stored subprograms).
    I have to grant only create any trigger to user.
    Problem solved.
    Thanks to all for ur help.
    Regards,
    Andy.

  • Create triggers?

    Does Oracle TimesTen support creating triggers?

    No, not currently. What TimesTen does have is a high performance post-commit event notification API called XLA. Check it out in the documentation; it might meet your requirements.
    Chris

  • The ideal knowledge of creating triggers in form

    its very easy to design a form but the matters is creating triggers so since i am a beginner i need ur guidance how to create triggers in form

    Hi,
    There are 3 types of triggers Form Level, Block Level and Item level triggers.
    First you have to decide which level you are going to create a trigger.
    Suppose you need to create Item level trigger, for a push button there is a trigger called When-Button-Presed. Like wise for each item,block and form has specific/general triggers for each event.
    you should check forms documentation or fellow online help/examples
    http://www.oracle.com/webapps/online-help/forms/10g/state?navSetId=_&navId=3&vtTopicFile=designing_forms/trig/dg0701.html&vtTopicId=
    Nilaksha.

  • Creating triggers in a package

    Does any body has an example on how to create triggers in package/package body.
    Here is an example of one of many triggers that I need to create in a package.
    CREATE OR REPLACE TRIGGER distributor_q_i
    BEFORE INSERT ON f_sw.WQM001Q000001
    FOR EACH ROW
    DECLARE
    lv_sql_error_code PLS_INTEGER;
    lv_sql_error_message VARCHAR2(512);--Maximum SQL error message size:512
    BEGIN
    INSERT INTO [email protected]
    (F_PRITIME, F_STATUS, F_DELAY, F_TIMEOUT, F_USERID,
    F_GROUPID, UF000, UF001, UF002, UF003, UF004, UF005,
    UF006,SYS_CREATED_DATE, SYS_STATUS_DATE,
    SYS_STATUS_PREV,SYS_USER_NAME, SYS_USER_IP )
    VALUES (:new.f_pritime,:new.f_status,:new.f_delay,:new.f_timeout,
    :new.f_userid,:new.f_groupid,:new.uf000,:new.uf001,
    :new.uf002,:new.uf003,:new.uf004,:new.uf005,
    :new.uf006,SYSDATE, SYSDATE, null, USER, null);
    EXCEPTION
    WHEN OTHERS THEN
    lv_sql_error_code := SQLCODE;
    lv_sql_error_message := SQLERRM(v_sql_error_code);
    DBMS_OUTPUT.PUT_LINE('OTHER ERROR');
    DBMS_OUTPUT.PUT_LINE(v_sql_error_message);
    END distributor_q_i;
    show errors;

    Hello
    That idea is pretty much fine. If you're on 9i the values(rec1) will work, if you're on 8i you'll have to specify each column i.e.
    SQL> CREATE OR REPLACE PACKAGE dt_test_package
      2  AS
      3  PROCEDURE proc1 (rec1 IN dt_test_tab2%ROWTYPE);
      4  END;
      5  /
    Package created.
    SQL> CREATE OR REPLACE PACKAGE BODY dt_test_package
      2  AS
      3  PROCEDURE proc1 (rec1 IN dt_test_tab2%ROWTYPE)
      4  IS
      5  BEGIN
      6  INSERT INTO dt_test_tab2 VALUES(rec1.col1,rec1.col2);
      7  END;
      8  END;
      9  /
    Package body created.
    SQL> CREATE OR REPLACE TRIGGER dt_test_trigger BEFORE INSERT ON dt_test_tab1 FOR EACH ROW
      2
      3  DECLARE
      4  rec1 dt_test_tab2%ROWTYPE;
      5  BEGIN
      6  rec1.col1 := :NEW.col1;
      7  rec1.col2 := :NEW.col2;
      8  dt_test_package.proc1(rec1);
      9  END;
    10  /
    Trigger created.
    SQL> insert into dt_test_tab1 values('col1','col2','col3');
    1 row created.
    SQL> /
    1 row created.
    SQL> select * from dt_test_tab1;
    COL1       COL2       COL3
    col1       col2       col3
    col1       col2       col3
    SQL> select * from dt_test_tab2;
    COL1       COL2
    col1       col2
    col1       col2David

  • Please Help... Problem creating triggers...

    I am using Oracle 8i Personal Edition for WinNT/Win2k. I am trying to create a trigger, and keep getting a message that I can't create triggers on tables created by SYS, although I am logged in as SYS. I looked at some documentation, and it said that I have to run the catproc.sql script and the dbmsstdx.sql script. I assume to run them, I type "start" with the file name at the sql prompt. I tried running both of those scripts, but I get error messages with both. If I run the catproc.sql script, it says "ORA-01756: quoted string not properly terminated". The dbmsstdx.sql script says "SP2-0552: Bind variable "38" not declared."
    Does anyone have any suggestions for me? Any help is greatly appreciated. Thanks.

    Hi,
    See first of all you shouldn't write any user defined procedure,trigger in schema 'Sys'. It fires an error. so that is right.
    You create new user and write the same trigger in that schema it will definately work.
    null

  • How to create triggers...

    I have the following trigger which seems to be working properly when it's created using sqlplus.
    CREATE OR REPLACE TRIGGER trig_address
    BEFORE INSERT ON address REFERENCING NEW AS NEW
    FOR EACH ROW
    BEGIN
    SELECT seq_address.nextval INTO :NEW.ID FROM dual;
    END;
    I would like to create this thru JDBC if possible. I have run into problems that make me believe Oracle considers placement of keywords because this doesn't seem to work properly:
    CREATE OR REPLACE TRIGGER trig_address BEFORE INSERT ON address REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT seq_address.nextval INTO :NEW.ID FROM dual;END;/
    Is it possible to create triggers thru JDBC? If so, how?
    Thx,
    Dan
    Edited by: user10432031 on Dec 15, 2008 6:20 AM

    As you can see from following example, Oracle does not care about the formatting.
    SQL> create table test (id number);
    Table created.
    SQL> create or replace trigger trgrow_testbu before update on test for each row begin :new.id := 10; end;
      2  /
    Trigger created.
    SQL>You have not mentioned the error that you are getting so I presume the forward slash at the end of following statement is causing the problem.
    CREATE OR REPLACE TRIGGER trig_address BEFORE INSERT ON address REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT seq_address.nextval INTO :NEW.ID FROM dual;END;/Try removing that.
    Apart from that, ensure that the logged in user has CREATE TRIGGER privilege.

  • How to raise the event without creating Triggers

    Hi Gurus,
    here is my requirement.
    Whenever user issue the material from inventory ( on hand quantity reduced ), we have to generate a data file which contains item number, sub inventory and quantity info. for this we have created a utl file package. But here my issue is, without creating triggers / Alerts , i have to run the utl package.
    Please advice me how to do this / is there any middle ware tools available to run the package / concurrent prohram.
    We are using R12.
    Regards,
    Sreehari.

    Oracle provides various business events for material issue/transactions from inventory (For e.g.,oracle.apps.inv.miscIssue, oracle.apps.inv.subinvTransfer, oracle.apps.wip.job.material.transact, etc.).
    First check what kind of transactions happen when the On-hand is consumed. Then Go to any Workflow Admin responsibility >> Business Events: Events >> Search for the event you are looking for >>Hit Update >> Enable the event >> Navigate to Subscription and associate your PLSQL pacakge. let me know if it helps.

  • Creating triggers and Stored proceedures

    . Can someone pls give me codes to execute following things?
    *create sql server triggers to prevent deletion of primary key in employee table (primary key is emp_id)
     *create stored procedures,
    1.to obtain employee details, company he's working in and the manager's name, any changes to the database 
    2.update if something is successful in operations
    These are all the codes in my query for you to understand my requirement
    create table employee
    (emp_id nvarchar(20) primary key,
    employee_name varchar(20),
    street varchar(20),
    city varchar(20))
    create table company
    (company_name varchar(20) primary key,
    city varchar(20))
    create table works
    (emp_id nvarchar(20),
    company_name varchar(20),
    salary int,
    HireDate date)
    create table manages
    (emp_id nvarchar(20),
    manager_name varchar(20))
    Insert into employee values('101','Scott Matthews','Netson street','Auckland')
    Insert into employee values('102','Jonah Black','Wills street','Wellington')
    Insert into employee values('103','Karen Ole','Manners street','Wellington')
    Insert into employee values('104','Ben Dawson','Queen Street','Wellington')
    Insert into employee values('105','Norah Jones','Symonds street','Auckland')
    Insert into company values('TSB','Wellington')
    Insert into company values('ABC','Auckland')
    Insert into works values('101','ABC','20000','12-09-2009')
    Insert into works values('102','TSB','40000','06-10-2009')
    Insert into works values('103','ABC','50000','05-09-2009')
    Insert into works values('104','ABC','60000','11-09-2008')
    Insert into works values('105','ABC','80000','08-09-2009')
    Insert into manages values('101','Norah Jones')
    Insert into manages values('102','Norah Jones')
    Insert into manages values('104','Norah Jones')
    Thanks!

    Thanks! but it gives this error message
    Msg 208, Level 16, State 6,
    Procedure trg_AvoidPKDeletion, Line 1
    Invalid object name 'trg_AvoidPKDeletion'.
    Once I execute this code, I shouldn't be able to delete any emp_id from the table by going to it's edit option. that's what done by this
    trigger right?
    sorry it should be this
    CREATE TRIGGER trg_AvoidPKDeletion
    ON DATABASE
    FOR ALTER_TABLE
    AS
    BEGIN
    DECLARE @SQLCommand varchar(max)= EVENTDATA().value('(/EVENT_INSTANCE/TSQLCommand)[1]', 'nvarchar(max)')
    IF EXISTS (select s.name as TABLE_SCHEMA, t.name as TABLE_NAME
    , k.name as CONSTRAINT_NAME, k.type_desc as CONSTRAINT_TYPE
    , c.name as COLUMN_NAME, ic.key_ordinal AS ORDINAL_POSITION
    from sys.key_constraints as k
    join sys.tables as t
    on t.object_id = k.parent_object_id
    join sys.schemas as s
    on s.schema_id = t.schema_id
    join sys.index_columns as ic
    on ic.object_id = t.object_id
    and ic.index_id = k.unique_index_id
    join sys.columns as c
    on c.object_id = t.object_id
    and c.column_id = ic.column_id
    where k.type_desc = 'PRIMARY_KEY_CONSTRAINT'
    AND @SQLCommand = 'ALTER TABLE ' + s.name + ' DROP CONSTRAINT ' + k.name )
    PRINT 'PK constraints cannot be dropped'
    ROLLBACK
    END
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Help on creating Triggers on POR1

    Hi,
    I have a trigger on POR1 table, which updates a UDF field when Insert/Update is done on POR1 lines.
    If PO has a single line, it works great.
    But, if there is more than one line, I'm getting the error message : 'Invalid Cursor' while trying to update PO.
    I have stripped down the trigger, so that it is in its simplest form.
    Still I'm getting the invalid cursor error.
    Simplest form of Trigger:
    Create Trigger AIT_FWA_POR ON POR1
    AFTER INSERT
    AS
    Begin
    Update POR1 Set U_ShipCost = '10'     
    FROM POR1,Inserted where POR1.DocEntry = Inserted.DocEntry
    End
    If I see what happens in SQL profiler, it appears that SAP is deleting the POR1 rows (and reinserts?).
    Please let me know how I can fix it, or more details about the internal functionality.
    Your valuable inputs in fixing the problem will be highly appreciated.
    Thanks in advance.
    Regards,
    Geetha

    Hi Geetha,
    Unfortunately, SAP do not support triggers on their tables and do not support updating UDFs directly through SQL on system tables so I can't offer a solution for this.
    For a solution that fits within SAP's rules, I'd recommend you have an addon that traps the event of the user clicking on the Add/Update button on the purchase order screen and then populate your UDF value through the UI API before the document is added.
    Kind Regards,
    Owen

  • Is it possible to create triggers in sybase from jdbc (java application)?

    We are in the need to create a triggers in the database (sybase) from JDBC (java application)?
    Please send me pointers or articles related to this.
    Thanks in advance,
    Kri

    A trigger is NEVER explicitly called, from any environment.
    It is implicitly called when you invoke the operation that it's a trigger for.
    Whether you're using Java or anything else to invoke that operation makes no difference whatsoever.

  • Creating/Triggering Output Type from program

    Hi,
    When I am creating Inbound Delivery using VL31N tcode, an Output type associated with it triggers automatically.  But my problem is that I have stopped the triggering of Output type automatically while saving Inbound delivery. and want to create mannually through program.
    Is there any FM or any other way to do through program.
    best regards
    bobby

    Hi
    Below link is for your reference
    [create output type reference|http://www.interfax.net/en/help/sap_sd_mm_module.html]
    hope it will help you.
    Regards
    Natasha Garg
    Edited by: Natasha Garg on Feb 5, 2009 7:25 AM

  • Performance issue with create triggered by

    Hi,
    We have a big performance problem when trying to create a triggered by on a business function.
    We created through headstart utilities (productivity boosters - analyses - maintain default events for entities) a lot of events on different entities.
    When trying to create a triggered by for a business function, the select list never comes up.
    This is what exactly happens:
    Enter the Ron
    choose a application
    choose a business function
    click on triggered by
    Click on the plus sign on the toolbar to create a reference.
    The next screen never appears, we let the program run for over 4 hours without any results. When investigating we found two queries are coninuesly executed, this one is causing the major problem:
    SELECT MAX(1) FROM I$SDD_WA_CONTEXT CTXT WHERE CTXT.OBJECT_IV
    ID = :b1 AND CTXT.WORKAREA_IRID = JR_CONTEXT.WORKAREA AND CTXT
    .WASTEBASKET = JR_CONTEXT.WASTEBASKET
    We run the tkprof utility and found this:
    SELECT MAX(1)
    FROM
    I$SDD_WA_CONTEXT CTXT WHERE CTXT.OBJECT_IVID = :b1 AND CTXT.WORKAREA_IRID =
    JR_CONTEXT.WORKAREA AND CTXT.WASTEBASKET = JR_CONTEXT.WASTEBASKET
    call count cpu elapsed disk query current rows
    Parse 0 0.00 0.00 0 0 0 0
    Execute 43995 0.00 0.00 0 0 0 0
    Fetch 43994 0.00 0.00 0 88041 0 43994
    total 87989 0.00 0.00 0 88041 0 43994
    Misses in library cache during parse: 0
    Optimizer goal: CHOOSE
    Parsing user id: 34 (REPOS_MANAGER) (recursive depth: 1)
    Rows Execution Plan
    0 SELECT STATEMENT GOAL: CHOOSE
    0 SORT (AGGREGATE)
    0 INDEX GOAL: ANALYZED (UNIQUE SCAN) OF 'PK_WA_CTXT' (UNIQUE)
    Did anybody had similar problems and know a solution for this?
    Yvon

    Yvon,
    This must be a Designer (RON) problem, unrelated to Headstart. If you had created the events manually, you should have had the same problem.
    I saw that you already posted this same question in the Designer forum. If you don't get any reply, I'd advise you to contact Oracle Worldwide Customer Support.
    kind regards,
    Sandra Muller

  • Creating triggers in a logical standby database

    Does anyone know if its possible to create and enable a trigger in a logical standby database on a 'guarded' table? I've been able to create the trigger (as an after insert trigger) and it appears to be valid but it never seems to fire, despite inserts taking place. Are there any other steps involved to activate this, or is it just plain not possible in a logical standby? My primary and logical standby databases are 10.2.0.3

    HI Daniel,
    I appreciate your quick response.
    My choice of name may not have been ideal, however changing new to another name - like gav - does not solve the problem.
    SYS@UATDR> connect / as sysdba
    Connected.
    SYS@UATDR>
    SYS@UATDR> select name, log_mode, database_role, guard_status, force_logging, flashback_on, db_unique_name
    2 from v$database
    3 /
    NAME LOG_MODE DATABASE_ROLE GUARD_S FOR FLASHBACK_ON DB_UNIQUE_NAME
    UATDR ARCHIVELOG LOGICAL STANDBY ALL YES YES UATDR
    SYS@UATDR>
    SYS@UATDR> create tablespace ts_gav
    2 /
    Tablespace created.
    SYS@UATDR>
    SYS@UATDR> create user gav
    2 identified by gav
    3 default tablespace ts_gav
    4 temporary tablespace temp
    5 quota unlimited on ts_gav
    6 /
    User created.
    SYS@UATDR>
    SYS@UATDR> grant connect, resource to gav
    2 /
    Grant succeeded.
    SYS@UATDR> grant unlimited tablespace, create table, create any table to gav
    2 /
    Grant succeeded.
    SYS@UATDR>
    SYS@UATDR> -- show privs given to gav
    SYS@UATDR> select * from dba_sys_privs where grantee='GAV'
    2 /
    GRANTEE PRIVILEGE ADM
    GAV CREATE TABLE NO
    GAV CREATE ANY TABLE NO
    GAV UNLIMITED TABLESPACE NO
    SYS@UATDR>
    SYS@UATDR> -- create objects in schema
    SYS@UATDR> connect gav/gav
    Connected.
    GAV@UATDR>
    GAV@UATDR> -- prove ability to create tables
    GAV@UATDR> create table gav
    2 (col1 number not null)
    3 tablespace ts_gav
    4 /
    create table gav
    ERROR at line 1:
    ORA-01031: insufficient privileges
    GAV@UATDR>

Maybe you are looking for

  • Server 2008 SP2 will not install Windows Updates

    I receive this error: Installation Failure: Windows failed to install the following update with error 0x8000ffff: Security Update for Windows Server 2008 (KB2653956). Installation Failure: Windows failed to install the following update with error 0x8

  • Question regarding best practice

    Hello Experts, What is the best way to deploy NWGW? We recently architected a solution to install the 7.4 ABAP stack which comes with Gateway. We chose the Central Gateway HUB scenario in a 3 -tier setup. Is this all that's required in order to conne

  • I Deleting "photo library" pics?

    Don't see a trash can/delete icon when I select pictures.  Need to make space on phone for system updates....anypne know how to rid the phone of these pictures?

  • Help in Cell Definition

    Hello, Can you please anybody tell us , what do you mean by help cell in Cell defintion. Thanks PT

  • Error in Biller Direct

    Hi All, I am getting following error in biller direct after log in. "Your user master has not been created correctly. Contact your system administrator." My observation In the ECC side is: In RFC RFC EBPP_GET_ACTIVITI I_PARTNER-PARTNERTYPE and I_PART