The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

185795 (4) [Avatar] Offline
#1
I hope the the authors still watch this forum...Im running into this issue.

When I run:

INSERT INTO ch07.bag_o_rasters(rast_name, rast)  
WITH a1 AS (SELECT ST_Buffer(ST_GeomFromText('LINESTRING(448252 5414206,448289 5414317,448293 5414330,448324 5414417,448351 5414495)', 32631),10) As geom)
SELECT 'disprop road', ST_AsRaster(geom,50,500) FROM a1
UNION ALL
SELECT 'proport fixed w road', 
    ST_AsRaster(geom,200,(
        (ST_YMax(geom) - ST_YMin(geom)) *  200 / 
        (ST_XMax(geom) - ST_XMin(geom)))::integer 
FROM a1;


I get:

ERROR:  syntax error at or near "FROM"
LINE 9: FROM a1;
        ^
********** Error **********

ERROR: syntax error at or near "FROM"
SQL state: 42601
Character: 432
regina.leo (265) [Avatar] Offline
#2
Sorry about that. Misplaced paretheses it seems. Try this:

WITH a1 AS (SELECT ST_Buffer(ST_GeomFromText('LINESTRING(448252 5414206,448289 5414317,448293 5414330,448324 5414417,448351 5414495)', 32631),10) 
    As geom)

	SELECT 'disprop road', ST_AsRaster(geom,50,500) FROM a1
	UNION ALL

	SELECT 'proport fixed w road',

	    ST_AsRaster( geom, 200, 

	        ( ST_YMax(geom) - ST_YMin(geom) ) *  200 /

	        ( ST_XMax(geom) - ST_XMin(geom)  )::integer)
	FROM a1;