[postgis-users] execute 'alter table' won't work

Peter Bange bange at argoss.nl
Wed Apr 18 04:35:20 PDT 2007


Anybody an idea why this won't work, I am checking if a table has all  
the columns I need:

	for rec in select shortname from atb_pollutants loop
	--	loop over pollutants
		BEGIN
			strSQL = 'alter table atb_compositions add column ' ||  
rec.shortname || ' real';
			execute strSQL;
			raise notice '... added';
		EXCEPTION
			when duplicate_column then
			--	take next
				raise notice '... already existing';
		END;
	end loop;

I get the notice ' ... added'  for all non-existing columns in the  
table (so I assume no error has occured) but when I look in the table  
not a single field is added. And indeed, when I run the same code  
again I get exactly the same ' ...added' messages. (The notice  
'...already existing works fine for all the columns already in the  
table.)


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20070418/0dab59e5/attachment.html>


More information about the postgis-users mailing list