Reputation: 1
I have an error in syntax @ in my code in postgreSQL database, but I don't know what could be wrong. Did I implemented the SQL loop code in rigth way? My SQL code:
DECLARE @Counter INT
SET @Counter=1
WHILE ( @Counter <= 1000)
BEGIN
INSERT INTO punkty (geog) SELECT ST_GeometryN(st_asText(ST_GeneratePoints(geom,1000)), @Counter) FROM panstwo
SET @Counter = @Counter + 1
END
Upvotes: 0
Views: 43
Reputation: 175556
First your code looks like T-SQL(Microsoft and Sybase dialect) and it won't work on PostgreSQL by design
Second loop is not required:
INSERT INTO punkty (geog)
SELECT ST_GeometryN(st_asText(ST_GeneratePoints(geom,1000)), s.Counter)
FROM panstwo
CROSS JOIN generate_series(1,1000) s(counter);
Upvotes: 2