pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ismail Kizir <ikizir@teklan.com.tr>
To: pgsql-sql@postgreSQL.org
Subject: ERROR:  unexpected SELECT query in exec_stmt_execsql()
Date: Wed, 13 Oct 1999 10:20:34 +0300
Message-ID: <001501bf154b$ab9eba20$5500aec3@kaplan> (raw)

Hi all,

I had the error message in subject when i ran first time the function below.
Can someone explain me what does it mean and what i must do to avoid it?
Thanks in advance.

Regards
Ismail Kizir

CREATE FUNCTION fOdemesiGereken  (bpchar, int2, int2,boolean) RETURNS float8
AS '
DECLARE
  pOkulNo ALIAS FOR $1; -- Okul numarasý
  pYil ALIAS FOR $2;    -- Yil
  pDonem ALIAS FOR $3;  -- Dönem

  -- Borçlandýrýlan dönem 1. dnm. ise ve öðrenci krediye baþvurmuþsa
borçlandýrýlmaz
  pKrdBasvuraniBorclandirma ALIAS FOR $4;

  tmpint int2;
  IkiliOkuyor boolean;
  Sonuc float8;
  tmpfloat float8;
  OgrRec ogrkutuk%ROWTYPE;
BEGIN
  SELECT * INTO OgrRec from ogrkutuk WHERE okulno = pOkulNo;
  IF NOT FOUND THEN
    RAISE EXCEPTION \'Öðrenci bulunamadý. No : % \', pOkulNo;
  END IF;
  -- Kayýt donduran öðrenci o yýl ve dönem için harç ödemez
  SELECT yil FROM KayitDon INTO tmpint WHERE okulno = pOkulNo AND yil = pYil
AND donem = pdonem;
  IF FOUND THEN
    return 0.0;
  END IF;
  -- Öðrenci ikili öðretimde okuyorsa,
  IF OgrRec.OgrenimTipi = 1 THEN
    SELECT yil FROM IlkYuzdeOn INTO tmpint WHERE okulno = pOkulNo AND yil =
pYil;
    -- Ýlk yüzde ona girdiðinden dolayý normal harç mý ödeyecek?
    IF NOT FOUND THEN
      SELECT IkiliHarc FROM fakdetay INTO sonuc WHERE FBKODU =
OgrRec.FbKodu;
      IF NOT FOUND THEN
        RAISE EXCEPTION \' % kodlu fakültenin % yýlýna ait harç bilgisi
bulunamadý\', OgrRec.FbKodu, pYil;
      END IF;
      IkiliOkuyor := TRUE;
    ELSE
      IkiliOkuyor := FALSE;
      SELECT OrgunHarc FROM fakdetay INTO sonuc WHERE FBKODU =
OgrRec.FbKodu;
      IF NOT FOUND THEN
        RAISE EXCEPTION \' % kodlu fakültenin % yýlýna ait harç bilgisi
bulunamadý\', OgrRec.FbKodu, pYil;
      END IF;
    END IF;
  END IF;

  -- Öðrenci daha önce bir üniversite bitirmiþ ise iki katý harç öder
  IF OgrRec.IkinciUniversite THEN
    Sonuc := Sonuc * 2.0;
  END IF;

  -- Eðer yabancý dilde öðrenim görüyorsa
  -- Ýkili öðrenimde 1.5
  -- Örgün öðrenimde 2 katý harç öder
  IF OgrRec.YabanciDil THEN
    IF IkiliOkuyor THEN
      Sonuc := Sonuc * 1.5;
    ELSE
      Sonuc := Sonuc * 2.0;
    END IF;
  END IF;

  -- Eðer yabancý uyruklu ise,
  IF (OgrRec.Uyruk <> 2425) AND (NOT OgrRec.IkiliAnlasma) THEN
    IF pDonem = 1 THEN
      IF IkiliOkuyor THEN
        Sonuc := Sonuc * 2.0;  -- 2. Öðretimde iki katý
      ELSE
        Sonuc := Sonuc * 3.0;  -- Örgün Öðretimde üç katý
      END IF;
    ELSE
      return 0.0;  -- Yabancý uyruklular ikinci dönemde harç ödemez
    END IF;
  ELSE
    Sonuc := Sonuc / 2.0;  -- Türk uyruklular harcý iki eþit taksitte öder
  END IF;

  -- Normal süresinde bitiremeyenler ilk yýl %50 daha sonra %100 zam öder
  IF NOT (OgrRec.YElliZamBas ISNULL) THEN
    IF pYil = OgrRec.YElliZamBas THEN
      Sonuc := Sonuc * 1.5;
    ELSE
      IF pYil > OgrRec.YElliZamBas THEN
        Sonuc := Sonuc * 2.0;
      END IF;
    END IF;
  END IF;

  -- Eðer pKrdBasvuraniBorclandirma parametresi TRUE ise,
  IF pKrdBasvuraniBorclandirma THEN
    SELECT yil FROM KrediBasvuru INTO tempint WHERE OkulNo = pOkulNo AND Yil
= pYil;
    IF NOT FOUND
      return Sonuc;
    ELSE
      IF pDonem = 1 THEN
        return 0.0;
      END IF;
      return Sonuc * 2;
    END IF;
  END IF;
  return Sonuc;
END;
' LANGUAGE 'plpgsql';





view thread (2+ messages)  latest in thread

Message-ID: <001501bf154b$ab9eba20$5500aec3@kaplan>
Permalink:  ../001501bf154b$ab9eba20$5500aec3@kaplan/
Also on:    postgresql.org/message-id/001501bf154b$ab9eba20$5500aec3@kaplan

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: ikizir@teklan.com.tr
  Subject: Re: ERROR:  unexpected SELECT query in exec_stmt_execsql()
  In-Reply-To: <001501bf154b$ab9eba20$5500aec3@kaplan>
  References: <001501bf154b$ab9eba20$5500aec3@kaplan>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox