LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
LinkBack Search this Thread
Old 07-06-2011, 10:02 AM   #1
mpapet
Member
 
Registered: Nov 2003
Location: Los Angeles
Distribution: debian
Posts: 452

Rep: Reputation: 46
Postgresql Newbie needs help with function


I've been using scripts to perform data manipulation for a while now and I'd like to take a stab at writing functions.

I've got a table with addresses and I'd like to loop through the table and do some calculating on the fields.

##############
CREATE OR REPLACE FUNCTION dev.mygeocode_function()
RETURNS SETOF text AS
$BODY$
DECLARE
r tiger._stores_grocery%rowtype; --r becomes a quoted string?
franistan varchar;
BEGIN
for r in select '' || address || ' ' || city || ', ' || state || ' ' || zip || '' as the_address from tiger._stores_grocery limit 10 LOOP
SELECT g.rating FROM tiger.geocode(r) As g into franistan;
return next franistan;
END LOOP;
END;
$BODY$
LANGUAGE plpgsql VOLATILE;
############

doing select * from dev.mygeocode_function() returns an error. r is populated with the string _stores_grocery, not the 'the_address' field.

What am I doing wrong?

Last edited by mpapet; 07-06-2011 at 10:05 AM.
 
  


Reply

Tags
postgres, postgresql


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie question about PostgreSQL, Schemas & Tables! justemail Linux - Newbie 3 05-27-2009 09:25 AM
PostgreSQL-8.1, Kubuntu 6.06 alternate... HELP NEEDED FOR LINUX NEWBIE HelpSosHelp Linux - Newbie 4 05-20-2008 04:12 AM
no mouse function? (still quite newbie) divingduck Linux - Distributions 8 04-25-2004 03:14 PM
postgresql -odbc & postgresql-jdbc installation kjsubbu Linux - Software 0 06-19-2003 02:50 AM


All times are GMT -5. The time now is 07:58 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration