posted 4 years ago
I don't use MySQL so the syntax for this kind of merge is unfamiliar, but what does the "VALUE(?)" do? Maybe try just using the place-holder "?" instead. Also, CORPUSID is your primary key, so you will only get to the "ON DUPLICATE" code if the Corpus ID value already exists. So why do you need to update it? you should not update primary keys anyway - one of the characteristics of a primary key is that it should not change.
No more Blub for me, thank you, Vicar.
sahar eb
Ranch Hand
Posts: 38
posted 4 years ago
Dear Chris,
I have used only ? instead of vale(?), no result, same error. yes, but this utility is actually a Backyp process and this snippet is for to restore section, ex.: in case that a row with a particular primary key has had some unwanted changed, or wrong ones, or have been deleted by mistake, we want to update If it exists. it will be updated to the last version of the backup or will be inserted.
Thanks!
I have used only ? instead of vale(?), no result, same error. yes, but this utility is actually a Backyp process and this snippet is for to restore section, ex.: in case that a row with a particular primary key has had some unwanted changed, or wrong ones, or have been deleted by mistake, we want to update If it exists. it will be updated to the last version of the backup or will be inserted.
Thanks!
posted 4 years ago
I use MySQL but I haven't ever used the INSERT... ON DUPLICATE KEY UPDATE... feature. So I googled it: http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html and I think you ought to look more carefully at what's supposed to be in the UPDATE clause. The examples in that manual page are kind of lame but I'm pretty sure you aren't using it right. Don't you have to specify the values for the fields you want to update in that clause?
sahar eb
Ranch Hand
Posts: 38
posted 4 years ago
Thank you, yes, now I am using oracle sql developer comand window to test this:
throws me this error:
here is crete table:
I spent almost 3 days, no progress, please if any idea.. how can I solve this ?
Thank you sooo much!
throws me this error:
here is crete table:
I spent almost 3 days, no progress, please if any idea.. how can I solve this ?
Thank you sooo much!
posted 4 years ago
The problem is that the DUAL table doesn't have column CORPUSDOMAIN (nor any other column you're selecting from it).
Instead ofuse(and similarly for all other columns you have in your select query). This is the way to obtain one row containing columns with given values in Oracle.
In your Java application, you should use parameters instead of hard-coded values, of course.
Instead ofuse(and similarly for all other columns you have in your select query). This is the way to obtain one row containing columns with given values in Oracle.
In your Java application, you should use parameters instead of hard-coded values, of course.
sahar eb
Ranch Hand
Posts: 38
posted 4 years ago
thanks, now I have this that works fine in oracle command window:
but when I put in java class , it works for insert but it does not work in case it is an update, it just freezes, until I delete the row from DB then it inserts it. So no update!!!
here is the java code:
do you know what I am doing wrong here?
Thank you so much!!!
but when I put in java class , it works for insert but it does not work in case it is an update, it just freezes, until I delete the row from DB then it inserts it. So no update!!!
here is the java code:
do you know what I am doing wrong here?
Thank you so much!!!
