• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Bear Bibeault
  • Liutauras Vilda
  • Devaka Cooray
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Insert in JSp

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
i am trying to insert just one field into a table which contains many fields. When i am executing this i am getting an error that the "destinational fields are not the same as the query results"
If anyone can tell me how i can insert just one field in a table of many fields.
Thank you and regards
vikram
 
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
generally you can't just insert a single column into a table (unless the row only has one column), you have insert an entire row.
You might have to populate the other columns with dummy data (depending on their data type).
Updates can be done on single columns though.
James.
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
INSERT INTO table (field)
   SELECT field
   FROM othertable
   WHERE ...
This will only work if the other fields in the table are either NULL fields or have default values. In particular, the primary key field(s) (if any) need to be populated in some way unless they are autogenerated (SQL Server identity field, Oracle sequence in a trigger, PostgreSQL serial...)
- Peter
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually in this case number of records u r going to insert doesn't match with no.of columns.. To avoid this u need to specify the column names where u want to insert values.. like:
INSERT INTO TABLE(FIELDS) VALUES("..)
Hope this will solve ur prob..
Thanks
Pranit..

Originally posted by vikram nalagampalli:
"destinational fields are not the same as the query results"


 
vikram nalagampalli
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks one and all for your replies.
 
He puts the "turd" in "saturday". Speaking of which, have you smelled this tiny ad?
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!