Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what is the problem in this function

Status
Not open for further replies.

ahmet_sinav

Programmer
May 16, 2007
10
TR
hi all;
Postgres 8.2.x Platform Windows.
Code:

declare toplamtutar double precision;
declare bitkifiyat double precision;
declare alan double precision;
declare intI integer;
declare strSql Varchar;
/* indirim parametreleri */
declare enerji BOOLEAN;
declare damla boolean;
declare pompaj boolean;
declare grup boolean;
declare zam boolean;

declare tenerji smallint;
declare tdamla smallint;
declare tpompaj smallint;
declare tgrup smallint;
/* ilgili beyan sabitlerde girilen beyan zam tarihinden sonra yap?lm??sa
ve beyan zamm? uygulamas? varsa beyan zamm? uygulanarak tahakkuk edilir */
declare beyanzamtarih date;
declare beyantarih date;
declare tzam smallint;

declare toplamindirim smallint;

begin
select into alan
beyan_donum from tbl_beyan where beyan_idno = beyanid;
intI=0;

select into bitkifiyat
bitki_fiyat from tbl_bitki where bitki_idno=bitkiid;

if (bitkifiyat isnull) then
return null;
else
/*ilgili beyanda uygulanmas? gereken indirimler al?n?yor*/
select into enerji, damla, pompaj, grup, zam ,beyantarih
beyan_enerji,beyan_damla,beyan_pompaj,beyan_grup,beyan_beyanzam,beyan_tarih from tbl_beyan
where beyan_idno=beyanid;

select into tenerji, tdamla, tpompaj, tgrup, tzam, beyanzamtarih
beyanparam_enerji,beyanparam_damla,beyanparam_pompaj,beyanparam_grup,beyanparam_zam,beyanparam_zamta rih from tbl_beyanparams
where beyanparam_idno=beyanid;



/* indirimler uygulan?yor
hesab? toplamtutar = ((100-indirim)/100)*toplamtutar */
toplamindirim = 0;
if enerji = true then toplamindirim = toplamindirim + tenerji; end if;
if damla = true then toplamindirim = toplamindirim + tdamla; end if;
if pompaj = true then toplamindirim = toplamindirim + tpompaj; end if;
if grup = true then toplamindirim = toplamindirim + tgrup; end if;

if (zam = true) and (beyantarih <= beyanzamtarih) then toplamindirim = toplamindirim - tzam; end if;
/* toplam tutar */
toplamtutar = (bitkifiyat * alan) * (( 100 - toplamindirim )/100);
intI=1;
loop
/* tarih */

strSql='update tbl_beyan set '||
' beyan_tarih'||intI||
' = (select bitki_taksit'||intI||'tarih from tbl_bitki where'||
' bitki_idno='||bitkiid||') ,'||
' beyan_tutar'||intI||
' = (((select bitki_taksit'||intI||'yuzde from tbl_bitki where'||
' bitki_idno='||bitkiid||')/100)*'||toplamtutar||')'||
' where beyan_idno='||beyanid;
execute strSql;
intI=intI + 1;
if intI=7 then exit; end if;
end loop;

end if;
return strSql;
end;
[/color red]

i'm trying to execute code below
Code:

select "fnc_BeyanCreate"(25,44)


but i'm getting an error below
Code:

ERROR: cannot EXECUTE a null querystring
CONTEXT: PL/pgSQL function "fnc_BeyanCreate" line 70 at execute statement


what is the problem i couldn't understand. it is marking that the null query can not execute its right but in function i'm filling the
StrSql.
Thnks.
 
if only one of the parameters is null
then the whole concatenation will return null

by the way
why do you construct this like this, and not just execute it, at first glance I don't see a reason
 
i solve the problem thnks. it was about the new value as u say.
Regards.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top