From: | Uro Gruber <uros(at)sir-mag(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Functions in Postgre |
Date: | 2000-12-27 23:20:15 |
Message-ID: | 145447603700.20001228002015@sir-mag.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi!
I have 2 questions.
1. I want to store some data in database (8 different fields) and then
check some other thig and if something is ok i wan't to update some
data. I think i have to use function for this, because i don't want to
send so many queries over the net.
But now i'm confused. Is it ok if i use function with like 8 arguments
or is it better to insert data with normal INSERT query and then use
triger on INSERT wich calls some function to do all the work.
I would like someone to tell me more about this. Because document are
realy bad. Is it some great documents or book out in the net or book
store.
2. I have 3 SELECT queries
- SELECT id,name FROM users WHERE id = '40';
- SELECT id FROM users WHERE id > '40' ORDER BY id ASC LIMIT 1;
- SELECT id FROM users WHERE id < '40' ORDER BY id DESC LIMIT 1;
Now i want to create a function who wil execute al tree.
something like this
CREATE FUNCTION get_user(int4) RETURNS ?? AS '
..
..
..
' LANGUAGE = 'plpgsql'
I want output like this when i call this function ( SELECT
get_user('40');
id name idprev idnext
------------------------------
40 user1 35 42
id's are not one by one but its generated and stored as 23characters
(this 40 is just an example.)
What i want to know is how can i write that function and What should i
put after RETURNS and then how to return data.
Thanks for help
--
Uros
From | Date | Subject | |
---|---|---|---|
Next Message | Rick Vlahov | 2000-12-27 23:59:34 | PostgreSQL on AIX |
Previous Message | Mike Castle | 2000-12-27 20:09:03 | Re: LD_LIBRARY_PATH |