To reproduce the issue, follow the steps below
Create the following tables
CREATE TABLE TABLE1
(
T1_ID NUMBER PRIMARY KEY
);
CREATE TABLE TABLE2
(
T2_ID NUMBER,
T2_REF NUMBER REFERENCES TABLE1 (T1_ID)
);
Go to Database | Import | Generate Table
Check "Enforce Referential Integrity". You can leave the default values for the other settings or change them.The result is the same.
Click + and add table1 and table2
Select # of records to create 10 for both tables (just so it is faster)
Click Run
you get the error
ORA-06550: line 2, column 18:
PLS-00302: component 'T2_REF' must be declared
ORA-06550: line 2, column 11:
PL/SQL: Item ignored
ORA-06550: line 10, column 14:
PL/SQL: ORA-00904: "T2_REF": invalid identifier
ORA-06550: line 7, column 5:
PL/SQL: SQL Statement ignored
ORA-06550: line 19, column 16:
PL/SQL: ORA-00904: "T2_REF": invalid identifier
ORA-06550: line 16, column 7:
PL/SQL: SQL Statement ignored
ORA-06550: line 41, column 7:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 41, column 7:
PL/SQL: ORA-00904: "V_T2REF": invalid identifier
ORA-06550: line 37, column 5:
PL/SQL: SQL Statement ignored
If you check the script to see the code generated by Toad, you will see the code below:
SELECT T2_REF
INTO v_T2REF
FROM (
SELECT T2_REF -----This is wrong
FROM HR.TABLE1 SAMPLE(1)
ORDER BY DBMS_RANDOM.VALUE
) WHERE rownum = 1;