Truncate in a stored procedure or trigger?

hello all,
is it possible to use 'truncate table' in trigger or stored procedure ?
I can do a delete, but when i use truncate table <mytable>, when i compile the trigger, i get an error,
the word 'TABLE' seems forbidden.
thanks for help

Hi Laurent,
I tryed to describe the work-around above.
Let me explain in details.
If you want to use 'TRUNCATE TABLE B' comand from a insert trigger on A, you can do the following:
1) create stored procedure which is autonomous
transaction:
create or replace procedure z1
is
pragma autonomous_transaction;
begin
execute immediate 'TRUNCATE TABLE B';
end;
You don't need put there explicit COMMIT -
it will be executed implicitly (autonomous
transactions require commit or rollback before
completon).
2) Create trigger on A for example:
create trigger trr
before insert on A
begin
z1;
end;
After issuing INSERT command for table A, table B
will be truncated.
Consider the following waterstones here:
1) In contrast with the using of DELETE, if you will
do rollback the changes after insertion in A - everything will rollbacked - except for B truncation. It's already
committed in another transaction. You are not able
to rollback the results of TRUNCATE.
2) If you do uncommitted changes in table B before
insertion in A - you will have
'ORA-00054: resource busy and acquire with NOWAIT specified'
exception because you can't truncate table where another
transaction makes changes.
Regards.

