Subject | script formatter |
---|---|
Author | Wiesław Poszewiecki |
Post date | 2008-02-26T18:10:04Z |
Hi,
I am finishing my work on formatter
for firebird isql scripts.
It will be free and open source.
I need scripts to test it.
Can anybody help me with it?
I attached a sample formatted procedure.
regards
Wiesiek
----------
ALTER PROCEDURE mr_rozra_kpw
(p_id_kpw BIGINT)
AS
DECLARE z_firma BIGINT;
DECLARE z_rodzaj_kpw VARCHAR (2);
DECLARE z_okres VARCHAR (7);
DECLARE z_rodzaj CHAR (1);
DECLARE z_id_konto BIGINT;
DECLARE z_id_roz BIGINT;
DECLARE z_opis VARCHAR (30) CHARACTER SET win1250;
DECLARE z_numer_rach VARCHAR (20) CHARACTER SET win1250;
DECLARE z_kwota DECIMAL (18,2);
DECLARE z_id_poz_sl BIGINT;
BEGIN
SELECT k.id_firma, kpw.rodzaj, kpw.id_poz_sl
FROM mr_raport r, mr_kpw kpw, mr_kasa k
WHERE kpw.id_raport=r.id
AND kpw.id=:p_id_kpw
AND k.id=r.id_kasa
INTO z_firma, z_rodzaj_kpw, z_id_poz_sl;
SELECT MAX (id_okres)
FROM mr_okres
WHERE id_firma=:z_firma
INTO z_okres;
FOR
SELECT k.id, k.rozrachunki
FROM mr_konta_el_slownika (:z_id_poz_sl) k, mr_konto ke, mr_obroty o
WHERE ke.id=k.id
AND k.id=o.id
AND k.id_firma=:z_firma
AND o.okres=:z_okres
AND ( :z_rodzaj_kpw='KP'
AND (o.saldo_wn>0 OR o.saldo_ma<0)
OR :z_rodzaj_kpw='KW'
AND (o.saldo_wn<0 OR o.saldo_ma>0))
INTO z_id_konto, z_rodzaj
DO
FOR
SELECT r.id id_roz, r.opis, r.numer_rach,
CASE
WHEN (r.typ||:z_rodzaj||:z_rodzaj_kpw) IN ('TNKP','ZZKP','TZKW','ZNKW') THEN r.kwota_zostala
ELSE -r.kwota_zostala
END kwota
FROM mr_rozr r
WHERE r.id_konto=:z_id_konto
AND r.stan='N'
INTO z_id_roz, z_opis, z_numer_rach,
z_kwota
DO
INSERT INTO mr_poz_kpw
(id, id_nag, id_konto,
id_roz, opis, numer_rach,
kwota)
VALUES (GEN_ID (mr_inne_seq,1), :p_id_kpw, :z_id_konto,
:z_id_roz, :z_opis, :z_numer_rach,
:z_kwota);
END
^
[Non-text portions of this message have been removed]
I am finishing my work on formatter
for firebird isql scripts.
It will be free and open source.
I need scripts to test it.
Can anybody help me with it?
I attached a sample formatted procedure.
regards
Wiesiek
----------
ALTER PROCEDURE mr_rozra_kpw
(p_id_kpw BIGINT)
AS
DECLARE z_firma BIGINT;
DECLARE z_rodzaj_kpw VARCHAR (2);
DECLARE z_okres VARCHAR (7);
DECLARE z_rodzaj CHAR (1);
DECLARE z_id_konto BIGINT;
DECLARE z_id_roz BIGINT;
DECLARE z_opis VARCHAR (30) CHARACTER SET win1250;
DECLARE z_numer_rach VARCHAR (20) CHARACTER SET win1250;
DECLARE z_kwota DECIMAL (18,2);
DECLARE z_id_poz_sl BIGINT;
BEGIN
SELECT k.id_firma, kpw.rodzaj, kpw.id_poz_sl
FROM mr_raport r, mr_kpw kpw, mr_kasa k
WHERE kpw.id_raport=r.id
AND kpw.id=:p_id_kpw
AND k.id=r.id_kasa
INTO z_firma, z_rodzaj_kpw, z_id_poz_sl;
SELECT MAX (id_okres)
FROM mr_okres
WHERE id_firma=:z_firma
INTO z_okres;
FOR
SELECT k.id, k.rozrachunki
FROM mr_konta_el_slownika (:z_id_poz_sl) k, mr_konto ke, mr_obroty o
WHERE ke.id=k.id
AND k.id=o.id
AND k.id_firma=:z_firma
AND o.okres=:z_okres
AND ( :z_rodzaj_kpw='KP'
AND (o.saldo_wn>0 OR o.saldo_ma<0)
OR :z_rodzaj_kpw='KW'
AND (o.saldo_wn<0 OR o.saldo_ma>0))
INTO z_id_konto, z_rodzaj
DO
FOR
SELECT r.id id_roz, r.opis, r.numer_rach,
CASE
WHEN (r.typ||:z_rodzaj||:z_rodzaj_kpw) IN ('TNKP','ZZKP','TZKW','ZNKW') THEN r.kwota_zostala
ELSE -r.kwota_zostala
END kwota
FROM mr_rozr r
WHERE r.id_konto=:z_id_konto
AND r.stan='N'
INTO z_id_roz, z_opis, z_numer_rach,
z_kwota
DO
INSERT INTO mr_poz_kpw
(id, id_nag, id_konto,
id_roz, opis, numer_rach,
kwota)
VALUES (GEN_ID (mr_inne_seq,1), :p_id_kpw, :z_id_konto,
:z_id_roz, :z_opis, :z_numer_rach,
:z_kwota);
END
^
[Non-text portions of this message have been removed]