Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Throw DB error

by Bheema_Tyco (Novice)
on Mar 02, 2010 at 06:50 UTC ( #826081=perlquestion: print w/replies, xml ) Need Help??

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..

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

      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

      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://826081]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2023-12-06 21:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (32 votes). Check out past polls.

    Notices?