/*ALIAS>l_data*/

/*SQLStart>1117*/
ALTER TABLE PAYMENT
    ADD P_INFO BLOB SUB_TYPE 1 SEGMENT SIZE 80,
	ADD P_INVOICEID INTEGER,
    ADD P_INVOICENUMBERS BLOB SUB_TYPE 1 SEGMENT SIZE 80,
	ADD P_INVOICEDATE DATE;
/*SQLStop*/

/*SQLStart>1118*/
UPDATE PAYMENT SET P_INVOICEID=P_FID;
/*SQLStop*/

/*SQLStart>1119*/
ALTER TABLE PAYMENT_HIST
    ADD P_INFO BLOB SUB_TYPE 1 SEGMENT SIZE 80,
	ADD P_INVOICEID INTEGER,
    ADD P_INVOICENUMBERS BLOB SUB_TYPE 1 SEGMENT SIZE 80,
	ADD P_INVOICEDATE DATE;
/*SQLStop*/

/*SQLStart>1120*/
UPDATE PAYMENT_HIST SET P_INVOICEID=P_FID;
/*SQLStop*/

/*DLLStart>1121*/
DLLName=upd063.dll
DLLProc=DoIt
/*DLLStop*/

/*SQLStart>1122*/
create or alter procedure AGETLASTPAY (
    AID integer,
    ATYPE integer)
returns (
    OUTID integer)
as
begin
  select max(payinner.p_num) from payment payinner  where (payinner.p_id=:aid) and
   (payinner.p_type=:atype) and (payinner.p_flags like "__0%")
   and (payinner.P_INVOICENUMBERS is not null)
  into :outid;
  suspend;
end
/*SQLStop*/

/*SQLStart>1123*/
ALTER TABLE PAYMENT 
    DROP P_COMMENT, 
	DROP P_FID,
	DROP P_FNUM, 
	DROP P_FDATE;
/*SQLStop*/

/*SQLStart>1124*/
ALTER TABLE PAYMENT_HIST
    DROP P_COMMENT, 
	DROP P_FID,
	DROP P_FNUM, 
	DROP P_FDATE;
/*SQLStop*/

/*SQLStart>1125*/
delete from system_strings where SYS_ID = 0;
/*SQLStop*/

/*SQLStart>1126*/
insert into system_strings (SYS_ID,SYS_STR) values (0,'1.5.63.1');
/*SQLStop*/
