msgolez
asked on
Invalid datatype wehn doing alter tables in jdbc?
hello experts...
i have the following code:
statem.executeUpdate( "create table population(cid varchar2(5), pop number, pyear date)" );
System.out.println("Create d populations table...");
statem.executeUpdate( "create table encompassed(cid char(5), con varchar2(40), perc number)" );
System.out.println("Create d encompassed table...");
statem.executeUpdate( "create table ethngroups(cid char(5), grp varchar2(30), perc number)" );
System.out.println("Create d ethngroups table...");
statem.executeUpdate( "create table religions(cid char(5), rel varchar2(30), perc number)" );
System.out.println("Create d religions table...");
statem.executeUpdate( "create table languages(cid char(5), lan varchar2(30), perc number)" );
System.out.println("Create d languages table...");
statem.executeUpdate( "create table border(cid char(5), cou varchar2(40), len number, jus varchar2(40))" );
System.out.println("Create d border table...");
statem.executeUpdate( "create table locatedat(cid varchar2(50), type char(5))" );
System.out.println("Create d locatedat table...");
statem.executeUpdate( "create table provloc(cid char(50), pname varchar2(40))" );
System.out.println("Create d provloc table...");
statem.executeUpdate( "create table cityloc(cid char(50), pid varchar2(50), cname varchar2(40))" );
System.out.println("Create d cityloc table...");
//Apply integrity constraints
//INSERT MASSIVE AMOUNTS OF XML DATA HERE
System.out.println("Applyi ng integrity constraints...");
statem.executeUpdate( "alter table population add (constraint pop_fk" +
"foreign key (cid) references cities(id))");
System.out.println("Altere d population table...");
statem.executeUpdate( "alter table encompassed add (constraint enc_fk" +
"foreign key (cid) references countries(ccode))");
System.out.println("Altere d encompassed table...");
statem.executeUpdate( "alter table ethngroups add (constraint ethn_fk" +
"foreign key (cid) references countries(ccode))");
System.out.println("Altere d ethngroups table...");
statem.executeUpdate( "alter table religions add (constraint rel_fk" +
"foreign key (cid) references countries(ccode))");
System.out.println("Altere d religions table...");
statem.executeUpdate( "alter table languages add (constraint lan_fk" +
"foreign key (cid) references countries(ccode))");
System.out.println("Altere d languages table...");
statem.executeUpdate( "alter table border add (constraint bor_fk" +
"foreign key (cid) references countries(ccode))" );
System.out.println("Altere d border table...");
statem.executeUpdate( "alter table locatedat add (constraint locat_fk" +
"foreign key (cid) references cities(id))" );
System.out.println("Altere d locatedat table...");
statem.executeUpdate( "alter table provloc add (constraint provloc_fk" +
"foreign key (cid) references countries(ccode))");
System.out.println("Altere d provloc table...");
statem.executeUpdate( "alter table cityloc add (constraint cityloc_fk1" +
"foreign key (cid) references countries(ccode)," +
"constraint cityloc_fk2 foreign key (pid)" +
"references provinces(id))");
System.out.println("Altere d cityloc table...");
well i get to create the tables but it wont let me alter it. i get an invalid datatype from oracle.
help please :(
i have the following code:
statem.executeUpdate( "create table population(cid varchar2(5), pop number, pyear date)" );
System.out.println("Create
statem.executeUpdate( "create table encompassed(cid char(5), con varchar2(40), perc number)" );
System.out.println("Create
statem.executeUpdate( "create table ethngroups(cid char(5), grp varchar2(30), perc number)" );
System.out.println("Create
statem.executeUpdate( "create table religions(cid char(5), rel varchar2(30), perc number)" );
System.out.println("Create
statem.executeUpdate( "create table languages(cid char(5), lan varchar2(30), perc number)" );
System.out.println("Create
statem.executeUpdate( "create table border(cid char(5), cou varchar2(40), len number, jus varchar2(40))" );
System.out.println("Create
statem.executeUpdate( "create table locatedat(cid varchar2(50), type char(5))" );
System.out.println("Create
statem.executeUpdate( "create table provloc(cid char(50), pname varchar2(40))" );
System.out.println("Create
statem.executeUpdate( "create table cityloc(cid char(50), pid varchar2(50), cname varchar2(40))" );
System.out.println("Create
//Apply integrity constraints
//INSERT MASSIVE AMOUNTS OF XML DATA HERE
System.out.println("Applyi
statem.executeUpdate( "alter table population add (constraint pop_fk" +
"foreign key (cid) references cities(id))");
System.out.println("Altere
statem.executeUpdate( "alter table encompassed add (constraint enc_fk" +
"foreign key (cid) references countries(ccode))");
System.out.println("Altere
statem.executeUpdate( "alter table ethngroups add (constraint ethn_fk" +
"foreign key (cid) references countries(ccode))");
System.out.println("Altere
statem.executeUpdate( "alter table religions add (constraint rel_fk" +
"foreign key (cid) references countries(ccode))");
System.out.println("Altere
statem.executeUpdate( "alter table languages add (constraint lan_fk" +
"foreign key (cid) references countries(ccode))");
System.out.println("Altere
statem.executeUpdate( "alter table border add (constraint bor_fk" +
"foreign key (cid) references countries(ccode))" );
System.out.println("Altere
statem.executeUpdate( "alter table locatedat add (constraint locat_fk" +
"foreign key (cid) references cities(id))" );
System.out.println("Altere
statem.executeUpdate( "alter table provloc add (constraint provloc_fk" +
"foreign key (cid) references countries(ccode))");
System.out.println("Altere
statem.executeUpdate( "alter table cityloc add (constraint cityloc_fk1" +
"foreign key (cid) references countries(ccode)," +
"constraint cityloc_fk2 foreign key (pid)" +
"references provinces(id))");
System.out.println("Altere
well i get to create the tables but it wont let me alter it. i get an invalid datatype from oracle.
help please :(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try running it as a batch using statement.executeBatch ()
ASKER
thank you for the reply guys, ill try a couple of things tonite and let you guys how it went.
ASKER
should be
statem.executeUpdate( "alter table languages add constraint lan_fk " +
"foreign key (cid) references countries(ccode)");
actually, it was the space between the foreign key keyword and (cid) that was messing it up. thanks!
statem.executeUpdate( "alter table languages add constraint lan_fk " +
"foreign key (cid) references countries(ccode)");
actually, it was the space between the foreign key keyword and (cid) that was messing it up. thanks!
:-)
>>actually, it was the space between the foreign key keyword and (cid) that was messing it up.
No, it would have been the *lack* of space before 'foreign key' that was messing it up
>>
statem.executeUpdate( "alter table encompassed add (constraint enc_fk" +
"foreign key
>>
No, it would have been the *lack* of space before 'foreign key' that was messing it up
>>
statem.executeUpdate( "alter table encompassed add (constraint enc_fk" +
"foreign key
>>
ASKER
im sorry but you kinda threw me off...
statem.executeUpdate( "alter table languages add constraint lan_fk " +
"foreign key (cid) references countries(ccode)");
isnt there a space after 'lan_fk'? so when the string is built it should be ok right?
statem.executeUpdate( "alter table languages add constraint lan_fk " +
"foreign key (cid) references countries(ccode)");
isnt there a space after 'lan_fk'? so when the string is built it should be ok right?
>>isnt there a space after 'lan_fk'? so when the string is built it should be ok right?
There wasn't in your original, no
There wasn't in your original, no
ASKER
huh.. didnt even notice that :D
thanks again!
thanks again!
ASKER