to solve trigger

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • UPHADE
    New Member
    • May 2012
    • 1

    to solve trigger

    CREATE OR REPLACE PROCEDURE MFGNO(BODYSRNO IN VARCHAR2)
    IS
    MFGSRNO VARCHAR2(8);
    mfgno varchar2(8);
    cnt varchar2(3);
    BDATE DATE;
    BEGIN
    Select year_code||TO_C HAR(SYSDATE, 'MMDD') INTO mfgno from year_master
    where year in (select to_char(sysdate ,'yyyy') from dual);
    select lpad(count(*)+1 ,3,0) into cnt from manu where
    substr(bodysrno ,1,1) in ('U','S','P')
    AND bdate IN (SELECT SYSDATE FROM DUAL);
    mfgno:=mfgno||c nt;
    UPDATE manu SET mfgsrno=MFGNO WHERE BODYSRNO IN(SELECT BODYSRNO FROM MANU) ;
    DBMS_OUTPUT.PUT _LINE(MFGSRNO);
    END;


    this is the procedure to create the trigger using this and put the output in that way bodysrno,mfgsrn o,bdate in one table so pls help me for creating trigger
  • rski
    Recognized Expert Contributor
    • Dec 2006
    • 700

    #2
    Could you precise
    1) what operation on what table should invoke the trigger
    2) in what table do you want to insert the rows
    3) this query
    Code:
    UPDATE manu SET mfgsrno=MFGNO WHERE BODYSRNO IN(SELECT BODYSRNO FROM MANU) ;
    does not make sense to me, you update manu for all records which exists in manu.
    it is equall to
    Code:
    UPDATE manu SET mfgsrno=MFGNO;
    Also if you use IN you have to make sure that BODYSRN is not null.

    Please put here table structures and describe how should it work.

    Comment

    Working...