As part of my k-medoid algorithm, I have declared a record variable called o_random in my function, which I use to store a random row retrieved from a table of crimes as in this query:
EXECUTE 'SELECT * FROM algorithms.kmedoid_crimes_' ||k||' WHERE
cluster_id='||k_count||' OFFSET floor(random()*'||row_count||') LIMIT 1'
INTO o_random;
However, the below query is giving me an error saying "could not identify column "latitude" in record data type". The crimes table I am getting the row from definitely has a field called latitude.. so I'm thinking I'm trying to get the data from the record variable wrongly?
EXECUTE 'UPDATE algorithms.km_cluster_centres_' ||k||'
SET latitude = $1.latitude, longitude = $1.longitude, geom =
ST_Transform(ST_SetSRID(ST_MakePoint($1.longitude, $1.latitude), 4326),3435)
WHERE id=' ||k_count
USING o_random;
Found some solutions on stack but none of them seem to work.. help would be appreciated.