create function getRemainingCorpusForLoan(splandate varchar(40), sbillid varchar(40)) returns varchar(80)
RETURN (
		SELECT SUM(lfp.corpus) AS sumcorpus FROM LOAN_FUND_PLAN lfp WHERE lfp.bill_id=sbillid AND lfp.plan_date<=splandate GROUP BY lfp.bill_id
	);

