How can I generate a specific number of random points in a polygon with PostGIS?
You should try the 'RandomPointsInPolygon(geom geometry, num_points integer)` function.
Add an additional geometry column, and update it using RandomPointsInPolygon. The first parameter is your existing geometry, and the second is your PNTSneeded column.
There are two question on SO related with RandomPointsInPolygon:
How to create random points in a polygon in PostGIS
Postgis random point inside a polygon
Start with a smaller sample, if possible, using a WHERE clause in the UPDATE statement.
The actual code would be:
-- copy and paste the RandomPointsInPolygon function
CREATE OR REPLACE FUNCTION RandomPointsInPolygon(geom geometry, num_points integer)
RETURNS SETOF geometry AS
$BODY$DECLARE
(...)
-- if you use EPSG:4326
SELECT AddGeometryColumn('polygons', 'points', 4326, 'MULTIPOINT', 2);
-- update your table polygons, using existing geom and PNTSneeded
UPDATE polygons
SET points = (SELECT ST_Union(manypoints)
FROM RandomPointsInPolygon("geom", "PNTSneeded") AS manypoints);