LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   perl & oracle triggers (https://www.linuxquestions.org/questions/programming-9/perl-and-oracle-triggers-202506/)

champ 07-08-2004 04:27 AM

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.

jim mcnamara 07-08-2004 09:49 AM

Use:
Code:

$sth->err() -- error number
$sth->errstr() -- error description
$sth->state() -- SQLSTATE, Oracle returns S100, meaning ti is not supported.


champ 07-12-2004 08:32 AM

yeah I have read about those methods somewhere....I'll give it a try. Thanks


All times are GMT -5. The time now is 09:37 PM.