TQ20170605 2017-06-15 02:17 采纳率: 0%
浏览 415

oracle语句与SQL的转换,谢谢了

//客户退房后记录存入历史记录表 这是用oracle写出来的我对应写出来的sql有问题吗
create or replace TRIGGER deletecustomer
after delete
on customer
for each row
declare
ldate date;
money number;
begin
account(:OLD.RID,:OLD.rdate,ldate,money);
insert into history values
(id_seq.nextval,:OLD.CID,:OLD.RID,:OLD.cname,:OLD.csex,:OLD.ctel,:OLD.rdate,ldate,money);
end deletecustomer;

SQL//客户退房后记录存入历史记录表
create TRIGGER deletecustomer
on Customer
for delete
as
begin
declare
@ID int,
@CID nchar(18),
@RID nchar(3),
@Cname nvarchar(50),
@Csex nchar(1),
@Ctel nchar(11),
@Rdate date,
@Ldate date,
@payMoney int;
select @RID=RID,@CID=CID,@cname=cname,@csex=csex,
@ctel=Ctel,@rdate=rdate from deleted
SET IDENTITY_INSERT history ON
insert into history values (@ID,@CID,@RID,@Cname,@Csex,@Ctel,@Rdate,@Ldate,@payMoney);
SET IDENTITY_INSERT history OFF
end

  • 写回答

1条回答 默认 最新

  • copeterol 2023-05-30 09:51
    关注
    
    CREATE TRIGGER deletecustomer
    ON Customer
    AFTER DELETE
    AS
    BEGIN
      DECLARE
        @ID INT,
        @CID NCHAR(18),
        @RID NCHAR(3),
        @Cname NVARCHAR(50),
        @Csex NCHAR(1),
        @Ctel NCHAR(11),
        @Rdate DATE,
        @Ldate DATE,
        @payMoney INT;
    
      SELECT @RID = RID,
             @CID = CID,
             @Cname = cname,
             @Csex = csex,
             @Ctel = Ctel,
             @Rdate = rdate
      FROM deleted;
    
      SET IDENTITY_INSERT history ON;
    
      INSERT INTO history
      VALUES (@ID, @CID, @RID, @Cname, @Csex, @Ctel, @Rdate, @Ldate, @payMoney);
    
      SET IDENTITY_INSERT history OFF;
    END;
    
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Workbench中材料库无法更新,如何解决?
  • ¥20 如何推断此服务器配置
  • ¥15 关于github的项目怎么在pycharm上面运行
  • ¥15 内存地址视频流转RTMP
  • ¥100 有偿,谁有移远的EC200S固件和最新的Qflsh工具。
  • ¥15 有没有整苹果智能分拣线上图像数据
  • ¥20 有没有人会这个东西的
  • ¥15 cfx考虑调整“enforce system memory limit”参数的设置
  • ¥30 航迹分离,航迹增强,误差分析
  • ¥15 Chrome Manifest扩展引用Ajax-hook库拦截请求失败