exception handling sqlserver (insert statement)

exception handling sqlserver (insert statement)

Post by ramirezmend » Wed, 30 May 2001 19:48:11



why does the insert statement don't work???
(the duration row is a int type.)

insert into log(duration)values('90890p')

BEGIN  
  print 'error'
END

 
 
 

exception handling sqlserver (insert statement)

Post by Bob Pfeif » Wed, 30 May 2001 20:11:10


If the duration column is an int datatype, you can't insert a value that has
an alphabetical character in it.

 
 
 

exception handling sqlserver (insert statement)

Post by Mark Allis » Wed, 30 May 2001 22:44:27


You are trying to insert a character into an integer field. Change
your datatype in the table of remove the character.

Mark Allison.


> why does the insert statement don't work???
> (the duration row is a int type.)

> insert into log(duration)values('90890p')

> BEGIN  
>   print 'error'
> END

 
 
 

1. Exception handling for dynamic SQL statement

Hi,

is anyone know how to make exception handling for dynamic PL/SQL statement?

it seems my exception handling cannot catch the error when my insert
statement get error. It just leave as program success. But if I turn off the
exception section, it will give me error report

ERROR at line 1:
ORA-01401: inserted value too large for column
ORA-06512: at "SYSADM.RU2", line 84
ORA-06512: at line 1
ORA-00001: unique constraint (SYSADM.PS_MESSAGE_LOG) violated

following is my code.

Thanks for your help!!

Phil

PROCEDURE RU2
(
...parameters...
)
IS
/*  declaration */
/*--------------------------------------------------------*/
BEGIN
     /* open a cursor for this next object */
     cursor_handle := DBMS_SQL.OPEN_CURSOR;
     /* Construct the SQL statement and parse it. */
     DBMS_SQL.PARSE(
         cursor_handle,
          'INSERT INTO PS_MESSAGE_LOG (....) VALUES (...);
     DBMS_SQL.BIND_VARIABLE(...);
     .....
     ReturnCode := DBMS_SQL.EXECUTE(cursor_handle);
     DBMS_SQL.CLOSE_CURSOR(cursor_handle);
---------------------------------------------------
EXCEPTION
---------------------------------------------------
  WHEN OTHERS
  THEN
        DBMS_OUTPUT.ENABLE;
        DBMS_OUTPUT.PUT_LINE('some error message here');
        DBMS_OUTPUT.DISABLE;
END; --end of procedure RU2

2. OLE objects from Paradox table to Delphi form?

3. Exception handling in CREATE FUNCTION - how to handle - URGENT HELP NEEDED

4. ADO via OLE DB on Oracle

5. Problem with Insert command statement and updating SqlServer

6. pdox5.0:multipage-forms:DON'T WORK OK!!

7. select + insert vs. insert and catching exception

8. Embedded SQL and exception handling

9. Strange behavior of SQL Server for exception handling

10. Exception Handling

11. exception handling

12. SQL Server 7 error (exception) handling