Index: openacs-4/packages/evaluation/sql/postgresql/upgrade/upgrade-0.4d6-0.4d7.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/sql/postgresql/upgrade/upgrade-0.4d6-0.4d7.sql,v diff -u -r1.2 -r1.2.8.1 --- openacs-4/packages/evaluation/sql/postgresql/upgrade/upgrade-0.4d6-0.4d7.sql 8 Aug 2006 21:26:41 -0000 1.2 +++ openacs-4/packages/evaluation/sql/postgresql/upgrade/upgrade-0.4d6-0.4d7.sql 5 Sep 2014 16:40:03 -0000 1.2.8.1 @@ -1,8 +1,18 @@ -create function evaluation__clone (integer,integer) -returns integer as ' -declare - p_new_package_id alias for $1; --default null, - p_old_package_id alias for $2; --default null + + + +-- added +select define_function_args('evaluation__clone','new_package_id,old_package_id'); + +-- +-- procedure evaluation__clone/2 +-- +CREATE OR REPLACE FUNCTION evaluation__clone( + p_new_package_id integer, --default null, + p_old_package_id integer --default null + +) RETURNS integer AS $$ +DECLARE v_grade_id evaluation_grades.grade_id%TYPE; v_item_id acs_objects.object_id%TYPE; v_revision_id acs_objects.object_id%TYPE; @@ -12,7 +22,7 @@ one_grade record; entry record; -begin +BEGIN -- get all the grades belonging to the old package, -- and create new grades for the new package delete from evaluation_grades where grade_id in (select eg.grade_id from acs_objects o, evaluation_grades eg,cr_items ci,cr_revisions cr where o.object_id = ci.item_id and cr.revision_id=eg.grade_id and ci.item_id=cr.item_id and cr.revision_id=ci.live_revision and o.context_id = p_new_package_id); @@ -38,27 +48,27 @@ one_grade.description, one_grade.mime_type, null, - null, - ''text'', - ''content_item'', - ''evaluation_grades'' +y null, + 'text', + 'content_item', + 'evaluation_grades' ); - v_revision_id := nextval(''t_acs_object_id_seq''); + v_revision_id := nextval('t_acs_object_id_seq'); v_grade_id := evaluation__new_grade ( v_item_id, v_revision_id, one_grade.grade_name, one_grade.grade_plural_name, one_grade.weight, - ''evaluation_grades'', + 'evaluation_grades', one_grade.creation_date, one_grade.creation_user, one_grade.creation_ip, one_grade.title, one_grade.description, one_grade.publish_date, null, - ''text/plain'' + 'text/plain' ); for entry in select *, (ci.live_revision = cr.revision_id) as live_p from evaluation_tasks et,cr_revisions cr,cr_items ci, acs_objects o where grade_item_id = one_grade.grade_item_id and cr.revision_id=task_id and cr.item_id=ci.item_id and object_id=ci.item_id order by task_item_id @@ -80,13 +90,13 @@ null, null, entry.storage_type, --storage_type - ''content_item'', -- item_subtype - ''evaluation_tasks'' -- content_type + 'content_item', -- item_subtype + 'evaluation_tasks' -- content_type ); end if; - v_task_revision_id := nextval(''t_acs_object_id_seq''); + v_task_revision_id := nextval('t_acs_object_id_seq'); perform evaluation__new_task ( v_task_item_id, v_task_revision_id, entry.task_name, @@ -126,5 +136,7 @@ end loop; return 0; - end; -' language 'plpgsql'; \ No newline at end of file + END; + +$$ LANGUAGE plpgsql; +