Similar Messages

  • How to kill a  session in stored procedure or trigger.

    Can anyone let me know, how to kill a particular session in stored procedure or trigger.
    Regards
    KVSS

    also you cannot attempt to kill ur own current session.
    But on what circumstances you want to kill the session.
    When anyone trys to access a table and lets suppose the trigger onthat table activates
    and you want to kill that very session which activated the trigger ???
    i dont think its possible. To kill a session definitely you should be in a different session and
    then only you can achieve that.
    pls check it out
    prakash
    [email protected]

  • Hi i am using oracle 10g how to view the content of the stored procedure or trigger ?

    Hi i am using oracle 10g .How to edit  the content of the stored procedure or trigger ?

    jklopkjl wrote:
    Hi i am using oracle 10g .How to view the content of the stored procedure or trigger ?
    query ALL_SOURCE
    SQL> desc all_source
    Name                                      Null?    Type
    OWNER                                              VARCHAR2(30)
    NAME                                               VARCHAR2(30)
    TYPE                                               VARCHAR2(12)
    LINE                                               NUMBER
    TEXT                                               VARCHAR2(4000)

  • Bulk insert using stored procedure or trigger

    Hi ,
    I have to insert around 40,000 rows in a table querying other database using database link.
    Please advice whether I do using stored procedure or trigger.
    Thanks.

    Here is a basic benchmark that illustrates the difference between maximising SQL, or doing it in PL/SQL instead.
    Care needs to be taken with such a benchmark in order for physical I/O not to negatively impact a test, and then have no impact in the second test as that data read from disk now sits in the cache.
    So I ran it a couple of times in order to "warm up" the cache. I also put the maximise-SQL test first in order to show that it is still faster, despite any physical I/O it may do (which will likely be faster logical I/O with the second test).
    Run on Oracle XE 10.2.0.1.
    SQL> drop table my_objects_copy purge;
    Table dropped.
    SQL> create table my_objects_copy as select * from all_objects;
    Table created.
    SQL>
    SQL> set timing on
    SQL> begin
    2 delete from my_objects_copy;
    3
    4 insert into my_objects_copy
    5 select * from all_objects;
    6
    7 commit;
    8 end;
    9 /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:01.11
    SQL> set timing off
    SQL>
    SQL> drop table my_objects_copy purge;
    Table dropped.
    SQL> create table my_objects_copy as select * from all_objects;
    Table created.
    SQL>
    SQL> set timing on
    SQL> declare
    2 cursor c is select * from all_objects;
    3 objRow ALL_OBJECTS%ROWTYPE;
    4 begin
    5 delete from my_objects_copy;
    6
    7 open c;
    8 loop
    9 fetch c into objRow;
    10 exit when c%NOTFOUND;
    11
    12 insert into my_objects_copy
    13 values objRow;
    14
    15 end loop;
    16 commit;
    17 end;
    18 /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:03.21
    SQL>
    The cursor-fetch-loop is almost 3 times slower. The more rows there are to process, the slower the cursor-fetch-loop will become, as it will create more and more context switching and copying data between the SQL and PL engines and back.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • STORED PROCEDURE & DATABASE TRIGGER

    제품 : FORMS
    작성날짜 : 1995-11-07
    * STORED PROCEDURE
    1. Oracle Forms 4.5에서는 PL/SQL Code를 Server-Side에 저장하거나 Forms 내 Trigger, Procedure로 갖을 수도 있다.
    다음과 같은 경우 Procedure를 Database Server에 저장하는 방법을 선택하는
    것이 좋다.
    - Procedure가 Standard한 기능을 제공하여 다른 Tool이 공유할 수 있을 때.
    - Procedure가 중요한 DML 기능을 가질 경우.
    - Oracle Forms 4.5에서는 PL/SQL의 Version을 1.1까지 지원하므로, PL/SQL
    Version 2.X 의 기능이 필요한 경우.
    2. Stored Procedure의 제한사항
    (1) Server가 7.0 이상이어야 한다.
    (2) Pass되는 Variable은 2000 Byte이하이어야 한다.
    - 2000이 넘으면 Truncate가 되고, PL/SQL에서 Value_Error Exception이
    발생한다.
    (3) Menu PL/SQL에서는 Stored Procedure와 Function을 부를 수 없다.
    (4) Stored Subprogram의 정의가 바뀐 경우, Forms를 다시 Server와 Connect
    하기 전에는 영향을 주지 않는다.
    3. Oracle 7 Server 에서 제공하는 Standard Package들
    - dbms_alert
    - dbms_ddl
    - dbms_describe
    - dbms_lock
    - dbms_mail
    - dbms_output
    - dbms_pipe
    - dbms_session
    - dbms_snapshot
    - dbms_standard
    - dbms_transaction
    - dbms_utility
    < Oracle7 Developers Guide 참조>
    4. Calling Stored Procedures
    (1) Database Procedure는 Server-Side PL/SQL Engine에 의해 실행되도록
    Design된 PL/SQL Block이다.
    (2) Stored Procedure를 Call하기 위해서는 EXECUTE Privilege가 필요하다.
    (3) Server-Side Procedure와 Forms에서의 PL/SQL의 중요한 차이점은
    Server-Side 에서는 Forms의 Bind Variable (:Block_Name.Item_Name 등)
    을 인식하지 못한다는 것이다.
    (4) Parameter/Return이 가능한 Data Type
    - VARCHAR2 : Maximum of Varchar2(2000)
    - NUMBER
    - DATE
    - BOOLEAN
    제한사항
    - TABLE%ROWTYPE, TABLE.COLUMN%ROWTYPE으로 정의된 것은 Reference가
    안된다.
    - Unsupported Parameter나 Return Value를 사용하면 다음의 Error가
    발생한다.
    * PL/SQL error 313 at line xxx, column yyy 'PROCNAME'
    not declared in this scope.
    * PL/SQL error 201 at line xxx, column yyy identifier 'FUNCTNAME'
    must be declared.
    (5) Formal Parameter의 Default Value
    - Defulat Value는 제공하지 않는다.
    - User가 임의로 줄 수 있다.
    - Procedure Private_Test(a in VARCHAR2 := 'Hello' b in
    VARCHAR2 := 'There') IS
    BEGIN
    Dbms_Output.Put_Line(a);
    Dbms_Output.Put_Line(b);
    END;
    (6) 다른 User의 Stored Subprogram이나 Remote Database를 Call하려면
    - User Name이나 Database Link명을 숨기기 위하여 Synonym을 생성하여야
    한다.
    - CREATE SYNONYM lib_hr_syn FOR libowner.lib_hr;
    - Program에서 Call할 때에는 ss_num ;= lib_hr_syn.get_ssn(:EMP.EMPNO);
    5. PL/SQL Compiler가 해당 Procedure를 찾는 순서
    (1) Current PL/SQL Block 내에 정의되어 있는가?
    (2) Standard PL/SQL Command인가?
    (3) Oracle Forms 내의 Built-in Procedure 혹은 Function인가?
    (4) User_Named Procedure 혹은 Function인가?
    (5) Server-side에 정의된 DBMS_STANDARD Package인가?
    (6) Current user가 Server-Side의 어떤 Procedure나 Function을 Access
    하는가?
    * 이상의 질문에 대하여 전부 'NO'라는 대답이 나오면 Compiler는 다음과 같은
    Error Message를 준다.
    - PL/SQL error 313 at line xxx, column yyy 'PROCNAME' not declared in
    this scope.
    - PL/SQL error 201 at line xxx, column yyy identifier 'FUNCTNAME'
    must be declared.
    * DATABASE TRIGGER
    1. Database Trigger는 Forms에서의 Trigger와 개념적으로 거의 동일하다.
    차이점은 Trigger가 Fire되는 원인을 제공하는 사건과 후속코드가 실행되는
    장소가 틀린 것이다.
    2. Database Trigger는 Table과 연관된 PL/SQL Block들이다. Table에 대한
    UPDATE, INSERT, DELETE 등의 행위에 의해 Fire된다.
    3. Error 발생 시에는 RAISE_APPLICATION_ERROR Built-In Procedure를 사용하
    여 Error를 표시한다.
    RAISE_APPLICATION_ERROR Procedure에서는 Error Number가 20000 - 20999의
    Range를 가진다.
    4. Creating & Editing Database Triggers
    아래와 같은 적절한 권한이 주어진다면 Forms Designer Mode에서 Database
    Trigger를 직접 Create, Edit, Compile, Browse 할 수 있다.
    - Execute Privilege, Create Privilege, Compile Privilege,
    Drop Privilege
    * Create하려면
    - Navigator에서 Database Objects와 Table Nodes를 Expand한다.
    - 원하는 Table을 선택하고 Expand한다.
    - Triggers Nodes를 선택하고 Menu Bar의 Navigator*Create를 선택한다.
    - Database Trigger Editor에서 작성, compile한다.
    * Edit 하려면
    - Navigator에서 Database Objects와 Table Nodes를 Expand한다.
    - 원하는 Table을 선택하고 Expand한다.
    - 원하는 Trigger에서 Double-Click하면 Editor가 나타난다.
    - Database Trigger Editor에서 변경, compile한다.

    not possible via forms
    you can debug it on SQL Developer by using manual INSERT Updates commands

  • Problem in executing Stored Procedure from Trigger

    Hi,
    Case1.
    I am executing a stored procedure form a trigger. The stored procedure is not executing fully.
    Case 2.
    But when when I execute Stored Procedure alone it is executing.
    CREATE OR REPLACE TRIGGER mhubadmin.call_proc_ratesheet_new
    after INSERT OR delete ON mhubadmin.pvt_br_ratesheet
    FOR EACH ROW
    declare
    var_orgid number;
    begin
    if inserting then
    select org_child_id into var_orgid from business_relationship where br_id=:new.br_id;
    mhubadmin.proc_ratesheet_new(var_orgid);
    else
    select org_child_id into var_orgid from business_relationship where br_id=:old.br_id;
    mhubadmin.proc_ratesheet_new(var_orgid);
    end if;
    end;
    CREATE OR REPLACE PROCEDURE proc_ratesheet_new(var_orgid in number)
    IS
    cursor c3 is select distinct(purs.user_id) from hubuser hu
    inner join PVT_USER_RATESHEET purs on hu.USER_ID=purs.USER_ID
                   where hu.ORG_ID=var_orgid;
    cursor c1(varUser_id number) is select purs.user_id,purs.ratesheet_id from hubuser hu
    inner join PVT_USER_RATESHEET purs on hu.USER_ID=purs.USER_ID
                   where hu.ORG_ID=var_orgid and purs.USER_ID=varUser_id;
    cursor c2(varUser_id number) is select hu.user_id,pbr.ratesheet_id from HUBUSER hu
                             inner join BUSINESS_RELATIONSHIP br on hu.ORG_ID=br.ORG_CHILD_ID
                             inner join PVT_BR_RATESHEET pbr on br.BR_ID=pbr.BR_ID
                                  where hu.user_id in(select distinct(purs.USER_ID) from hubuser hu
                                       inner join PVT_USER_RATESHEET purs
                                                                     on hu.USER_ID=purs.USER_ID
                                                 where hu.ORG_ID=var_orgid) and hu.user_id=varUser_id;
    foundFlag boolean;
    incrFound integer;
    insertFound integer;
    deleteFound integer;
    str varchar2(4000);
    BEGIN
         incrFound:=0;
         insertFound:=0;
         for c3var in c3 loop
    for c2var in c2(c3var.user_id) loop
              insert into test values ('Step3:'||c2var.user_id);
              foundFlag:=false;
              for c1var in c1(c3var.user_id) loop
                   if c2var.ratesheet_id=c1var.ratesheet_id then
                        foundFlag:=true;
                             incrFound:=incrFound+1;
                             exit;
                        end if;
                   end loop;
                   if foundFlag=False then
                   --insert into pvt_user_ratesheet (username_ratesheet_id,user_id,ratesheet_id) values (SEQ_USER_RATESHEET.nextval,c3var.user_id,c2var.ratesheet_id);
                   dbms_output.put_line('Inserted for user :'||c3var.user_id||' is - ratesheet :'||c2var.ratesheet_id);
                   insertFound:=insertFound+1;
                   end if;
              end loop;
    end loop;
         commit;
         incrFound:=0;
         deleteFound:=0;
         for c3var in c3 loop
              for c1var in c1(c3var.user_id) loop
              foundFlag:=false;
              for c2var in c2(c3var.user_id) loop
                        if c1var.ratesheet_id=c2var.ratesheet_id then
                        foundFlag:=true;
                        incrFound:=incrFound+1;
                        exit;
                        end if;
                   end loop;
                   if foundFlag=False then
                   --delete from pvt_user_ratesheet where user_id=c3var.user_id and ratesheet_id=c1var.ratesheet_id;
                        --dbms_output.put_line('Deleted for userid:'||c3var.user_id||' for ratesheet :'||c1var.ratesheet_id);
                        deleteFound:=deleteFound+1;
                   end if;
              end loop;
    end loop;
         commit;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.put_line (SQLCODE||' '|| SQLERRM);
    END;
    Regards,
    Mathew

    In general, I would suggest that you only catch errors that you can handle reasonably. If you know that a SELECT INTO might return 0 rows for example, handle the NO_DATA_FOUND exception. Having a WHEN OTHERS, particularly without re-raising the exception, only serves to hide the source of the problem. I would much rather that my code fail quickly and explicitly than hope that I see an error message in the output and that other code doesn't start failing because the system wasn't left in an appropriate state.
    As Mark suggests, you may choose to implement a comprehensive logging framework using autonomous transactions, in which case a WHEN OTHERS would be reasonable, but you would still want to propagate exceptions you cannot handle.
    If you see a WHEN OTHERS clause and there is no RAISE, you probably have an error waiting to happen.
    Justin

  • Problem: PL/SQL + Stored Procedure + Sequence + Trigger + Transaction + Violation Key

    I have a violation key when i insert some datas from a stored procedure. Why ???
    This is my script :
    1) The script of the table :
    CREATE TABLE OLLMULTI (
         IDO int NOT NULL ,
         IDL int NOT NULL ,
         T1 varchar2 (2) NOT NULL ,
         IDR int NOT NULL ,
         Constraint pk_outilsllmulti PRIMARY KEY (IDO, IDL, T1) ,
         Constraint u_outilsllmulti unique (IDR) );
    2) Now, i want to manage automatic increment field on IDR :
    I create a sequence :
    create sequence OLLMULTI_sequence increment by 1 start with 1;
    I create the trigger :
    create or replace trigger OLLMULTI_trigger
    before insert on OLLMULTI
    for each row when (new.IDR is null)
    begin
    select OLLMULTI_sequence.nextval into :new.IDR from dual;
    end;
    3) Now i create my store procedure and, in my procedure i want to insert 6 rows :
    Procedure Insert_OLLMULTI( i_IDO in OLLMULTI.IDO%type)
    is
    pragma AUTONOMOUS_TRANSACTION;
    BEGIN
    INSERT INTO OLLMULTI (IDO,IDL,T1)
    VALUES (i_IDO,2,'GJ');
    INSERT INTO OLLMULTI (IDO,IDL,T1)
    VALUES (i_IDO,5,'ND');
    INSERT INTO OLLMULTI (IDO,IDL,T1)
    VALUES (i_IDO,12,'AC');
    INSERT INTO OLLMULTI (IDO,IDL,T1)
    VALUES (i_IDO,120,'AH');
    INSERT INTO OLLMULTI (IDO,IDL,T1)
    VALUES (i_IDO,10,'ZG');
    INSERT INTO OLLMULTI (IDO,IDL,T1)
    VALUES (i_IDO,5,'RB');
    commit;
    EXCEPTION
    WHEN OTHERS THEN
    rollback;
    raise;
    END;
    END;
    4) The problem :
    The violation key on the constrainst u_outilsllmulti appears sometimes on a randome insert. Never the same !
    Why ? I think that the sequence is the problem... Or is the problem is the "pragma AUTONOMOUS_TRANSACTION" command ?
    Anyone can help me ?

    Two ideas:
    - Is it possible that there are already records in the table that were
    created without using the sequence? A sequence initially starts at 1,
    if you already got data you first have to increment it.
    - May it be that some inserts happen without your procedure? The trigger
    allows to create IDs without using the sequence. Correct, there are already records in my table !!
    Thanks. That's right.

  • Using truncate table in stored procedure

    Hello
    I am trying to truncate and repopulate a table in a procedure. I have found that this appears to be impossible. Surely there is some way around this!!
    Can anyone help me overcome this problem?
    Dean
    null

    Use the DBMS_SQL package or (in 8i) execute immediate.

  • Trigger Unix Program from a stored procedure

    Is it possible to start a Unix program as a background OS process from a stored procedure?
    In fact I want to call a stored procedure which starts a Unix process. After the termination of this process get the results of the programm (a text file) using UTL_FILE package from the stored procedure and produce an HTML document based on the output of the started process using the htp package.
    Thanks, JV

    wrote:roadbike
    Whats the best way to start a host (Unix) program from a stored procedure or trigger without having to wait for a response from the program (i.e start it and forget it )The BEST way depends on your operating system and version of the Oracle database. If you are at Oracle 10g or higher, I would certainly suggest using dbms_scheduler. In 10gR2 you can set a program to execute on receipt of an event, and the trigger or stored procedure can be the cause of the event.

  • Trouble with calling a stored procedure with VARCHAR parameter from trigger

    Hi everybody,
    today I ran across a problem with stored procedures and triggers that try to call them. Background info: I want to log changes in certain tables to another table in a trigger, so I can replicate the changes to another (non-Oracle) database in an asynchronous way. As an example I have the first data table "bak_s3_berufliste" and the table to store the changes in is "bak_s3_change_request".
    DROP TABLE BAK_S3_BERUFLISTE;
    CREATE TABLE bak_s3_berufliste (
    id_bl NUMBER(27,0) NOT NULL,
    berufsbez VARCHAR2(255),
    CONSTRAINT PK_BAK_S3_BERUFLISTE PRIMARY KEY (id_bl) ENABLE);
    DROP TABLE bak_s3_change_request;
    CREATE TABLE bak_s3_change_request (
    ID_CR NUMBER(27,0) NOT NULL,
    TABELLE_NAME VARCHAR2(50) NOT NULL,
    TABELLE_ID_ALT NUMBER(27,0),
    TABELLE_ID_NEU NUMBER(27,0),
    CONSTRAINT PK_BAK_S3_CHANGE_REQUEST PRIMARY KEY (ID_CR) ENABLE);
    DROP SEQUENCE seq_bak_s3_change_request;
    CREATE SEQUENCE seq_bak_s3_change_request;
    For testing purposes I created the following stored procedure and trigger:
    CREATE OR REPLACE PROCEDURE schreibe_cr (t_id_alt IN NUMBER, t_id_neu IN NUMBER) IS
    BEGIN
    INSERT INTO bak_s3_change_request(ID_CR, TABELLE_NAME, TABELLE_ID_ALT, TABELLE_ID_NEU)
    VALUES (seq_bak_s3_change_request.NEXTVAL, t_name, t_id_alt, t_id_neu);
    END;
    CREATE OR REPLACE TRIGGER trg_bak_s3_berufliste
    BEFORE INSERT OR UPDATE OR DELETE ON bak_s3_berufliste
    FOR EACH ROW
    call schreibe_cr(:old.id_bl,:new.id_bl)
    *... and everything worked perfectly - except from the fact that I need to know which table had changed of course. So I added another parameter to the stored procedure:*
    CREATE OR REPLACE PROCEDURE schreibe_cr (t_name IN VARCHAR2, t_id_alt IN NUMBER, t_id_neu IN NUMBER) IS
    BEGIN
    INSERT INTO bak_s3_change_request(ID_CR, TABELLE_NAME, TABELLE_ID_ALT, TABELLE_ID_NEU)
    VALUES (seq_bak_s3_change_request.NEXTVAL, t_name, t_id_alt, t_id_neu);
    END;
    and tested it:
    CALL schreibe_cr('Test',1,2);
    *... successfully. So I also added the parameter to the trigger:*
    CREATE OR REPLACE TRIGGER trg_bak_s3_berufliste
    BEFORE INSERT OR UPDATE OR DELETE ON bak_s3_berufliste
    FOR EACH ROW
    call schreibe_cr('Tabellenname',1,2)
    and what i get is:
    Error starting at line 31 in command:
    CREATE OR REPLACE TRIGGER trg_bak_s3_berufliste
    BEFORE INSERT OR UPDATE OR DELETE ON bak_s3_berufliste
    FOR EACH ROW
    call schreibe_cr('Tabellenname',1,2)
    When I try to insert something into that table I get the following error:
    insert into bak_s3_berufliste (id_bl, berufsbez) values (seq_bak_s3_change_request.NEXTVAL, 'tueduelue');
    Error report:
    ORA-00911: Ungültiges Zeichen
    00911. 00000 - "invalid character"
    Cause: identifiers may not start with any ASCII character other than
    letters and numbers. $#_ are also allowed after the first
    character. Identifiers enclosed by doublequotes may contain
    any character other than a doublequote. Alternative quotes
    (q'#...#') cannot use spaces, tabs, or carriage returns as
    delimiters. For all other contexts, consult the SQL Language
    Reference Manual.
    Action:
    I tried everything that came to my mind, like using double-quotes (") instead of quotes (') in the trigger code or escaping the quotes (\'), but nothing worked. Can anybody help my and tell me what's wrong? After googling for hours I'm outta ideas :-(
    Any ideas appreciated!
    Thanks in advance,
    Jens

    Why?
    Are you looking for this?
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:01.61
    satyaki>
    satyaki>
    satyaki>create table aud_dup_emp
      2     as
      3       select empno, ename
      4       from dup_emp
      5       where 1=2;
    Table created.
    Elapsed: 00:00:01.86
    satyaki>
    satyaki>select * from dup_emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       4450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       7000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
    18 rows selected.
    Elapsed: 00:00:00.10
    satyaki>
    satyaki>
    satyaki>create or replace procedure ins_aud_dup(eno in number, enm in varchar2)
      2     is
      3     begin
      4       insert into aud_dup_emp(empno,ename) values(eno,enm);
      5     end;
      6  /
    Procedure created.
    Elapsed: 00:00:03.36
    satyaki>
    satyaki>
    satyaki>
    satyaki>ed
    Wrote file afiedt.buf
      1  create or replace trigger trg_aud_dup
      2  before insert on dup_emp
      3     for each row
      4     begin
      5       ins_aud_dup(:old.empno,:new.ename);
      6*    end;
    satyaki>/
    Trigger created.
    Elapsed: 00:00:01.47
    satyaki>
    satyaki>
    satyaki>select * from aud_dup_emp;
    no rows selected
    Elapsed: 00:00:00.10
    satyaki>
    satyaki>
    satyaki>insert into dup_emp(empno,ename,deptno) values(8855,'BILLY',40);
    1 row created.
    Elapsed: 00:00:00.19
    satyaki>
    satyaki>commit;
    Commit complete.
    Elapsed: 00:00:00.03
    satyaki>
    satyaki>
    satyaki>select * from dup_emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       4450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       7000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          8855 BILLY                                                                   40
    19 rows selected.
    Elapsed: 00:00:00.20
    satyaki>
    satyaki>select * from aud_dup_emp;
         EMPNO ENAME
               BILLY
    Elapsed: 00:00:00.09
    satyaki>Regards.
    Satyaki De.

  • Does Oracle have Extended Stored Procedure like SQL Server and Sybase?

    Hi, i am new to Oracle. I want to know if...
    Does Oracle have Extended Stored Procedure like SQL Server and Sybase?
    If it does not have, then how can i call outside program written in C or JAVA from the Database stored procedure or trigger?

    refer to this link on external procedures
    http://download-west.oracle.com/docs/cd/A87860_01/doc/server.817/a76956/manproc.htm#11064

  • Java class call from Stored Proc or trigger

    Hi Experts!
    I have windows 2K server with Oracle 8i Enterprise Edition installed. Please let me know if I can call a java class from Stored Procedure or Trigger. If there is a way, then help me out with code sample or description.
    Regards,
    Atul
    [email protected]

    Atul,
    Couple of questions to you, off the subject,
    * Why NULL NULL registration?(You already revealed your name at the bottom)
    * Why email at the bottom? This is already a discussion forum.
    To your qn, it is very much possible. It is not something that one can explain in a single thread. It takes your machine setup for JVM, your knowledgebase on JAVA and other things. Please find notes on External Procedure Calls, which should give you a start. If you are running into problems, please come back with specifics.
    Thx,
    SriDHAR

  • "user defined exception" in a stored procedure and APEX

    I would like to use user defined exception in a stored procedure or trigger in a APEX application.
    Does anybody know how to do it ? or know where can I find a good reference ?
    Thanks,

    raise_application_error(-20001, 'error message');
    Scott

  • Calling of Stored Procedure in After Insert Trigger

    Can I call a Stored Procedure in After Insert Trigger ?
    Please send a sample code (good example) of After Insert Trigger.
    Thanks.

    Kishore,
    I have two table WLCS_ORDER, WLCS_ORDER_LINE
    WLCS_ORDER - It holds order header information like
    ORDER_ID
    CUSTOMER_ID
    TRANSACTION_ID
    STATUS
    ORDER_DATE
    SHIPPING_METHOD
    SHIPPING_AMOUNT
    SHIPPING_CURRENCY
    PRICE_AMOUNT
    PRICE_CURRENCY
    SHIPPING_GEOCODE
    SHIPPING_STREET1
    SHIPPING_STREET2
    SHIPPING_CITY
    SHIPPING_STATE
    SHIPPING_COUNTRY
    SHIPPING_POBOX
    SHIPPING_COUNTY
    SHIPPING_POSTAL_CODE
    SHIPPING_POSTAL_CODE_TYPE
    SPECIAL_INSTRUCTIONS
    SPLITTING_PREFERENCE
    ORDER_SUBTOTAL
    WLCS_ORDER_LINE - It holds all order lines information like
    ORDER_LINE_ID
    QUANTITY
    PRODUCT_ID
    TAX_AMOUNT
    TAX_CURRENCY
    SHIPPING_AMOUNT
    SHIPPING_CURRENCY
    UNIT_PRICE_AMOUNT
    UNIT_PRICE_CURRENCY
    MSRP_AMOUNT
    MSRP_CURRENCY
    DESCRIPTION
    ORDER_ID
    TOTAL_LINE_AMOUNT
    Relation between WLCS_ORDER, WLCS_ORDER_LINE is one to many.
    For each WLCS_ORDER row, one or more order lines will insert into WLCS_ORDER_LINE table.
    For each new row in WLCS_ORDER table, I have to update the following columns in both the tables with my maths.
    WLCS_ORDER
    shipping_amount
    price_amount
    order_subtotal
    WLCS_ORDER_LINE
    shipping_amount
    I thought I can do this in after insert trigger, But if it is not possible, Please give the best way to fulfill this requirement.
    I appreciate your help.
    Have a great day.
    Srinivas

  • Stored procedure OUTPUT VARCHAR2 value truncated using 12c client on Server 2012

    Questions:
    1) Is there a version of Oracle Client 11g which runs on Server 2012? My 11.2.0.0, when the installer begins, says my Server 2012 (8GB mem, 80 GB drive) does not meet the minimum requirements and I should not install it. This same installer worked on Server 2008.
    2) Have you seen the following behavior from Oracle client 12c? Are there any patches?
    When I was unable to find a version of Oracle 11g client for Windows Server 2012, I downloaded Oracle 12c. We have a few stored procedures, when invoked from a Windows Server 2008 with an 11g client work. However, when running that some code on a Windows Server 2012 machine does not work. I have certain stored procedures with an OUTPUT parameter when executed on 2012 has the values truncated.
    For instance:
    Output parameter is set to return "SUCCESS", but was is received is "SUC"
    Ouput parameter is set to return "AllSet", but it returns "All"
    Output parameter is set to cast a NUMBER to a VARCHAR2 and the value is a 5 digit number, but only the first two digits are returned. Ex: "83976", but only "83" appears.
    The above takes place when run from Server 2012, but works fine from Server 2008 and Win 7.

    Questions:
    1) Is there a version of Oracle Client 11g which runs on Server 2012? My 11.2.0.0, when the installer begins, says my Server 2012 (8GB mem, 80 GB drive) does not meet the minimum requirements and I should not install it. This same installer worked on Server 2008.
    2) Have you seen the following behavior from Oracle client 12c? Are there any patches?
    When I was unable to find a version of Oracle 11g client for Windows Server 2012, I downloaded Oracle 12c. We have a few stored procedures, when invoked from a Windows Server 2008 with an 11g client work. However, when running that some code on a Windows Server 2012 machine does not work. I have certain stored procedures with an OUTPUT parameter when executed on 2012 has the values truncated.
    For instance:
    Output parameter is set to return "SUCCESS", but was is received is "SUC"
    Ouput parameter is set to return "AllSet", but it returns "All"
    Output parameter is set to cast a NUMBER to a VARCHAR2 and the value is a 5 digit number, but only the first two digits are returned. Ex: "83976", but only "83" appears.
    The above takes place when run from Server 2012, but works fine from Server 2008 and Win 7.

Maybe you are looking for

  • How can I get rid of multiple versions of the iTunes Folder

    I am using Windows 7 and iTunes 12.1.1.4.  Multiple iTunes folders have been created on my computer (on both my C: drive and my D: drive under Users and My Documents) and they all have different content.  Some albums show up in one instance of the iT

  • How to replace the Losing fonts with scrip in photoshop,by script

    Frequently,I Receive some PSD files, It is did by Other people. When I open it with my computer,I find it missed a lot of fonts. Some times,I have this fonts, but the name is not  like with the fonts of the PSD file. So,I need to replae the Losing fo

  • Advice on Ownership & Permisions loss error?

    Hello, I've been having a MAJOR problem lately over a sudden loss in my Ownership & Permissions, which has prohibited me from ripping any music with iTunes due to "Access Privileges" (and I also asked this question there--http://discussions.apple.com

  • Error: the requested feature is unavailable on localhost

    Hi, everyone: I have Labview 7.1 installed in my computer (windows 2000) with my programs working. I need to change my version 7.1 files to 6.1 files in order to convert to an application file because I only have an ver 6.1 application builder. Yeste

  • I Need Apps That I Can Open A File I

    I need some app names i can open things in