Welcome to All About PostgreSQL
This lens aggregates postgresql news, information and blogs from around the web. Check back frequently for updates. If you don't see your favorite PostgreSQL blog linked, send me an email and I will add it.
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 fo 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
Alternate Source for PostgreSQL Books
A First Course in Database Systems
Price: $91.00
Written by well-known computer scientists, this accessible and succinct introduction to database systems focuses on database design and use. Provides... more »
Database Administration
Price: $49.99
A thorough reference on database administration outlines a variety of DBA roles and responsibilities and discusses such topics as data modeling and no... more »
Data Access Patterns
Price: $54.99
25 proven patterns for improving data access and application performance Efficient, high-quality data access code is crucial to the performance and... more »
SQL Demystified
Price: $19.95
There s no easier, faster, or more practical way to learn the really tough subjects SQL Demystified explains how to use SQL (Structured Query Langua... more »
Beginning Databases With Postgresql
Price: $44.99
A good beginner book. Plenty of beginners info and a decent reference once you get some experience.
Postgresql Essential Reference
Price: $39.99
Description not available. Copyright (C) Muze Inc. 2005. For personal use only. All rights reserved.
The Database Hacker's Handbook
Price: $50.00
Description not available. Copyright (C) Muze Inc. 2005. For personal use only. All rights reserved.
New Guestbook
Like this lens? Want to share your feedback, or just give a thumbs up? Be the first to submit a blurb!
























