• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Comparing parameters values with db values

 
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And what is the question?
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Respected Sir,

I want to insert values in the database that not exists by ignoring already existing values

javascript:emoticon('');
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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



 
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic