| Author |
Comparing parameters values with db values
|
Farakh khan
Ranch Hand
Joined: Mar 22, 2008
Posts: 672
|
|
1) I am trying to compare the db value with user values with parameter received from user
2) if the value exists then ignore and insert the values that not exists in the db
Please check my code and help. Thanks in anticipation
===============
My code output:
===============
Already Exists: "1"
1" Not exists
1" Not exists
1" Not exists
3" Not exists
3" Not exists
Already Exists: "3"
3" Not exists
2" Not exists
Already Exists: "2"
2" Not exists
2" Not exists
|
 |
Edwin Dalorzo
Ranch Hand
Joined: Dec 31, 2004
Posts: 961
|
|
|
And what is the question?
|
 |
Farakh khan
Ranch Hand
Joined: Mar 22, 2008
Posts: 672
|
|
Respected Sir,
I want to insert values in the database that not exists by ignoring already existing values
javascript:emoticon(' ');
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26138
|
|
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.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Farakh khan
Ranch Hand
Joined: Mar 22, 2008
Posts: 672
|
|
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?
|
 |
Farakh khan
Ranch Hand
Joined: Mar 22, 2008
Posts: 672
|
|
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?
1) MERGE is not working in this case as it comparing existing two values of the database i.e. comparing two tables or two columns
2) I have to show the existing values in my program according to my task.
Please help me
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26138
|
|
|
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
Ranch Hand
Joined: Mar 22, 2008
Posts: 672
|
|
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
Ranch Hand
Joined: Mar 22, 2008
Posts: 672
|
|
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
|
 |
Somnath Mallick
Ranch Hand
Joined: Mar 04, 2009
Posts: 471
|
|
Could you post the full code?
I saw something like expertise.length in your code... but i did not see any expertise variable declared anywhere!
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26138
|
|
Farakh khan wrote:Thanks Sir for your reply
Just want to point out that I'm female.
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?
Your originally code needs a list to keep track of the values to insert. Then it would loop through that list and do the inserts. Why not try to add these two parts and posting the new code?
|
 |
 |
|
|
subject: Comparing parameters values with db values
|
|
|