Re: Catch duplicate primary key exeption

Tech-Archive recommends: Fix windows errors by optimizing your registry



If you are doing the insert via a stored procedure, you can do a
"count(id) from mytable" and see if that is greater than zero. If so,
do a "raise error 'social insurance id already exists'". If you are not
inserting with a stored procedure, you have to do the count statment or
a select statement to figure out if the social exists and throw a
similar exception.

sayed

.



Relevant Pages

  • Re: Cant edit form data from stored procedure
    ... If you want to display zero when the field is null, you can apply a number format to the control displaying the value. ... If you want to change the value that is stored to zero, then you will have to use some VBA code on the form to change the null to zero. ... I have narrowed the problem down to how the stored procedure returns the data which I find very odd. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Retrieve Unique Table Value
    ... The @@Error will be zero, ... if so then this stored procedure ... >>it will get a different reg number, ... >>Programmer Analyst III ...
    (microsoft.public.sqlserver.programming)
  • RE: Problem with Output param for stored procedure
    ... As I understand your Query Analyzer results you pass zero and it returns 1. ... > I'm trying to get an error code back from a sqlserver stored procedure; ... > using an Output param to do it. ...
    (microsoft.public.sqlserver.programming)
  • Re: Establishing if procedure parameters are mandatory
    ... look to see if a stored procedure parameter declaration has a default ... That gives you the full text of the stored procedure in question. ... should be ordered by, if I remember correctly, colid2, colid. ... I suspect that it always zero for a view column as well. ...
    (comp.databases.sybase)
  • Re: Timeout on populating a datagrid
    ... I'd review the stored procedure SQL in a query tool and see how long ... An unhandled exception occurred during the execution of the ... >Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior ...
    (microsoft.public.dotnet.framework.aspnet)