Thread: Syntax Error

Syntax Error

From
Marcel Boscher
Date:
Hey there,

ERROR:  function round(double precision, integer, integer) does not exist
Any suggestions

Purpose is to generate a 4 digit errorcode 1st letter alpha - rest numeric

my source code:

DECLARE
    chars         nchar(26);
    charpos     INTEGER;
    character     nchar(4);
    nentries    INTEGER;
    key         INTEGER;

BEGIN
chars := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
charpos := Round((random() * (length(chars)-1)), 0, 0);
character := SubString(chars, charpos, 1)  ;

    nentries := 1;
    WHILE (nentries > 0) LOOP
        key := trunc(random() * 10000);

SELECT eCode = character + key

SELECT
            INTO nentries
            count(*)
            FROM se_errorcode
            WHERE se_errorcode.entry = eCode;
    END LOOP;

    INSERT
        INTO se_errorcode (entry)
        VALUES (eCode);

    RETURN(eCode);
END;

Thx in advance
Marcel

Re: Syntax Error

From
Oliver Elphick
Date:
On Tue, 2004-08-10 at 13:44, Marcel Boscher wrote:
> Hey there,
>
> ERROR:  function round(double precision, integer, integer) does not exist
> Any suggestions

No such function is defined.

According to the manual there are:

   round(double precision)
   round(numeric)
   round(numeric, integer)

The second parameter of the last one specifies the number of decimal
places.

--
Oliver Elphick                                          olly@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA  92C8 39E7 280E 3631 3F0E  1EC0 5664 7A2F A543 10EA
                 ========================================
     "Be still before the LORD and wait patiently for him;
      do not fret when men succeed in their ways, when they
      carry out their wicked schemes."
                            Psalms 37:7