Index: openacs-4/packages/ref-itu/sql/oracle/ref-itu-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ref-itu/sql/oracle/ref-itu-create.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ref-itu/sql/oracle/ref-itu-create.sql 26 Feb 2003 18:05:25 -0000 1.1 @@ -0,0 +1,56 @@ +-- packages/ref-itu/sql/postgresql/ref-itu-create.sql +-- +-- @author jon@jongriffin.com.com +-- @creation-date 2003-02-25 +-- @cvs-id $Id: ref-itu-create.sql,v 1.1 2003/02/26 18:05:25 jong Exp $ + +create table itu_notes ( + note_id char(3) + constraint itu_notes_id_pk + primary key, + note text + constraint itu_notes_note_nn + not null + constraint itu_notes_note_uq + unique +); + +create table itu_codes ( + itu_code char(6) + constraint itu_code_nn + not null, + country varchar(100) + constraint itu_country_nn + not null, + note_id char(3) + constraint itu_codes_note_fk + references itu_notes (note_id), + constraint itu_code_pk + primary key (itu_code,country) +); + + +comment on table itu is ' + This is the ITU country dialing code list. +'; + +-- add this table into the reference repository + +declare + v_id integer; +begin + v_id := acs_reference.new ( + table_name => 'itu_codes', + last_update => to_date('2002-05-01','YYYY-MM-DD'), + source => 'ITU', + source_url => 'http://www.itu.int/', + effective_date => '2002-05-01' + ); +commit; +end; +/ +-- This is the translated mapping of country names +-- Need to see if ITU used the same country names as ISO and if so, we can use those for +-- translated names, but they have some non-country names + +@ '../common/ref-itu-data.sql' Index: openacs-4/packages/ref-itu/sql/oracle/ref-itu-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ref-itu/sql/oracle/ref-itu-drop.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ref-itu/sql/oracle/ref-itu-drop.sql 26 Feb 2003 18:05:25 -0000 1.1 @@ -0,0 +1,36 @@ +-- Drop the ACS Reference ITU data +-- +-- @author jon@jongriffin.com +-- @cvs-id $Id: ref-itu-drop.sql,v 1.1 2003/02/26 18:05:25 jong Exp $ + +set serveroutput on +-- drop all associated tables and packages +-- I am not sure this is a good idea since we have no way to register +-- if any other packages are using this data. + +-- This will probably fail if their is a child table using this. +-- I can probably make this cleaner also, but ... no time today + +declare + cursor refsrc_cur is + select table_name, + package_name, + repository_id + from acs_reference_repositories + where upper(table_name) like 'ITU_CODE%' + order by repository_id desc; +begin + for rec in refsrc_cur loop + dbms_output.put_line('Dropping ' || rec.table_name); + execute immediate 'drop table ' || rec.table_name; + if rec.package_name is not null then + execute immediate 'drop package ' || rec.package_name; + end if; + acs_reference.delete(rec.repository_id); + end loop; +end; +/ +show errors + +-- drop the notes +drop table itu_notes; Index: openacs-4/packages/ref-itu/sql/postgresql/ref-itu-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ref-itu/sql/postgresql/ref-itu-create.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ref-itu/sql/postgresql/ref-itu-create.sql 26 Feb 2003 18:08:53 -0000 1.1 @@ -0,0 +1,52 @@ +-- packages/ref-itu/sql/postgresql/ref-itu-create.sql +-- +-- @author jon@jongriffin.com.com +-- @creation-date 2003-02-25 +-- @cvs-id $Id: ref-itu-create.sql,v 1.1 2003/02/26 18:08:53 jong Exp $ + +create table itu_notes ( + note_id char(3) + constraint itu_notes_id_pk + primary key, + note text + constraint itu_notes_note_nn + not null + constraint itu_notes_note_uq + unique +); + +create table itu_codes ( + itu_code char(6) + constraint itu_code_nn + not null, + country varchar(100) + constraint itu_country_nn + not null, + note_id char(3) + constraint itu_codes_note_fk + references itu_notes (note_id), + constraint itu_code_pk + primary key (itu_code,country) +); + +comment on table itu_codes is ' + This is the ITU country dialing code list. +'; + +-- add this table into the reference repository + +select acs_reference__new ( + 'itu_codes', -- table_name + '2002-05-01', + 'ITU', -- source + 'http://www.itu.int/', -- source_url + to_date('2002-05-01','YYYY-MM-DD') -- effective_date + ); + +-- This is the translated mapping of country names +-- Need to see if ITU used the same country names as ISO and if so, we can use those for +-- translated names, but they have some non-country names + +begin; +\i ../common/ref-itu-data.sql +end; Index: openacs-4/packages/ref-itu/sql/postgresql/ref-itu-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ref-itu/sql/postgresql/ref-itu-drop.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ref-itu/sql/postgresql/ref-itu-drop.sql 26 Feb 2003 18:08:53 -0000 1.1 @@ -0,0 +1,28 @@ +-- Drop the ACS Reference ITU data +-- +-- @author jon@jongriffin.com +-- @cvs-id $Id: ref-itu-drop.sql,v 1.1 2003/02/26 18:08:53 jong Exp $ + +-- drop all associated tables and packages +-- I am not sure this is a good idea since we have no way to register +-- if any other packages are using this data. + +-- This will probably fail if their is a child table using this. +-- I can probably make this cleaner also, but ... no time today + +create function inline_0() returns integer as ' +declare + rec acs_reference_repositories%ROWTYPE; +begin + for rec in select * from acs_reference_repositories where upper(table_name) like ''ITU_CODE%'' loop + execute ''drop table '' || rec.table_name; + perform acs_reference__delete(rec.repository_id); + end loop; + return 0; +end;' language 'plpgsql'; + +select inline_0(); +drop function inline_0(); + +-- drop the notes +drop table itu_notes;