Обсуждение: Execute a function?

Поиск
Список
Период
Сортировка

Execute a function?

От
"Steve - DND"
Дата:
I'm completely baffled here. I've created a function, but how can I execute
it? I tried opening up the SQL editor window and typed:

test_function(20, 32);
received: ERROR:  syntax error at or near "test_function" at character 1

I then tried:
EXECUTE my_function(20, 32);
received: ERROR:  prepared statement "test_function" does not exist

What the heck do I have to do to execute my functions to see the results of
them? The function exists, it shows up in the list of functions for the DB.
This seems so stupidly simple, and it probably is, so what am I doing wrong?

Thanks,
Steve




Re: Execute a function?

От
"Mark A. Taff"
Дата:
On Monday 14 March 2005 21:31, you wrote:
> I'm completely baffled here. I've created a function, but how can I execute
> it? I tried opening up the SQL editor window and typed:
>
> test_function(20, 32);
> received: ERROR:  syntax error at or near "test_function" at character 1
>
> I then tried:
> EXECUTE my_function(20, 32);
> received: ERROR:  prepared statement "test_function" does not exist
>
> What the heck do I have to do to execute my functions to see the results of
> them? The function exists, it shows up in the list of functions for the DB.
> This seems so stupidly simple, and it probably is, so what am I doing
> wrong?
>
> Thanks,
> Steve
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
Been a _very_long while, but try:

SELECT my_function(param_1, param_2) As Answer;
--
Mark A. Taff

Re: Execute a function?

От
"Steve - DND"
Дата:
> Been a _very_long while, but try:
>
> SELECT my_function(param_1, param_2) As Answer;

Yep, that did it. I'm such a newb with PG, still trying everything the MSSQL
way first. Is that the proper way to do it even if you have a function that
returns void?

Steve




Re: Execute a function?

От
Sim Zacks
Дата:
If you have a function that returns a recordset instead of just a
value then you would have to do a select * from functionname
You can also try reading the documentation on functions. I believe
section 35 discusses the various pl languages.

Sim
__________________________________________________________

> Been a _very_long while, but try:
>
> SELECT my_function(param_1, param_2) As Answer;

Yep, that did it. I'm such a newb with PG, still trying everything the MSSQL
way first. Is that the proper way to do it even if you have a function that
returns void?

Steve



---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
              http://www.postgresql.org/docs/faq



Re: Execute a function?

От
"Dave Page"
Дата:

> -----Original Message-----
> From: pgadmin-support-owner@postgresql.org
> [mailto:pgadmin-support-owner@postgresql.org] On Behalf Of Steve - DND
> Sent: 15 March 2005 05:55
> To: Mark A. Taff; pgadmin-support@postgresql.org
> Subject: Re: [pgadmin-support] Execute a function?
>
> > Been a _very_long while, but try:
> >
> > SELECT my_function(param_1, param_2) As Answer;
>
> Yep, that did it. I'm such a newb with PG, still trying
> everything the MSSQL
> way first. Is that the proper way to do it even if you have a
> function that
> returns void?

Yeah, though you'd omit the 'As Answer' (which will fold to lower case
without quotes btw). That bit just gives the resulting column an alias.

Regards, Dave