1. Christian Breu
  2. as Valentina DB Server
  3. 水, 3月 27 2019, 11:08 PM
  4.  メールで購読
[How] is it possible to just update existing records while using vCursor.importText()?
コメント
There are no comments made yet.
Christian Breu 承諾済みの回答
Is it possible or not?
コメント
There are no comments made yet.
Sergey Pashkov 承諾済みの回答
Hello Christian,

For example, if the imported text contains the RecID or primary key column, right?
コメント
There are no comments made yet.
Christian Breu 承諾済みの回答
Hi Sergey

Actually not really but they are products and have a barcode-number.
Is it possible directly while importing from text?
コメント
There are no comments made yet.
Sergey Pashkov 承諾済みの回答
Hi Christian,

No, it is impossible to do directly.

One of the possible ways:
1. Create intermediate (temporary or even RAM) table
2. Import records to this table
3. Use MERGE command to update existing and insert new records in the target table
参照
  1. http://valentina-db.com/docs/dokuwiki/v9/doku.php?id=valentina:vcomponents:vsql:reference:merge
コメント
There are no comments made yet.
Christian Breu 承諾済みの回答
Hi Sergey

Thank you for the clear answer.
I will take a look at that.


Best regards.

Chris.
コメント
There are no comments made yet.
Christian Breu 承諾済みの回答
Hello Sergey

Have to reactivate this thread...
Trying to use Merge but it does not work as I am expecting. :(

The sample from Wiki does not work – using dot-notation for fields is throwing errors!?
Found a sample from Ruslan that works but it is too simple.


this works without throwing an error:

MERGE main as mtarget
USING imp as isource ON (isource.artikelnummer = mtarget.artikelnummer)
WHEN MATCHED THEN
UPDATE SET name = isource.name


this is throwing an error:

MERGE main as mtarget
USING imp as isource ON (isource.artikelnummer = mtarget.artikelnummer AND isource.barcode = mtarget.barcode)
WHEN MATCHED THEN
UPDATE SET name = isource.name


this works without throwing an error:

MERGE main as mtarget
USING imp as isource ON (isource.artikelnummer = mtarget.artikelnummer AND isource.barcode <> mtarget.barcode)
WHEN MATCHED THEN
UPDATE SET name = isource.name



**********************************************************

I want to do anything like this:

MERGE main as mtarget
USING imp as isource ON (isource.artikelnummer = mtarget.artikelnummer AND isource.barcode = mtarget.barcode)
WHEN NOT MATCHED BY TARGET THEN
INSERT(artikelnummer, barcode, name) VALUES(isource.artikelnummer, isource.barcode, isource.name)
WHEN MATCHED THEN
UPDATE SET mtarget.name = isource.name


and a second one to delete:

MERGE main as mtarget
USING imp as isource
ON (isource.artikelnummer = mtarget.artikelnummer and isource.barcode = mtarget.barcode AND remove = 1)
WHEN MATCHED THEN
DELETE




What did I misunderstand?
How to make it work?


Best regards.
Chris
コメント
There are no comments made yet.
Christian Breu 承諾済みの回答
I tested with VServer 7.1.6 – is it a problem with that version?
コメント
There are no comments made yet.
Sergey Pashkov 承諾済みの回答
Hello Christian,

No, it is in the latest versions, too.
It is a limitation of the JOIN operator, we'll check if there any other way to do it.
コメント
There are no comments made yet.
Christian Breu 承諾済みの回答
Hi Sergey

A full implementation of Merge, to work as expected, would be great – save my day...
...and a reason for my customer to update to the latest version of VServer. ;)


Thank you for support.
Best regards.

Chris
コメント
There are no comments made yet.
Christian Breu 承諾済みの回答
Do I have to set it as a feature request somewhere?
コメント
There are no comments made yet.
Sergey Pashkov 承諾済みの回答
I added a feature request for JOIN operation which is used in MERGE command.
参照
  1. http://valentina-db.com/bt/view.php?id=8513
コメント
There are no comments made yet.
Christian Breu 承諾済みの回答
Thank you Sergey!
コメント
There are no comments made yet.
Christian Breu 承諾済みの回答
Hoping for some progress about this topic.
コメント
There are no comments made yet.
François Van Lerberghe 承諾済みの回答
Hi Christian,

Try with this link code :

ON (isource.artikelnummer = mtarget.artikelnummer AND isource.barcode = CONCAT(mtarget.barcode))
コメント
There are no comments made yet.
Ruslan Zasukhin 承諾済みの回答
Hi Christian,

Ivan worked the prev week to improve join, and MERGE

we will ship OR 9.1.5 or 9.2 next week.

IF this is VERY VERY urgent -- let me know, then we will try 9.1.5 asap
if can wait to weekend - then we hope for 9.2 ready
コメント
There are no comments made yet.
Christian Breu 承諾済みの回答
Hello Ruslan

Thank you for the info.
What does it mean v9.2 – before/until may 20?
This should be ok.
コメント
There are no comments made yet.
Ruslan Zasukhin 承諾済みの回答
9.1.5 archive can be found here already:

http://valentina-db.com/download/prev_releases/9.1.5
コメント
There are no comments made yet.
Christian Breu 承諾済みの回答
is it implemented already?
コメント
There are no comments made yet.
Christian Breu 承諾済みの回答
Can you please update the samples too?
I could not get it to work with 9.1.5
コメント
There are no comments made yet.
Ivan Smahin 承諾済みの回答
It should work for "MATCHED" actions as you wrote above ("NOT MATCHED" actions are still not supported for such a complex conditions).
コメント
There are no comments made yet.
  • ページ :
  • 1
  • 2


There are no replies made for this post yet.
However, you are not allowed to reply to this post.

Categories

Announcements & News
  1. 0 subcategories
Valentina Studio
  1. 2 subcategories
Valentina Server
  1. 4 subcategories
Valentina Database ADK
  1. 0 subcategories
Valentina Reports ADK
  1. 0 subcategories
Other Discussions
  1. 2 subcategories
BETA Testing
  1. 0 subcategories
Education & Research
  1. 0 subcategories