저장 프로세스 (스크롤 +if 문장 + 되돌아오는 매개 변수 + 클래스 수신 매개 변수) 실례
7880 단어 저장 프로세스
CREATE PROCEDURE change_product
@result varchar(50) output,
@product_no varchar(50),
@color varchar(50),
@product_size varchar(50),
@oldcolor varchar(50),
@oldproduct_size varchar(50),
@stockid int,
@oldstockid int,
@number int,
@users varchar(50),
@orderno varchar(50),
@memo_product_inout_record text
AS
declare @stockname varchar(50)
declare @oldstockname varchar(50)
declare @color2 varchar(50)
begin TRANSACTION
declare @nror int
set @nror=0
if @stockid>0 and @oldstockid>0
begin
select @stockname=stockname from tbl_stockid where stockid=@stockid
select top 1 @color2=color2 from tbl_productstore where product_no=@product_no and color=@color
select @oldstockname=stockname from tbl_stockid where stockid=@oldstockid
/* */
if @oldstockid=1 or @oldstockid=2 or @oldstockid=3
begin
/* */
if @stockid=1 or @stockid=2 or @stockid=3
begin
update tbl_productstore set number=number+@number,lock_number=lock_number-@number where product_no=@product_no and color=@oldcolor and product_size=@oldproduct_size and stockid=@oldstockid
set @nror=@nror+@@error
insert into tbl_product_inout_record
(product_no,color,product_size,number2,stock,users,operation_type,operation,memo)
values (@product_no,@oldcolor,@oldproduct_size,@number,@oldstockname,@orderno+'|'+@users,' ',' ',@memo_product_inout_record)
set @nror=@nror+@@error
update tbl_productstore set number=number-@number,lock_number=lock_number+@number where product_no=@product_no and color=@color and product_size=@product_size and stockid=@stockid
set @nror=@nror+@@error
insert into tbl_product_inout_record
(product_no,color,product_size,number2,stock,users,operation_type,operation,memo)
values (@product_no,@color,@product_size,0-@number,@stockname,@orderno+'|'+@users,' ',' ',@memo_product_inout_record)
set @nror=@nror+@@error
update tbl_trade set stockid=@stockid,color=@color,product_size=@product_size,color2=@color2 where orderno=@orderno
set @nror=@nror+@@error
end
/* */
else if @stockid=4 or @stockid=5
begin
update tbl_productstore set number=number+@number,lock_number=lock_number-@number where product_no=@product_no and color=@oldcolor and product_size=@oldproduct_size and stockid=@oldstockid
set @nror=@nror+@@error
insert into tbl_product_inout_record
(product_no,color,product_size,number2,stock,users,operation_type,operation,memo)
values (@product_no,@oldcolor,@oldproduct_size,@number,@oldstockname,@orderno+'|'+@users,' ',' ',@memo_product_inout_record)
set @nror=@nror+@@error
update tbl_productstore set number=number-@number,lock_number=lock_number+@number where product_no=@product_no and color=@color and product_size=@product_size and stockid=@stockid
set @nror=@nror+@@error
update tbl_trade set stockid=@stockid,color=@color,product_size=@product_size,color2=@color2 where orderno=@orderno
set @nror=@nror+@@error
end
end
/* */
if @oldstockid=4 or @oldstockid=5
begin
/* */
if @stockid=1 or @stockid=2 or @stockid=3
begin
update tbl_productstore set number=number+@number,lock_number=lock_number-@number where product_no=@product_no and color=@oldcolor and product_size=@oldproduct_size and stockid=@oldstockid
set @nror=@nror+@@error
update tbl_productstore set number=number-@number,lock_number=lock_number+@number where product_no=@product_no and color=@color and product_size=@product_size and stockid=@stockid
set @nror=@nror+@@error
insert into tbl_product_inout_record
(product_no,color,product_size,number2,stock,users,operation_type,operation,memo)
values (@product_no,@color,@product_size,0-@number,@stockname,@orderno+'|'+@users,' ',' ',@memo_product_inout_record)
set @nror=@nror+@@error
update tbl_trade set stockid=@stockid,color=@color,product_size=@product_size,color2=@color2 where orderno=@orderno
set @nror=@nror+@@error
end
/* */
else if @stockid=4 or @stockid=5
begin
update tbl_productstore set number=number+@number,lock_number=lock_number-@number where product_no=@product_no and color=@oldcolor and product_size=@oldproduct_size and stockid=@oldstockid
set @nror=@nror+@@error
update tbl_productstore set number=number-@number,lock_number=lock_number+@number where product_no=@product_no and color=@color and product_size=@product_size and stockid=@stockid
set @nror=@nror+@@error
update tbl_trade set stockid=@stockid,color=@color,product_size=@product_size,color2=@color2 where orderno=@orderno
set @nror=@nror+@@error
end
end
end
if @nror<>0
begin
set @result=' '
rollback transaction
end
else
begin
set @result=' '
commit transaction
end
GO
public string chang_product(string product_no,string color,string product_size,string oldcolor,string oldproduct_size,int stockid,int oldstockid,int number,string users,string orderno,string memo_product_inout_record)
{
con = new SqlConnection(shopcon);
con.Open();
com = new SqlCommand("change_product", con);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.Add("@product_no",product_no );
com.Parameters.Add("@color",color );
com.Parameters.Add("@product_size",product_size);
com.Parameters.Add("@oldcolor", oldcolor);
com.Parameters.Add("@oldproduct_size",oldproduct_size);
com.Parameters.Add("@stockid",stockid );
com.Parameters.Add("@oldstockid",oldstockid );
com.Parameters.Add("@number",number );
com.Parameters.Add("@users",users );
com.Parameters.Add("@orderno",orderno );
com.Parameters.Add("@memo_product_inout_record",memo_product_inout_record);
com.Parameters.Add(new SqlParameter("@result", SqlDbType.NVarChar, 30));
com.Parameters["@result"].Direction = ParameterDirection.Output;
com.ExecuteNonQuery();
string result = com.Parameters["@result"].Value.ToString();
con.Close();
com.Dispose();
return result;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Java 호출 Oracle 스토리지 프로세스 상세 정보Java 호출 Oracle 스토리지 프로세스 상세 정보 단계: 1. Oracle 스토리지 프로세스 작성 2. 데이터베이스 작성 연결 도구 클래스 얻기 3. 간단한 응용 프로그램 호출 저장 프로세스 작성 구현: 1. ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.