Welcome to All About PostgreSQL
Links to Visit
- PostgreSQL
- The Official PostgreSQL Home Page.
- PostgreSQL DB News
- News and Commentary regarding the open source database, PostgreSQL.
- EnterpriseDB News
- News and Commentary regarding EnterpriseDB, the Oracle compatible database built from PostgreSQL.
- EnterpriseDB Postgres Resource Center
- EnterpriseDB Postgres Resource Center: Forums, Documentation, Support, Downloads
- PostgreSQL Mail Lists
- Postgres Related Mail Lists
Create a simple function in Postgres PL/pgSQL
RETURNS CHAR VARYING(25)
AS $$
DECLARE
local_char_var CHAR(30);
BEGIN
SELECT datname
INTO local_char_var
FROM pg_database
LIMIT 1;
RETURN local_char_var;
END;
$$ LANGUAGE plpgsql;
Ok. Now we'll go through it line by line:
1. CREATE OR REPLACE FUNCTION func_1() - This line creates and names the function. The "OR REPLACE" will let us modify the function without fir DROPping it. func_1 can be any valid PLpgSQL name. Even if you are not declaring parameters, you must include the parenthesis ().
2. RETURNS CHAR VARYING(25) - RETURNS is the keyword that signifies what data type the function will be returing. RETURN is the equivalent in PL/SQL. Notice the S. CHAR VARYING is the equivalent of a VARCHAR2 in PL/SQL. In this case it will be a VARCHAR2(25).
3. AS $$ - AS is the same as the PL/SQL AS. The $$ is the function code delimiter. You can actually use single quotes here instead of $$ but in that case you would need to double all the quotes in your code. If that doesn't make sense, just consider the $$ mandatory. PLpgSQL is a more basic language than PL/SQL. The code is stored as text and compiled as it is run. The entire function body is just a string and the $$ is the delimiter.
Read the rest of this entry.
Call a Function in PL/pgSQL
SELECT func_1();
Or
SELECT * FROM func_1();
The PostgreSQL Blog Feed
Blog Feeds From Around the Web
If you don't see your favorite blog here, send me a note and I will add it!
Fetching RSS feed... please stand byPostgres Comparisons
- PostgreSQL vs Firebird, August 2007 (and hopefully it will remain updated)
- PostgreSQL vs. SQL Server: PostgreSQL is right for the Microsoft stack, SearchEntepriseLinux May 15, 2006
- PostgreSQL vs. Oracle: Users speak out, SeachOracle April 6, 2006
- Oracle 10g vs PostgreSQL 8 vs MySQL 5, This one I wrote, Aug 22, 2005
- MySQL vs. PostgreSQL, Aug 9, 2005
- PostgreSQL vs MySQL with Rails, June 18, 2005
- PostgreSQL or MySQL - Feb 15 2005, a fairly nice comparison actually.
- PostgreSQL vs. MySQL vs. Commercial Databases: It's All About What You Need - DevX April 12, 2004
- PostgreSQL vs MySQL: Which is better?, DatabaseJournal Dec 16, 2003
- Firebird vs Postgres, Forum Post, April 23, 2002
- PostgreSQL vs. MySQL (Web Techniques, Sep 2001), Dr Dobbs, Jan 1, 2002
PostgreSQL Plexo
Which is the BEST PostgreSQL book?
Vote UP for your favorite or vote DOWN the one you hate! Add your own, too!
PostgreSQL (2nd Edition) (Developer's Library) by Korry Douglas
This is my favorite PostgreSQL book. It's good for more...1 point
Beginning PHP and PostgreSQL 8: From Novice to Professional by W. Jason Gilmore
This is probably my second favorite postgres book. more...1 point
Beginning Databases with PostgreSQL: From Novice to Professional, Second Edition (Beginning from Novice to Professional) by Neil Matthew
Another good book but not as in depth as some othe more...0 points
PostgreSQL: Introduction and Concepts by Bruce Momjian
A classic but somewhat dated now.0 points
PostgreSQL and OSD News
Fetching RSS feed... please stand byPostgreSQL Stuff on CafePress
New Guestbook
ChipsTrip wrote...
Hi, This is a valuable hub. Very useful.
Does anybody else out here need a travel break?
...what can you do if travel is a dim dream? Here is a short term solution. Travel virtually!
Example: On this travel quiz you can even add your own questions to create a personal touch.
http://www.mystudiyo.com/act61911/mini/go/travel_the_world_quiz
Its easy to drift away into these travel video guides.
Even for those of us who love travel it is not always easy to get out there. These guys created a short-term solution. 19 countries are already included with up-close & personal journeys... You can add and upload your own stuff. Its quite useful also to preview the location for a next vacation.
Share and explore. It's free @ www.GlobeTrip.net
Here are a couple of fun travel polls with good linked video footage.
Fun to enjoy & share.
http://pollsb.com/polls/poll/13375
http://pollsb.com/polls/poll/13416
These are super easy to embed into almost any page for great content.
Have fun & safe travel.
JayGodse wrote...
You seem to have compared PostgreSQL with all the major databases except SQLite. Do you have any comparisons?
by lewisc
Lewis Cunningham is an Author, Blogger and Database Architect. He has worked in the Finance, Military, Airline Travel, Higher Education, Softwar...
(more)




















