how use procedure with sybase database?
author:chinayaosir
blog:http://blog.csdn.net/chinayaosir
1.auto create a question ?
when user delete /insert data in o_factoryqty,
then total rows of i_ftyandpric <> o_factoryqty by one oc_number?
table-name:i_ftyandpric,primary key:oc_number,itemnumber,shipp_date,factory_id
table-name:o_factoryqty,primary key:oc_number,itemnumber,shipp_date,factory_id
2. sql code test in sybase database
select oc_number+itemnumber+convert(char(14),shipp_date,1)+factory_id
from i_ftyandpric
where oc_number like "M05MB0%"
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 like "M05MB0%"
)
the data of sql run value,pls see below
M05MB018BY35343 11/12/04 HUA LONG/H
M05MB029BY35662 11/13/04 YUNGFENG/C
M05MB029BY35664 11/13/04 YUNGFENG/C
M05MB036BY34949 12/31/04 FOREVER/H
M05MB055BY35483 11/05/04 NEW IDEA/H
M05MB055BY35649 11/05/04 NEW IDEA/H
M05MB055BY35650 11/05/04 NEW IDEA/H
M05MB056BV30495 11/05/04 NEW IDEA/H
M05MB057BY35649 11/17/04 NEW IDEA/H
M05MB057BY35650 11/17/04 NEW IDEA/H
M05MB058BY35052 11/19/04 NEW IDEA/H
M05MB059BY35391 11/21/04 NEW IDEA/H
M05MB061BY34789 11/20/04 NEW IDEA/H
M05MB071BY34084 11/22/04 NEW IDEA/H
3.//define procedure
//create procedure with powerbuilder
//clear data with check_i_ftyandpric_data procedure
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
4.run procedure
//when clicked a save button,then call code with powerbuilder.
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!','delete data Error !')
end if