Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
magdaf75
Starting Member
5 Posts |
Posted - 2008-04-13 : 21:06:03
|
| can someone help me how to corect the query,BEGIN TRYINSERT INTO ORDERS VALUES( 1122,'BAC123' );INSERT INTO ORDLINE VALUES( 1122,991,1 );PRINT 'VERY GOOD'END TRYBEGIN CATCHPRINT 'FALSE'INSERT INTO LOGTAB ('BAC123',1122,991,1, ERROR_NUMBER,ERROR_MESSAGE);END CATCHi am getting error:Msg 102, Level 15, State 1, Line 11Incorrect syntax near 'ERROR_NUMBER'. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-13 : 23:31:46
|
quote: Originally posted by magdaf75 can someone help me how to corect the query,BEGIN TRYINSERT INTO ORDERS VALUES( 1122,'BAC123' );INSERT INTO ORDLINE VALUES( 1122,991,1 );PRINT 'VERY GOOD'END TRYBEGIN CATCHPRINT 'FALSE'INSERT INTO LOGTAB VALUES('BAC123',1122,991,1, ERROR_NUMBER,ERROR_MESSAGE);END CATCHi am getting error:Msg 102, Level 15, State 1, Line 11Incorrect syntax near 'ERROR_NUMBER'.
missed a VALUES clause in last insert |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-04-14 : 02:38:50
|
You also need to put the function paranthesises in the query.BEGIN TRY INSERT ORDERS VALUES ( 1122, 'BAC123' ) INSERT ORDLINE VALUES ( 1122, 991, 1 ) PRINT 'VERY GOOD'END TRYBEGIN CATCH PRINT 'FALSE' INSERT LOGTAB VALUES ( 'BAC123', 1122, 991, 1, ERROR_NUMBER(), ERROR_MESSAGE() )END CATCH E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|
|
|
|
|