Bheema_Tyco has asked for the wisdom of the Perl Monks concerning the following question:
I want to test a particular Scenario in my code, that is, How my code will responds if any DB(oracle) error occurs while processing the particular transaction. So for that i need to throw db error intentionally, How can i do it in my Perl code.
Thanks in advance
Bheema..
Re: Throw DB error
by Anonymous Monk on Mar 02, 2010 at 09:03 UTC
|
| [reply] |
Re: Throw DB error
by mje (Curate) on Mar 02, 2010 at 09:04 UTC
|
May be I am misunderstanding your question but if all you want is to get a database error why can't you change your code to provide incorrect SQL syntax or an incorrect parameter to a procedure or whatever. If you cannot change your code can you lock a table the code uses and wait for a lock timeout? This seems so straight forward I'm sure you must mean something else. If so what kind of "database" error do you need?
| [reply] |
|
Rather than locking a table (very unusual in Oracle), you can try simply misspelling a column name in your SQL statement. Oracle's compiler will throw an error for that.
select fred from global_name
*
ERROR at line 1:
ORA-00904: "FRED": invalid identifier
| [reply] [d/l] |
|
| [reply] |
|
| [reply] |
|
If you don't want to change your SQL then you will have to create a problem at the database end by ensuring some of your SQL fails - e.g., manually create a row which will cause a constraint to fail in your SQL, delete a key, change permissions etc. The possibilities are endless so I'm not listing all I can think of here.
| [reply] |
|
|
|
|