Farakh khan wrote:I want to insert values in the database that not exists by ignoring already existing values
[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Jeanne Boyarsky wrote:
Farakh khan wrote:I want to insert values in the database that not exists by ignoring already existing values
You can create a list of values that are not in the database and insert them at the end.
Or you can use the merge statement to do an insert if the value is not there. I don't think you can print out whether the value was found with this approach though.
Farakh khan wrote:
Jeanne Boyarsky wrote:
Farakh khan wrote:I want to insert values in the database that not exists by ignoring already existing values
You can create a list of values that are not in the database and insert them at the end.
Or you can use the merge statement to do an insert if the value is not there. I don't think you can print out whether the value was found with this approach though.
Thanks for your reply
The task is to show the end user values that already exists in the database that's why I am insisting for it.
Can we not control it programmatically instead of SQL?
[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Jeanne Boyarsky wrote:Since you have to show the user the values, you wouldn't use MERGE. Instead loop through your result (like you do now) and store the values that you need to insert in a list. Then run another query to insert those values.
Farakh khan wrote:
Jeanne Boyarsky wrote:Since you have to show the user the values, you wouldn't use MERGE. Instead loop through your result (like you do now) and store the values that you need to insert in a list. Then run another query to insert those values.
Thanks Sir for your reply
I am trying to do the same but where I am making mistake in my code. Can you please check my posted code?
Thanks & best regards
Farakh khan wrote:Thanks Sir for your reply
Farakh khan wrote:I am trying to do the same but where I am making mistake in my code. Can you please check my posted code?
[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2