Re: Calling Functions - Mailing list pgsql-sql

From Josh Berkus
Subject Re: Calling Functions
Date
Msg-id web-129183@davinci.ethosmedia.com
Whole thread Raw
In response to Re: On Differing Optimizer Choices ( Again)  (Oleg Lebedev <olebedev@waterford.org>)
List pgsql-sql
Oleg,

> Hi,
> this is a very silly question, but how do I run PL/pgSQL function
> from SQL?
> I created a function test(varchar, varchar) and I am trying to invoke
> it with
> parameters 'hello', 'world' using an SQL statement. I tried selects
> and executes
> - nothing works.
> Please help,

SELECT test('hello','world');

If you aren't getting the result you expect, then you have made a
mistake in your function name, parameters, return type, or a syntax
error in the function itself.

For example, if you do in fact have the function:

CREATE FUNCTION test (VARCHAR, VARCHAR) RETURNS VARCHAR AS '
DECLARE ....

And if
SELECT test('hello','world');
returns
Parser Error at or near ';'
then the database is telling you that you have a bad function, not that
it doesn't understand the SELECT.

-Josh


______AGLIO DATABASE SOLUTIONS___________________________
                                       Josh Berkus
  Complete information technology      josh@agliodbs.com
   and data management solutions       (415) 565-7293
  for law firms, small businesses        fax 621-2533
    and non-profit organizations.      San Francisco

Attachment

pgsql-sql by date:

Previous
From: Oleg Lebedev
Date:
Subject: Re: On Differing Optimizer Choices ( Again)
Next
From: Markus Wagner
Date:
Subject: using SQL to evaluate arbitrary expressions?