现在的位置: 首页 > 综合 > 正文

在相同主键的两个表A,B中,按表A存在的记录删除表B中不存在的记录

2013年10月08日 ⁄ 综合 ⁄ 共 941字 ⁄ 字号 评论关闭

在相同的主鍵的兩個表中,按表A存在記錄刪除表B的中不存在的記錄

/******************************************/

/*define check_i_ftyandpric_data procedure with sybase*/

 create procedure check_i_ftyandpric_data
(@oc_number char(8),
@result char(1) output
)
as
    select @result='1'
begin
    delete from i_ftyandpric
    where oc_number =@oc_number
    and oc_number+itemnumber+convert(char(14),shipp_date,1)+factory_id
    not in(
        select oc_number+itemnumber+convert(char(14),shipp_date,1)+factory_id
        from o_factoryqty
        where oc_number = @oc_number
    )
    select @result='0'
end

 

/****************************************************************/

/*run check_i_ftyandpric_data procedure with pb*/

string chk_oc,ls_code
chk_oc=trim(sle_1.text)
DECLARE b_i_ftyandprice_ck PROCEDURE FOR dbo.check_i_ftyandpric_data   
@oc_number = :chk_oc,
@result = :ls_code OUTPUT;
execute b_i_ftyandprice_ck;
fetch b_i_ftyandprice_ck into :ls_code;
close b_i_ftyandprice_ck;
commit;
if ls_code<>'0' then
    messagebox('Warning!','check data Error !')
end if

 

抱歉!评论已关闭.