CREATE PROCEDURE "demoadm".p_k_pmenge( pv_action char(1), pv_mandant char(2), pv_kst char(15), -- .kst pv_skt char(15), -- .skt pv_gjahr decimal(4,0), -- .gjahr pv_periode decimal(2,0), -- 1..12 pv_menge char(15) -- .menge1..12 ) DEFINE dw_oper varchar(50,0); DEFINE err_sql int; DEFINE err_isam int; DEFINE err_txt varchar(150,0); DEFINE err_msg varchar(200,0); DEFINE i int; DEFINE sv_kst_nr char(15); DEFINE sv_kart_nr char(15); DEFINE sv_mandant char(2); DEFINE sv_jahr decimal(4,0); DEFINE sv_periode decimal(2,0); DEFINE sv_menge_plan decimal(22,7); LET dw_oper = ' Start'; BEGIN ON EXCEPTION SET err_sql, err_isam, err_txt LET err_msg = 'ISAM['||err_isam||']:'||err_txt||' #'||dw_oper; INSERT INTO DWE_k_pmenge VALUES (0,err_sql,err_msg,0,'sr_pmenge_sa', pv_action, pv_mandant, pv_kst, pv_skt, pv_gjahr, pv_periode, pv_menge ); SET LOCK MODE TO NOT WAIT; END EXCEPTION; SET LOCK MODE TO WAIT 10; LET dw_oper = ' Computing variables'; LET sv_kst_nr = pv_kst; LET sv_kart_nr = pv_skt; LET sv_mandant = pv_mandant; LET sv_jahr = 1900 + pv_gjahr; LET sv_periode = pv_periode; IF LENGTH(pv_menge) > 0 THEN LET sv_menge_plan = pv_menge; -- text conversion ELSE LET sv_menge_plan = 0.0; END IF -- Negate Values -- IF pv_action = 'D' THEN LET sv_menge_plan = -sv_menge_plan; END IF LET dw_oper = 'Updating sr_pmenge_sa'; UPDATE sr_pmenge_sa SET menge_plan = menge_plan + sv_menge_plan WHERE (kst_nr = sv_kst_nr) AND (kart_nr = sv_kart_nr) AND (mandant = sv_mandant) AND (jahr = sv_jahr) AND (periode = sv_periode) ; IF DBINFO('sqlca.sqlerrd2') < 1 THEN -- No rows updated INSERT INTO sr_pmenge_sa ( mandant, kst_nr, kart_nr, jahr, periode, menge_plan ) VALUES ( sv_mandant, sv_kst_nr, sv_kart_nr, sv_jahr, sv_periode, sv_menge_plan ); END IF SET LOCK MODE TO NOT WAIT; END END PROCEDURE
HTML-Autor: Rohloff, Datenbank: demodb, Datenstand: 31.05.00 17:07