• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data Conversion Process

 
prathimaprasun rao
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

I have a table "Student". This table has three fields- SNo, SName and SClass.

While creating this table, these three fields are set to have primary keys.

Now I want to split the field SName into SFirstName and SLastName.So I add two new fields - SFirstName and SLastName to the "Student" table.When I try to insert new values into the Student table, it displays the error message "Null value cannot be inserted into the SName" and fails to create a new record after adding two new fields.

I am assuming that SName has the primary key, so it does not allow to create a new record as this field cannot be null. Could anyone tell me how I can drop the primary key constraint on this SName field so that I can create a new record by inserting new values in all the fields - SNo,SFirstName,SLastName and SClass except the SName field without displaying the error message: "Null value cannot be inserted into the SName".

SName and Sclass are just an example fields.

I also need some advice for the data conversion process:

I thought of writing the update statement as follows:

update Student set SFirstName = 'A',SLastName='B' and SClass=1 where SName='AB' and SClass=1;

Could anyone tell me whether this is the correct procedure to do the data conversion.

If the SName has 17 values and Sclass has 2 values then do we need to write 17*2 =34 update statements for the data conversion process.

-Prathima
[ October 02, 2007: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65340
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use real words when posting to the forums. I have no idea what "regd" means and it has been removed from your post title.

Please read this for more information.

thanks,
bear
JavaRanch sheriff
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65340
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And as this doesn't seem to have much to do with JSP, it's been moved to a more appropriate forum.
 
sun chengqiang
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please input sentensece:
update Student set SFirstName = 'A',SLastName='B',SClass=1 where SName='AB' and SClass=1;
I think this will help you.
 
Paul Campbell
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ALTER TABLE student DROP CONSTRAINT sname_PK; -- or whatever the pk constraint --is named
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic