Home > Archive > SQL Anywhere Mobile > March 2005 > Global Primary Key









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 Global Primary Key
Andy

2005-03-30, 9:42 am

using asa 9.02, 2552

I use global autoincrement to keep the primary keys unique. I got some
problem with some primary key which have been inserted manually into the
wrong range. To avoid this problem I'd like to block pirmary keys out of
range defined by global database ID and partition. Is there an easy way to
block all primary key out of range?

thanks a lot.


Greg Fenton

2005-03-30, 9:42 am

Andy wrote:
>
> I use global autoincrement to keep the primary keys unique. I got some
> problem with some primary key which have been inserted manually into the
> wrong range. To avoid this problem I'd like to block pirmary keys out of
> range defined by global database ID and partition. Is there an easy way to
> block all primary key out of range?


Can you describe what you mean by "block" ? Do you want to block
inserts from happening in the remote or do you want to block the rows
from being uploaded to the consolidated?

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

2005-03-30, 9:42 am

I want to block inserts from happening in the remote.


"Greg Fenton" <greg. fenton_NOSPAM_@ianyw
here.com> schrieb im Newsbeitrag
news:42265cf9@forums
-2-dub...
> Andy wrote:
>
> Can you describe what you mean by "block" ? Do you want to block inserts
> from happening in the remote or do you want to block the rows from being
> uploaded to the consolidated?
>
> greg.fenton
> --
> Greg Fenton
> Consultant, Solution Services, iAnywhere Solutions
> --------
> Visit the iAnywhere Solutions Developer Community
> Whitepapers, TechDocs, Downloads
> http://www.ianywhere.com/developer/



Breck Carter [TeamSybase]

2005-03-30, 9:42 am

You could write a row level insert trigger that does a ROLLBACK
TRIGGER WITH RAISERROR if it detects an out-of-bounds insert.

Breck

On 3 Mar 2005 10:50:14 -0800, "John" <mail@aherren.ch> wrote:

>I want to block inserts from happening in the remote.
>
>
>"Greg Fenton" <greg. fenton_NOSPAM_@ianyw
here.com> schrieb im Newsbeitrag
> news:42265cf9@forums
-2-dub...
>


--
SQL Anywhere Studio 9 Developer's Guide
Buy the book: http://www.amazon.com/exec/obidos/A...7/risingroad-20
bcarter@risingroad.com
RisingRoad SQL Anywhere and MobiLink Professional Services
www.risingroad.com
David Fishburn

2005-03-30, 9:43 am

"Breck Carter [TeamSybase]" < NOSPAM__bcarter@risi
ngroad.com> wrote in
news:1moe21lnsqi67f1
e0lri7ouqcn3pnua4r8@
4ax.com of
sybase.public.sqlanywhere.mobilink:

BC> You could write a row level insert trigger that does a ROLLBACK
BC> TRIGGER WITH RAISERROR if it detects an out-of-bounds insert.

Well, you can't issue a ROLLBACK by default in ASA, but it should be
enough to RAISERROR to fail the operation.

For the range question, you can do this inside your trigger:


declare @global_database_id integer

select "setting"
into @Global_database_id
from SYS.SYSOPTIONS
where "user_name" = 'PUBLIC'
and "option" = 'Global_database_id'


Then depending on how you specified the range each table gets:

if @@identity < ( 1000000 * @Global_database_id + 1 )
RAISERROR ...
end if


--
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]

Breck Carter [TeamSybase]

2005-03-30, 9:43 am

On 14 Mar 2005 12:31:37 -0800, David Fishburn
<fishburn_spam@off.ianywhere.com> wrote:

>"Breck Carter [TeamSybase]" < NOSPAM__bcarter@risi
ngroad.com> wrote in
> news:1moe21lnsqi67f1
e0lri7ouqcn3pnua4r8@
4ax.com of
>sybase.public.sqlanywhere.mobilink:
>
>BC> You could write a row level insert trigger that does a ROLLBACK
>BC> TRIGGER WITH RAISERROR if it detects an out-of-bounds insert.
>
>Well, you can't issue a ROLLBACK by default in ASA


Not a ROLLBACK, but a ROLLBACK TRIGGER, in this case including the
WITH RAISERROR option. Works well in ASA.

Breck

--
SQL Anywhere Studio 9 Developer's Guide
Buy the book: http://www.amazon.com/exec/obidos/A...7/risingroad-20
bcarter@risingroad.com
RisingRoad SQL Anywhere and MobiLink Professional Services
www.risingroad.com
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