Powerbuilder datawindow

Hi!
I'm importing a some data into my application. The way I do this is to
insert a the rows into a datawindow and then do an update() on the
datawindow.
If a row in the database allready exists with the same primary key as I have
inserted into the datawindow, what will happen then? Will then datawindow do
an update or will I get an error?
I'm doing this on a datastore object. How can I get an errormessage from the
datastore? I have tried the errormessages and codes from the transaction
object (sqlca.sqlerrtext and sqlca.sqlcode).
Jan Erik

0
Jan
12/17/2001 4:25:20 PM
📁 sybase.powerbuilder.datawindow
📃 28057 articles.
⭐ 5 followers.

💬 2 Replies
👁️‍🗨️ 1596 Views


> If a row in the database allready exists with the same >primary key as I
have
> inserted into the datawindow, what will happen then? Will then datawindow
do
> an update or will I get an error?
you will get an error stating that the primary key is not unique and the
datawindow will fail to update.
> I'm doing this on a datastore object. How can I get an errormessage from
the
> datastore? I have tried the errormessages and codes from the transaction
> object (sqlca.sqlerrtext and sqlca.sqlcode).
in this instance, i'm not sure that error codes will help you, as they won't
point you to which row is a duplicate. you'll get a general message that
states that the primary key is not unique.

0
Matt
12/17/2001 5:04:51 PM
<<
I'm importing a some data into my application. The way I do this is to
insert a the rows into a datawindow and then do an update() on the
datawindow.
If a row in the database allready exists with the same primary key as I 
have
inserted into the datawindow, what will happen then? Will then datawindow 
do
an update or will I get an error?
I'm doing this on a datastore object. How can I get an errormessage from 
the
datastore? I have tried the errormessages and codes from the transaction
object (sqlca.sqlerrtext and sqlca.sqlcode).
>>
The update will fail if you get a duplicate key error on the insert.  The 
status of the rows pior to the one that failed will depend upon your 
transaction management.  IOW, they may or may not be committed.
To capture any error on the update call from a datastore, you need to 
create a user object based upon a datastore and add code in the dberror 
event.  This event gets parameters already to indicate the sqlcode, 
errortext, etc.  You would need to add code to display the error or handle 
it in some other way.
HTH,
steve
[TeamSybase]
0
Steve_Katz_
12/17/2001 5:12:24 PM
Reply: