Skip to content

Commit

Permalink
Fixes for Oracle
Browse files Browse the repository at this point in the history
  • Loading branch information
m5n committed Apr 7, 2016
1 parent ab20ba1 commit 91cfad9
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 20 deletions.
14 changes: 4 additions & 10 deletions canadian_nf/MODIFICATIONS
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,7 @@ NUTRIENT AMOUNT:
NUTRIENT NAME:
- Allow Tagname to be null as not all records specify a value

TODO: review the rest:

FOOD_NM:
- (MySQL) Change FD_SRC_ID size from 11 to 2 to prevent an error with MySQL which requires the size of foreign keyed column to be the same as the referenced column:
120918 23:08:28 Error in foreign key constraint of table canadian_nf/#sql-5f1_5f:
foreign key (FD_SRC_ID) references FOOD_SRC(FD_SRC_ID):
Cannot find an index in the referenced table where the
referenced columns appear as the first columns, or column types
in the table and the referenced table do not match for constraint.

NUTRIENT_SOURCE:
- One record has a missing value for NutrientSourceDescriptionF:
108,18,Imputed data that USDA has deleted,
It was corrected by manually filling in that value in the NUTRIENT_SOURCE.csv.trimmed file (rather than allowing NutrientSourceDescriptionF to be null).
2 changes: 1 addition & 1 deletion canadian_nf/dist/canadian_nf_oracle.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ BEGIN EXECUTE IMMEDIATE 'CREATE USER food IDENTIFIED BY food'; EXCEPTION WHEN OT
/

-- Needed since Oracle 12c.
ALTER USER food QUOTA 100M ON USERS;
ALTER USER food QUOTA UNLIMITED ON USERS;

-- Needed since Oracle 12c.
ALTER SESSION SET "_ORACLE_SCRIPT"=FALSE;
Expand Down
2 changes: 1 addition & 1 deletion src/Oracle.pm
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ sub sql_recreate_database_and_user_to_access_it {

# Needed since Oracle 12c.
$result .= "\n" . sql_comment('Needed since Oracle 12c.') . "\n";
$result .= "ALTER USER food QUOTA 100M ON USERS;\n";
$result .= "ALTER USER food QUOTA UNLIMITED ON USERS;\n";

# Needed since Oracle 12c.
$result .= "\n" . sql_comment('Needed since Oracle 12c.') . "\n";
Expand Down
10 changes: 10 additions & 0 deletions usda_nndsr/MODIFICATIONS
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,13 @@ NUT_DATA table

NUTR_DEF table
- NUTR_DEF.txt contains non-ASCII characters (the mcg symbol). This is not corrected, so the actual value in the DB may not be the right character.

WEIGHT table:
- Change the size of Amount from 5.3 to 6.3 to accommodate these records (remember, n.m means n digits total with m decimal places):
~14260~^1^240^~ml~^240^1^
~14276~^2^200^~ml~^200^1^

- Change the size of Num_Data_Pts from 3 to 4 to accommodate these records:
~07254~^2^1^~slice 12 oz pkg~^16^1329^
~07973~^1^1^~slice~^8.1^1587^
~07973~^2^1^~raw pr g~^15^1627^
4 changes: 2 additions & 2 deletions usda_nndsr/dist/usda_nndsr_mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ create table NUT_DATA (
create table WEIGHT (
NDB_No varchar(5) not null, -- 5-digit Nutrient Databank number that uniquely identifies a food item. If this field is defined as numeric, the leading zero will be lost.
Seq varchar(2) not null, -- Sequence number.
Amount dec(5, 3) unsigned not null, -- Unit modifier (for example, 1 in "1 cup").
Amount dec(6, 3) unsigned not null, -- Unit modifier (for example, 1 in "1 cup").
Msre_Desc varchar(84) not null, -- Description (for example, cup, diced, and 1-inch pieces).
Gm_Wgt dec(7, 1) unsigned not null, -- Gram weight.
Num_Data_Pts smallint(3) unsigned, -- Number of data points.
Num_Data_Pts smallint(4) unsigned, -- Number of data points.
Std_Dev dec(7, 3) unsigned -- Standard deviation.
);

Expand Down
6 changes: 3 additions & 3 deletions usda_nndsr/dist/usda_nndsr_oracle.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ BEGIN EXECUTE IMMEDIATE 'CREATE USER food IDENTIFIED BY food'; EXCEPTION WHEN OT
/

-- Needed since Oracle 12c.
ALTER USER food QUOTA 100M ON USERS;
ALTER USER food QUOTA UNLIMITED ON USERS;

-- Needed since Oracle 12c.
ALTER SESSION SET "_ORACLE_SCRIPT"=FALSE;
Expand Down Expand Up @@ -71,10 +71,10 @@ BEGIN EXECUTE IMMEDIATE 'DROP TABLE WEIGHT CASCADE CONSTRAINTS'; EXCEPTION WHEN
CREATE TABLE WEIGHT (
NDB_No VARCHAR2(5) NOT NULL, -- 5-digit Nutrient Databank number that uniquely identifies a food item. If this field is defined as numeric, the leading zero will be lost.
Seq VARCHAR2(2) NOT NULL, -- Sequence number.
Amount NUMBER(5, 3) NOT NULL, -- Unit modifier (for example, 1 in "1 cup").
Amount NUMBER(6, 3) NOT NULL, -- Unit modifier (for example, 1 in "1 cup").
Msre_Desc VARCHAR2(84) NOT NULL, -- Description (for example, cup, diced, and 1-inch pieces).
Gm_Wgt NUMBER(7, 1) NOT NULL, -- Gram weight.
Num_Data_Pts NUMBER(3), -- Number of data points.
Num_Data_Pts NUMBER(4), -- Number of data points.
Std_Dev NUMBER(7, 3) -- Standard deviation.
);

Expand Down
4 changes: 2 additions & 2 deletions usda_nndsr/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@
{
"name": "Amount",
"type": "Numeric",
"size": 5.3,
"size": 6.3,
"allows_null": false,
"description": "Unit modifier (for example, 1 in \"1 cup\")."
},
Expand All @@ -304,7 +304,7 @@
{
"name": "Num_Data_Pts",
"type": "Numeric",
"size": 3,
"size": 4,
"allows_null": true,
"description": "Number of data points."
},
Expand Down
2 changes: 1 addition & 1 deletion usda_nndsr_abbr/dist/usda_nndsr_abbr_oracle.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ BEGIN EXECUTE IMMEDIATE 'CREATE USER food IDENTIFIED BY food'; EXCEPTION WHEN OT
/

-- Needed since Oracle 12c.
ALTER USER food QUOTA 100M ON USERS;
ALTER USER food QUOTA UNLIMITED ON USERS;

-- Needed since Oracle 12c.
ALTER SESSION SET "_ORACLE_SCRIPT"=FALSE;
Expand Down

0 comments on commit 91cfad9

Please sign in to comment.