oracle 我想用这个程序按ID删除解决方案中表的行

ewm0tg9j  于 2023-01-12  发布在  Oracle
关注(0)|答案(1)|浏览(101)
Create Table table8_prc (
                          Family    VARCHAR2(200),
                        
                          Name      VARCHAR2(200) ,
                          
                          ID        INTEGER 
                       

                           ) ;
                           
CREATE SEQUENCE ID_seq1
  MINVALUE 1
  START WITH 1
  INCREMENT BY 1
  CACHE 20;  
  
Create or Replace trigger trg1 
  BEFORE insert on  table8_prc 
  
   for each row 
   BEGIN
   select ID_seq1.nextval INTO :new.ID from dual ;
   END ;
 
   

 CREATE OR REPLACE PROCEDURE addnewmem1 (str IN VARCHAR2)
   AS
    BEGIN
      INSERT INTO table8_prc (Name, Family)
          WITH
            temp
             AS
               (    SELECT REGEXP_SUBSTR (str,
                                           '[^,]+',
                                          1,
                                        LEVEL) val
                    FROM DUAL
               CONNECT BY LEVEL <= REGEXP_COUNT (str, ',') + 1)
         SELECT TRIM (SUBSTR (val, 1, INSTR (val, ';') - 1)),
               TRIM (SUBSTR (val, INSTR (val, ';') + 1))
          FROM temp;
 
      COMMIT;
   END;
   

 BEGIN
       addnewmem1 ('faezeh;Ghanbarian,pari;izadi');
    END;
    
BEGIN
       addnewmem1 ('Saeed;Izadi,Saman; Rostami');
       
    END; 
    
   
 select *
 from  table8_prc ;
vxf3dgd4

vxf3dgd41#

传递ID值并删除由其标识的行:

CREATE OR REPLACE PROCEDURE delete_member (par_id IN INT)
IS
BEGIN
   DELETE FROM table8_prc
         WHERE id = par_id;
END;
/

相关问题