because ValidateWrite does not check this potential maybe raising sql
exeption.

i think this method will be the right place to integrate the time consuming
pre check to give the user a friendly informative status of the potential
violation candidate.

in general this prechecking is the not the state of the art method, because:

EVERY unique index has to checked using a own sql statement against the
database for a potential conflict. That can be very very very time
consuming.

The database server itself can detect this (due to a raised exception) even
more faster.


normal way: (cant be used with axapta)
            destructive optimitic brute force and fast

            transaction start;
            insert the record;
            except
              parse the native id to check if it raised due to a unique key
violation
              // error ids  depends on the database used : ora, ms-sql ,...
              if (yes)
                return notok;
              else
                rethrow this other database execption to sql client
            no except
              delete the record
              return ok
            transaction end;

            means normally the record is going to be inserted and a possible
            database exception for exactly the unique index violation is
captured


the main problem is the missing access to additional db native error
information within axapta's exception handling.
the other problem is the "drawn recID" for this "brute force check"


axapta way:
            non desturctive pessimistic concept and slow

loop over all unique indexes (there's only one primary)
keep in mind possible deactivated configurationkeys and/or array fields

build a query for each of the fieldcombinations and check existence using a
queryrun/query combination with querybuildranges for each of the index
fields setting their values to the current one from the record which should
be checked.

regards and happy coding

Douglas

cu sometimes at the restaurant at the end of universe

----- Original Message -----
From: "Bayliss, Barry" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, June 01, 2005 12:26 AM
Subject: RE: [development-axapta] How to determine the primary index of a
table


>
> Why not use the ValidateWrite() method on the table concerned?
>
>
> Barry.
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[EMAIL PROTECTED] On Behalf Of smeagul2303
> Sent: Tuesday, 31 May 2005 6:42 PM
> To: [email protected]
> Subject: [development-axapta] How to determine the primary index of a
> table
>
> I want to write a method which tests if a record can be inserted in
> a table without violating any primary index declarations (no doubles).
>
> But how do i find the primary index of a table ?
>
> Regards
>
> Manfred
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>



Yahoo! Groups Links

Reply via email to