issues with sql query

Hi there,

I have some trouble figuring out this error message on my client (browser) console:

{
  "code": "42703",
  "details": null,
  "hint": "There is a column named \"post_id\" in table \"content\", but it cannot be referenced from this part of the query.",
  "message": "column \"post_id\" does not exist"
}


This occurs after calling this function using RPC:

CREATE OR REPLACE FUNCTION public.create_content_parts(parts json[])
RETURNS void AS $$
  DECLARE
    array_len int;
  BEGIN
    array_len := array_length(parts, 1);
    FOR i IN 1..array_len
    LOOP
      insert into content(post_id, body, type, index)
      values (parts[i]->post_id, parts[i]->body, parts[i]->type, parts[i]->index);
    END LOOP;
  END
$$ LANGUAGE plpgsql SECURITY DEFINER;


The table has a post_id (int8) column setup, all other columns exist as well. Any ideas what maybe wrong here?

Thanks in advance.
Was this page helpful?