LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-08-2004, 04:27 AM   #1
champ
Member
 
Registered: Jul 2002
Distribution: Slackware 10.0
Posts: 46

Rep: Reputation: 16
perl & oracle triggers


Im creating a web application using perl and connecting to oracle through DBI.

I have created a few triggers in my database. These triggers can throw various kinds of
application errors depending on different conditions

Code:
create or replace trigger xxx
before insert into table
for each row

begin
   // select statement

   if (condition1)
   then
      raise_application_error(-22222, 'error1');
   else
       // ok
   end if

   if (condition2)
   then
      raise_application_error(-22223, 'error1');
   else
       // ok
   end if

end;
my problem is this. If there is an error, how do I find out which error that was thrown?

my perl code is something like this

Code:
$sth = $dbh->prepare(sql statement);

unless ($sth->execute())
{
   // error occured
}

// query ok
When I check the error I can print the error message using $DBI::errstr, but I don't want show that on the screen. Is it possible to only display the message I wrote in the raise_application_error statement in my trigger. Or some way of distinguishing the errors.

Any help would be appriciated.
 
Old 07-08-2004, 09:49 AM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
Use:
Code:
$sth->err() -- error number
$sth->errstr() -- error description
$sth->state() -- SQLSTATE, Oracle returns S100, meaning ti is not supported.
 
Old 07-12-2004, 08:32 AM   #3
champ
Member
 
Registered: Jul 2002
Distribution: Slackware 10.0
Posts: 46

Original Poster
Rep: Reputation: 16
yeah I have read about those methods somewhere....I'll give it a try. Thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
DBD-Oracle perl module hassan2 SUSE / openSUSE 5 02-22-2012 11:28 AM
Snes9x w/ analog L & R triggers? skubik Linux - Games 6 07-22-2005 01:53 AM
ORACLE/Perl question jjmaher Linux - Enterprise 1 04-08-2005 05:18 PM
Mouse triggers? carlosinfl Linux - Hardware 0 01-31-2005 02:18 AM
php & oracle 9i dominant Linux - Newbie 9 07-20-2004 10:18 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration