LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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
 
Search this Thread
Old 07-06-2011, 11:02 AM   #1
mpapet
Member
 
Registered: Nov 2003
Location: Los Angeles
Distribution: debian
Posts: 453

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 11: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


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


All times are GMT -5. The time now is 03:36 PM.

Main Menu
Advertisement
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