Forum OpenACS Development: Drop file for the datamodel

Collapse
Posted by Jack Purswani on
Hi everyone I have a nagging problem which I just cant figure out. I have this one last problem with my drop file for the datamodel and I cannot for the life of me figure out what is wrong with the way I am porting it. The original oracle version of this problem is:

declare
  cursor v_attach_cursor
  is
  select item_id from cr_items
  where content_type = 'cr_wp_attachment';

begin

  for c in v_attach_cursor loop
    update acs_objects set context_id = null where context_id =
c.item_id;
    content_item.delete(c.item_id);
  end loop;

end;

and the way I have ported it is:
begin
  for item_id in select item_id from cr_items
        where content_type = ''cr_wp_attachment''
  loop
    update acs_objects set context_id = null where context_id
=c.item_id;
    PERFORM content_item__delete(c.item_id);
  end loop;
return 0;
end;
The error that I am getting is:
psql:wp-slim-drop1.sql:25: ERROR:  parser: parse error at or near
"select"
Would anyone know what is wrong with the way I am doing it and put me out of my misery! Thanks everyone Jack
Collapse
Posted by Gilbert Wong on
I belive you need to declare a record:
declare
    del_rec  record;
begin
  for del_rec in select item_id from cr_items
        where content_type = ''cr_wp_attachment''
  loop
    update acs_objects set context_id = null where context_id
=del_rec.item_id;
    PERFORM content_item__delete(del_rec.item_id);
  end loop;
return 0;
end;

Collapse
Posted by Gilbert Wong on
</pre>

<p>Oops, forgot to close the pre tag.

Collapse
Posted by Jack Purswani on
thanks
that fixed the problem!

jack