Home » Developer & Programmer » Reports & Discoverer » display error message..
icon7.gif  display error message.. [message #262770] Tue, 28 August 2007 04:47 Go to next message
brintha
Messages: 28
Registered: August 2007
Junior Member
hi all,
can anybody help me in displaying error message when the passed parameter doesnot match any value in the database.
I tried out the following code...

begin
temp varchar2(20);
SELECT LOCATION_XID INTO temp FROM LOCATION WHERE
LOCATION_XID=:P_PROVID;
IF temp IS NULL THEN
SRW.MESSAGE(2,'INVALID PROVIDER ID');
raise SRW.PROGRAM_ABORT;
END IF;
end;


:P_PROVID is the parameter that is passed. I checked this against the location id. I added the code in after parameter form report triggers. I got an error.

REP - 1401:'afterpform'
Fatal PL/SQL error occured
ORA-01403 no data found.


Please help me in where to write that code in validation triggers or afterpform ? and is this code correct?

thanks & regards,
brintha.r






Re: display error message.. [message #262824 is a reply to message #262770] Tue, 28 August 2007 05:56 Go to previous messageGo to next message
Littlefoot
Messages: 20888
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I'd suggest you to read OraFAQ Forum Guide to learn how to properly format your messages. Also, in there you'll find link to official Oracle documentation - search for PL/SQL book and learn how PL/SQL blocks are to be written.

Now, back to your question.

If your code was correct, it would compile.

A variable is to be declared out of the BEGIN-END block.
You can not use 'IF temp IS NULL ...' because query returned with no records (i.e. NO-DATA-FOUND), and such things are handled via exception handlers.

Something like this:
function AfterPForm return boolean is
  temp varchar2(1);
begin
  select null
    into temp
    from dept
    where deptno = :p_1;

  return (TRUE);
  
exception
  when no_data_found then
    srw.message(1000, 'Invalid dept. number');
    raise srw.program_abort;
	  
  return (TRUE);
end;
Re: display error message.. [message #263220 is a reply to message #262824] Wed, 29 August 2007 07:30 Go to previous message
brintha
Messages: 28
Registered: August 2007
Junior Member
hi littlefoot,
Thanks for your reply.

regards,
brintha.r
Previous Topic: dynamic linking
Next Topic: REP-1401 Fatal PL/SQL error occured. ORA-06508:PL/SQL: cound not find program unit being called
Goto Forum:
  


Current Time: Sat Dec 03 01:27:34 CST 2016

Total time taken to generate the page: 0.18241 seconds