Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Throw DB error

by mje (Curate)
on Mar 02, 2010 at 09:04 UTC ( [id://826108]=note: print w/replies, xml ) Need Help??


in reply to Throw DB error

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?

Replies are listed 'Best First'.
Re^2: Throw DB error
by Anonymous Monk on Mar 02, 2010 at 20:07 UTC
    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

      Thanks for your reply. But i thing is, my code has to run for some extent then it has to throw DB error. So that only i can test my code for particular case. Tell me how can i throw db error at somewhere middle in the code

      By Bheema

Re^2: Throw DB error
by Bheema_Tyco (Novice) on Mar 03, 2010 at 05:51 UTC

    Thanks for your Ans But the thing i don't wants to change my SQL query. Because for extent it should work and then it should throw db error. So how should i throw db error intentionally

    By Bheema

      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.

        I am sorry again i am disturbing YOU. i don't want to change either in sql query or deleting rows. I am asking that, is there any mechanism in perl that a person can throw error intentionally. Because i am using

        $SIG{__WARN__} = \&WARN_Handler; $SIG{__DIE__} = \&DIE_Handler;

        And i also written code for handle error using WARN_HANDLER AND DIE_HANDLER

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://826108]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2024-03-29 14:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found