Index: openacs-4/packages/news/sql/postgresql/news-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/news/sql/postgresql/news-create.sql,v
diff -u -r1.8 -r1.9
--- openacs-4/packages/news/sql/postgresql/news-create.sql	2 Apr 2002 06:08:54 -0000	1.8
+++ openacs-4/packages/news/sql/postgresql/news-create.sql	17 Jul 2002 20:21:20 -0000	1.9
@@ -649,6 +649,72 @@
 ' language 'plpgsql';
 
 
+
+-- Incomplete for want of blob_to_string() in postgres 16 july 2000
+
+create function news__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
+ one_news		record;	 
+begin
+        for one_news in select
+                            publish_date,
+                            cr.content as text,
+                            cr.nls_language,
+                            cr.title as title,
+                            cr.mime_type,
+                            cn.package_id,
+                            archive_date,
+                            approval_user,
+                            approval_date,
+                            approval_ip,
+                            ao.creation_date,
+                            ao.creation_ip,
+                            ao.creation_user
+                        from 
+                            cr_items ci, 
+                            cr_revisions cr,
+                            cr_news cn,
+                            acs_objects ao
+                        where
+                            (ci.item_id = cr.item_id
+                            and ci.live_revision = cr.revision_id 
+                            and cr.revision_id = cn.news_id 
+                            and cr.revision_id = ao.object_id)
+                        or (ci.live_revision is null 
+                            and ci.item_id = cr.item_id
+                            and cr.revision_id = content_item__get_latest_revision(ci.item_id)
+                            and cr.revision_id = cn.news_id
+                            and cr.revision_id = ao.object_id)
+
+        loop
+            perform news__new(
+                				one_news.publish_date,
+                				one_news.text,
+                				one_news.nls_language,
+                				one_news.title,
+                				one_news.mime_type,
+                				new_package_id,
+                				one_news.archive_date,
+                				one_news.approval_user,
+                				one_news.approval_date,
+                				one_news.approval_ip,
+                				one_news.creation_date,
+                				one_news.creation_ip,
+                				one_news.creation_user
+            );
+
+        end loop;
+ return 0;
+end;
+' language 'plpgsql';
+
+
+
+
+
 -- currently not used, because we want to audit revisions
 create function news__revision_delete (integer)
 returns integer as '
