pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedIs this the wrong list?
3+ messages / 3 participants
[nested] [flat]
* Is this the wrong list?
@ 2000-08-16 13:36 Andreas Tille <tillea@rki.de>
2000-08-16 13:54 ` Re: Is this the wrong list? Chris Ryan <chris@greatbridge.com>
2000-08-16 16:25 ` Re: Is this the wrong list? Stephan Szabo <sszabo@megazone23.bigpanda.com>
0 siblings, 2 replies; 3+ messages in thread
From: Andreas Tille @ 2000-08-16 13:36 UTC (permalink / raw)
To: PostgreSQL General <pgsql-general@postgresql.org>
On Mon, 14 Aug 2000, I wrote under the subject "Any SQL-functions examples
available":
> I tried to write my first SQL-functions with the intention to
> port some stored procedures from MS SQL server. It would make my
> task much simpler if someone could point me to some simple
> examples which demonstate the use of function parameters in
> SELECT/INSERT statements and how to get the results transformed
> into reasonable return types, for instance if SELECT was successful
> return true else false, etc.
Is there any other list where I could expect answers to those simple
questions. I could not imagine that nobody has ever written some
simple tests with SQL functions. Perhaps this problem is to simple
here.
Or may be I have the wrong philosophy and those functions are not
ment to be used in PostgreSQL?
Kind regards
Andreas.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Is this the wrong list?
2000-08-16 13:36 Is this the wrong list? Andreas Tille <tillea@rki.de>
@ 2000-08-16 13:54 ` Chris Ryan <chris@greatbridge.com>
1 sibling, 0 replies; 3+ messages in thread
From: Chris Ryan @ 2000-08-16 13:54 UTC (permalink / raw)
To: Andreas Tille <tillea@rki.de>; +Cc: PostgreSQL General <pgsql-general@postgresql.org>
You'd probably be better off in pgsql-sql@postgresql.org. Also look
under the programmers documention for the interfaces (Specific interface
questions should probably go to pgsql-interfaces@postgresql.org) There
are ways to functions in Sql, PL/PgSQL, TCL etc. etc. It all depends on
what you need to do.
Here is a quick example on writing an sql procedure with parameters:
(create table and add some data)
CREATE FUNCTION get_user_age(int4) RETURNS int4
AS 'select user_age from user_tbl where user_id = $1' LANGUAGE
'sql';
select get_user_age(2);
get_user_age
--------------
13
(1 row)
Chris Ryan
Andreas Tille wrote:
>
> On Mon, 14 Aug 2000, I wrote under the subject "Any SQL-functions examples
> available":
>
> > I tried to write my first SQL-functions with the intention to
> > port some stored procedures from MS SQL server. It would make my
> > task much simpler if someone could point me to some simple
> > examples which demonstate the use of function parameters in
> > SELECT/INSERT statements and how to get the results transformed
> > into reasonable return types, for instance if SELECT was successful
> > return true else false, etc.
> Is there any other list where I could expect answers to those simple
> questions. I could not imagine that nobody has ever written some
> simple tests with SQL functions. Perhaps this problem is to simple
> here.
>
> Or may be I have the wrong philosophy and those functions are not
> ment to be used in PostgreSQL?
>
> Kind regards
>
> Andreas.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Is this the wrong list?
2000-08-16 13:36 Is this the wrong list? Andreas Tille <tillea@rki.de>
@ 2000-08-16 16:25 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
1 sibling, 0 replies; 3+ messages in thread
From: Stephan Szabo @ 2000-08-16 16:25 UTC (permalink / raw)
To: Andreas Tille <tillea@rki.de>; +Cc: PostgreSQL General <pgsql-general@postgresql.org>
On Wed, 16 Aug 2000, Andreas Tille wrote:
> On Mon, 14 Aug 2000, I wrote under the subject "Any SQL-functions examples
> available":
>
> > I tried to write my first SQL-functions with the intention to
> > port some stored procedures from MS SQL server. It would make my
> > task much simpler if someone could point me to some simple
> > examples which demonstate the use of function parameters in
> > SELECT/INSERT statements and how to get the results transformed
> > into reasonable return types, for instance if SELECT was successful
> > return true else false, etc.
> Is there any other list where I could expect answers to those simple
> questions. I could not imagine that nobody has ever written some
> simple tests with SQL functions. Perhaps this problem is to simple
> here.
>
> Or may be I have the wrong philosophy and those functions are not
> ment to be used in PostgreSQL?
I think the thing is that most people don't have basic examples, they
have whatever things they particularly needed. However, there
are a couple defined in the create_function_2 regression test.
CREATE FUNCTION hobbies(person)
RETURNS setof hobbies_r
AS 'select * from hobbies_r where person = $1.name'
LANGUAGE 'sql';
CREATE FUNCTION hobby_construct(text, text)
RETURNS hobbies_r
AS 'select $1 as name, $2 as hobby'
LANGUAGE 'sql';
CREATE FUNCTION equipment(hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = $1.name'
LANGUAGE 'sql';
CREATE FUNCTION user_relns()
RETURNS setof name
AS 'select relname
from pg_class
where relname !~ ''pg_.*'' and
relkind <> ''i'' '
LANGUAGE 'sql';
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2000-08-16 16:25 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-08-16 13:36 Is this the wrong list? Andreas Tille <tillea@rki.de>
2000-08-16 13:54 ` Chris Ryan <chris@greatbridge.com>
2000-08-16 16:25 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
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