What is @@ERROR ?

What is @@ERROR ?

Post by Sathya » Sun, 10 Jan 1999 04:00:00



Where am I making mistake?
I want to automatically rollback the inserts as I  am
trying insert duplicate rows.

begin tran TRAN1

begin
 delete from test
 insert into test(x,y) values (2,12)
 insert into test(x,y) values (3,12)
 insert into test(x,y) values (3,12)
 select * from test
end



 commit tran TRAN1
else
 rollback tran TRAN1

Result :

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

Msg 2627, Level 14, State 1
Violation of PRIMARY KEY constraint 'PK___1__10': Attempt to insert
duplicate key in object 'test'.
Command has been aborted.
x           y
----------- -----------
2           12
3           12

(2 row(s) affected)

-----------
0

(1 row(s) affected)



Sathyan

 
 
 

What is @@ERROR ?

Post by Tony Rogerso » Sun, 10 Jan 1999 04:00:00


@@error should be checked after each statement thus..

insert


insert


insert


--
Hope the above helps.

Tony Rogerson MCP, MS SQL Server MVP
Torver Computer Consultants Ltd
London, England.


>Where am I making mistake?
>I want to automatically rollback the inserts as I  am
>trying insert duplicate rows.

>begin tran TRAN1

>begin
> delete from test
> insert into test(x,y) values (2,12)
> insert into test(x,y) values (3,12)
> insert into test(x,y) values (3,12)
> select * from test
>end



> commit tran TRAN1
>else
> rollback tran TRAN1

>Result :

>(1 row(s) affected)

>(1 row(s) affected)

>(1 row(s) affected)

>Msg 2627, Level 14, State 1
>Violation of PRIMARY KEY constraint 'PK___1__10': Attempt to insert
>duplicate key in object 'test'.
>Command has been aborted.
>x           y
>----------- -----------
>2           12
>3           12

>(2 row(s) affected)

>-----------
>0

>(1 row(s) affected)



>Sathyan


 
 
 

What is @@ERROR ?

Post by Ian Posne » Mon, 11 Jan 1999 04:00:00



check it after each action.

A superior solution would be to insert all the data into a temporary table,
then perform an INSERT INTO FINALTABLE SELECT DISTINCT <COLUMNS> FROM
TEMPTABLE.

That will give you the results you want in a much cleaner manner with no
errors.

--

Ian Posner
MindQuest Solutions Ltd


>Where am I making mistake?
>I want to automatically rollback the inserts as I  am
>trying insert duplicate rows.

>begin tran TRAN1

>begin
> delete from test
> insert into test(x,y) values (2,12)
> insert into test(x,y) values (3,12)
> insert into test(x,y) values (3,12)
> select * from test
>end



> commit tran TRAN1
>else
> rollback tran TRAN1

>Result :

>(1 row(s) affected)

>(1 row(s) affected)

>(1 row(s) affected)

>Msg 2627, Level 14, State 1
>Violation of PRIMARY KEY constraint 'PK___1__10': Attempt to insert
>duplicate key in object 'test'.
>Command has been aborted.
>x           y
>----------- -----------
>2           12
>3           12

>(2 row(s) affected)

>-----------
>0

>(1 row(s) affected)



>Sathyan

 
 
 

What is @@ERROR ?

Post by Aaron Goldma » Mon, 11 Jan 1999 04:00:00



error.



to 0).

aaron


>Where am I making mistake?
>I want to automatically rollback the inserts as I  am
>trying insert duplicate rows.

>begin tran TRAN1

>begin
> delete from test
> insert into test(x,y) values (2,12)
> insert into test(x,y) values (3,12)
> insert into test(x,y) values (3,12)
> select * from test
>end



> commit tran TRAN1
>else
> rollback tran TRAN1

>Result :

>(1 row(s) affected)

>(1 row(s) affected)

>(1 row(s) affected)

>Msg 2627, Level 14, State 1
>Violation of PRIMARY KEY constraint 'PK___1__10': Attempt to insert
>duplicate key in object 'test'.
>Command has been aborted.
>x           y
>----------- -----------
>2           12
>3           12

>(2 row(s) affected)

>-----------
>0

>(1 row(s) affected)



>Sathyan

 
 
 

1. error ORA-01855: AM/A.M. or PM/P.M. required

Our VB 6 program access Oracle database using MS ODBC for Oracle. The
program is trying to run the following SQL stt:
select DATANOTES_NOTES from DATANOTES where EEI_KEY = 654 and DATANOTES_DATE
= TO_DATE('04/11/2002 11:10:45 AM','MM/DD/YYYY HH:MI:SS AM')

The Time Format and Date Format setting in Control Panel - Regional Setting
are the following:
Time Format: HH:mm:ss
Date Format: dd/MM/yyyy
For example: 11/04/2002 14:10:10 for April 11, 2002 2:10:10 PM

On a machine that uses MS Odbc for Oracle version 2.573.6019.00 I got an
error
[Microsoft][ODBC driver for Oracle][Oracle]ORA-01855: AM/A.M. or PM/P.M.
required.
I do not get this error on a machine that uses MS Odbc for Oracle version
2.573.5303.00 or MS Odbc for Oracle version 2.573.7713.00.

Is this a problem with MS Odbc for Oracle version 2.573.6019.00?

Thank you.

2. PRESS: PowerPlay and MetaCube

3. Locking error, DataControl Error, or am I stupid ?

4. Problems with SQL 7.0 and ODBC Driver 3.70.06.23 with Datetime (Fractional truncation)

5. Busy Day = Slowdown from 12 AM - 5 AM

6. IRVING -- Oracle DBA

7. I am getting this message when i am tring to export or import anything using

8. Outputting days of the month for the next 5 years

9. Use of @am, Am I dumb?

10. odd errors I am receiving

11. Null Values - WHY am I getting this error?

12. why am I getting this error?

13. I am getting the following connect error