From: | Ron St-Pierre <rstpierre(at)syscor(dot)com> |
---|---|
To: | Marcel Boscher <mboscher(at)emedia-office(dot)de>, pgsql-novice <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Script done... Function won´t wo |
Date: | 2004-08-10 16:03:00 |
Message-ID: | 4118F1B4.3000400@syscor.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Marcel Boscher wrote:
> Once again, ;-)
>
> The script is finally done i hope ...
>
> i can create my function.... no problem
> but when i'm calling it up with a
> SELECT zufall(); statement pgAdmin
> tells me there is no function with that name...
> although its listed in my function list as zufall!!!! ...
> <runningagainstthewallheadfirst>
>
>
> SOURCE:
> create or replace function zufall(int4) returns text as '
> declare
> anzahl alias for $1;
> i int4;
> zeichen char(1);
> zufallstext text;
> entries int8;
> begin
> loop
> zufallstext := '''';
> for i in 1..anzahl loop
> select chr(trunc((random()*26)+65)) into zeichen;
> zufallstext := zufallstext || zeichen;
> end loop;
> SELECT count(*) into entries FROM se_errorcode
> WHERE entry = zufallstext;
> EXIT WHEN entries = 0;
> end loop;
> return zufallstext;
> end;
> ' language 'plpgsql';
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>
>
First, make sure that you're passing in an argument:
SELECT zufall(5);
When I try it on my test db (7.4) I get:
testdb=# SELECT zufall(5);
ERROR: function chr(double precision) does not exist
HINT: No function matches the given name and argument types. You may
need to add explicit type casts.
CONTEXT: PL/pgSQL function "zufall" line 11 at select into variables
so you should also check the arguments and return type of the chr()
function.
Hope that helps.
Ron
From | Date | Subject | |
---|---|---|---|
Next Message | Michal Lijowski | 2004-08-10 16:31:50 | Using pgaccess and xpg |
Previous Message | Ron St-Pierre | 2004-08-10 15:56:54 | Re: DISTINCT ordering |