<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">If you're sure you're in a database
based on the PostGIS template, I'd try putting the schema name in
front of the function name, i.e. "public.ST_Within(...", see if
that's the issue.<br>
<br>
-Greg Kramida<br>
<br>
On 7/30/2012 2:32 PM, Eric Aspengren wrote:<br>
</div>
<blockquote
cite="mid:CAFLHT5Fc4HfG=FyAZgCnxruMDB=3BnVLUg8gKT-bdX4x1TGgGw@mail.gmail.com"
type="cite">
<div>So, I've got this PL/PGSQL script that doesn't want to work.
I've got the TIGER geocoder up and running and I can get
whatever I want from that. However, when I try and combine
ST_Within with the output from GEOCODE I get an error. I assume
there's a simple syntax error here, but I can't figure it out.
I've been able to get this to work when just cutting and pasting
the actual geometry data into where "geocoded" is below, but
replacing it with the variable name gives me an error (sldu is a
table with Senate districts and sldust is the district number
column):</div>
<div><br>
</div>
<div>
<div>CREATE OR REPLACE FUNCTION get_district(address text)</div>
<div> RETURNS text AS</div>
<div>$$</div>
<div>DECLARE</div>
<div> district RECORD;</div>
<div> geocoded RECORD;</div>
<div>BEGIN</div>
<div> SELECT geomout into geocoded from geocode(address) as
g;</div>
<div> SELECT sldust from sldu into district where
ST_Within(geocoded, the_geom);</div>
<div> return district;</div>
<div>END;</div>
<div>$$</div>
<div>
LANGUAGE 'plpgsql' IMMUTABLE;</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div>geocoder=# select get_district('1700 C St Lincoln, NE');</div>
<div><br>
</div>
<div><br>
</div>
<div>ERROR: function st_within(record, geometry) does not exist</div>
<div>LINE 1: SELECT sldust from sldu where ST_Within( $1 ,
the_geom)</div>
<div> ^</div>
<div>HINT: No function matches the given name and argument types.
You might need to add explicit type casts.</div>
<div>QUERY: SELECT sldust from sldu where ST_Within( $1 ,
the_geom)</div>
<div>CONTEXT: PL/pgSQL function "get_district" line 6 at SQL
statement</div>
<div><br>
</div>
-- <br>
Eric Aspengren<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
postgis-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a>
<a class="moz-txt-link-freetext" href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</a>
</pre>
</blockquote>
<br>
</body>
</html>