CREATE OR REPLACE FUNCTION f_import_delete_main(IN _itemcd integer, OUT errcd integer, OUT errmsg character varying, OUT code integer) AS
$BODY$

DECLARE

BEGIN
    -- 更新処理
    
    -- 品目基本属性 削除
    DELETE FROM t_item_basic_attr WHERE itemcd = _itemcd;
    
    -- 品目構成 削除
    DELETE FROM t_item_struct WHERE itemcd = _itemcd;
    
    -- 品目ウェブ属性 削除
    DELETE FROM t_item_web_attr WHERE itemcd = _itemcd;

    -- 出品在庫明細 削除
    DELETE FROM t_ex_stock_detail WHERE itemcd = _itemcd;

    -- ジャンル 削除
    DELETE FROM t_genre_item WHERE itemcd = _itemcd;
    
    -- キャスト 削除
    DELETE FROM t_cast_item WHERE itemcd = _itemcd;
    
    errcd := 1;
    errmsg := '完了';
END;

$BODY$
  LANGUAGE 'plpgsql' VOLATILE;