Home > Archive > SQL Anywhere Mobile > November 2005 > How catch error in insert_upload ?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How catch error in insert_upload ?
Fantom

2005-11-16, 11:24 am

When I in insert_upload inserted record who is not unique and i get error
"Integrity constraint violation: Primary key for table 'Grupa' is not unique
(ODBC State = 23000, Native error code = -193)". How i may catch this erro
and resolving conflicts (for example in this situation i want update record
in consolidate database).

Fantom

Fantom

2005-11-16, 11:24 am

> When I in insert_upload inserted record who is not unique and i get error

> "Integrity constraint violation: Primary key for table 'Grupa' is not

unique
> (ODBC State = 23000, Native error code = -193)". How i may catch this erro
> and resolving conflicts (for example in this situation i want update

record
> in consolidate database).


I know. I must use handle_error ?

Fantom

Fantom

2005-11-16, 11:24 am

> > When I in insert_upload inserted record who is not unique and i get
error

> unique
erro[color=darkred]
> record
>
> I know. I must use handle_error ?


Hmmm. But can i in this event for example change record ?

Fantom

David Fishburn

2005-11-16, 1:24 pm

"Fantom" <szczukot@skasujto.poczta.onet.pl> wrote in
news:437b5288@forums
-1-dub of sybase.public.sqlanywhere.mobilink:

F> When I in insert_upload inserted record who is not unique and i get
F> error "Integrity constraint violation: Primary key for table 'Grupa'
F> is not unique (ODBC State = 23000, Native error code = -193)". How i
F> may catch this erro and resolving conflicts (for example in this
F> situation i want update record in consolidate database).

No, this is not an "update" conflict. It is an INSERT conflict which
YOU the developer must ensure NEVER happens.

I believe our docs list at least 3 different ways to PREVENT this from
occuring.

See the 902 Help file:
MobiLink Administration Guide
Synchronization Techniques
Maintaining unique primary keys

These have little to do with 902, but they are documented there. If you
do not have the 902 docs and the above is not listed in the 803 docs,
they can be downloaded from the usually location to get EBFs.

--
David Fishburn
Certified ASA Developer Version 8
iAnywhere Solutions - Sybase
Professional Services
Please only post to the newsgroup
Please ALWAYS include version and MORE importantly BUILD number with
EACH post (dbeng9 -v).

EBFs and Maintenance Releases
http://downloads.sybase.com/swx/sdmain.stm

Developer Community / Whitepapers
http://www.ianywhere.com/developer

CaseXpress - to report bugs
http://casexpress.sybase.com

CodeXchange - Free samples
[url]http://ianywhere.codexchange.sybase.com/servlets/ ProjectDocumentList[
/url]

Fantom

2005-11-17, 3:25 am

> F> When I in insert_upload inserted record who is not unique and i get
> F> error "Integrity constraint violation: Primary key for table 'Grupa'
> F> is not unique (ODBC State = 23000, Native error code = -193)". How i
> F> may catch this erro and resolving conflicts (for example in this
> F> situation i want update record in consolidate database).
>
> No, this is not an "update" conflict. It is an INSERT conflict which
> YOU the developer must ensure NEVER happens.


I understand. But in example to handle_error is exists : "196 is
SQLE_INDEX_NOT_UNIQU
E
", and i mean that this error is for INSERT possible.
when i have table X:
int id_x (primary key)
char name unique
How i may write script form upload_insert ??

> I believe our docs list at least 3 different ways to PREVENT this from
> occuring.


Ok.

> See the 902 Help file:
> MobiLink Administration Guide
> Synchronization Techniques
> Maintaining unique primary keys
>
> These have little to do with 902, but they are documented there. If you
> do not have the 902 docs and the above is not listed in the 803 docs,
> they can be downloaded from the usually location to get EBFs.


Thanks. This chapter is exists in 803.

Fantom

Fantom

2005-11-17, 3:25 am

i expand this :

> when i have table X:
> int id_x (primary key)
> char name unique
> How i may write script form upload_insert ??


in all (for example one thousend) remote database inserted record where name
= 'name1'
and after 'normal' synch all remotes, in consolidated database i get :
-1000 name1
-2000 name1
-3000 name1
-4000 name1
-5000 name1
.........
- 1000000 name1
This is not elegance i big size in database. I want set name as unique,
catch error in upload_insert (change key in all referenced tables) and get
only
-1000 name1
and in dowlnoad_cursor i want send all records in refernced tables who
changes (and in delete_download_curs
or send 'not inserted' ID).
After this operation in consolidated and remotes i have one this same
record.
This is ok ?

Fantom

Greg Fenton

2005-11-19, 3:23 am

Fantom wrote:
> This is not elegance i big size in database. I want set name as unique,
> catch error in upload_insert (change key in all referenced tables) and get
> only -1000 name1


Recognize that you can do anything you want to in an upload_insert
script. You are not limited to only doing inserts. The event indicates
the type of operation that caused the upload, not what you are forced to
do with the data.

So one option is to do more complex SQL, like check to see if the row
already exists. You could do this in a compound statement (BEGIN ...
END) or in a stored procedure to which you pass all the parameters the
upload_insert has. Another option is to insert all uploaded rows into a
temp table and write an end_upload script to process the rows in the
temp table and move the desired data into the base table.

> and in dowlnoad_cursor i want send all records in refernced tables who
> changes (and in delete_download_curs
or send 'not inserted' ID).


Yes, this is doable. It is a bit tricky as you are essentially fighting
against the "changing primary keys" pattern. The problem is not with
the table in question, but with any child tables (i.e. tables with
foreign keys to this table). If you don't have any such relationships,
then you'll likely be fine.

greg.fenton
--
Greg Fenton
Consultant, Solution Services, iAnywhere Solutions
--------
Visit the iAnywhere Solutions Developer Community
Whitepapers, TechDocs, Downloads
http://www.ianywhere.com/developer/
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com