Home » Developer & Programmer » Application Express, ORDS & MOD_PLSQL » Termination Message (Oracle 11g,Win 7 32-bit,Apex 4.0)
Termination Message [message #614697] Mon, 26 May 2014 03:18 Go to next message
Xandot
Messages: 235
Registered: January 2014
Location: India
Senior Member
Hello All,

I want to restrict the user when certain condition is correct so i want to raise one message like "You can not edit this entry"
and after that pointer goes to the back button ..no data will be commit...

Like in Oracle forms we put :--

"raise form_trigger_failure;" for termination purpose .



Thanks
Re: Termination Message [message #614698 is a reply to message #614697] Mon, 26 May 2014 03:32 Go to previous messageGo to next message
Littlefoot
Messages: 21806
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Create a validation (such as Function Returning Error Text).
Re: Termination Message [message #614704 is a reply to message #614698] Mon, 26 May 2014 04:42 Go to previous messageGo to next message
Xandot
Messages: 235
Registered: January 2014
Location: India
Senior Member
Thanks for reply Littlefoot...

My validation are following ....
---------------------------------
declare
v_count number;
begin
select count(*) into v_count from xyz where col1=? ;

if nvl(v_count,0)>1 then
return 'Records exists some where else. ';
else
return null;
end if;
end;
-------------------------------------------

So how can i put this into the function returning error ....


Thanks
Re: Termination Message [message #614747 is a reply to message #614704] Mon, 26 May 2014 13:22 Go to previous messageGo to next message
Littlefoot
Messages: 21806
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
You don't need NVL as COUNT won't return NULL.

Try to rewrite it as
declare
  v_count number;
begin
  select count(*)
    into v_count
    from xyz
    where col1 = <what? Can't be a question mark, as you put it>;

  return (v_count) > 1;
end;

Then put your message text into the next field("Message text", I believe):
Records exist somewhere else
Re: Termination Message [message #614774 is a reply to message #614747] Tue, 27 May 2014 02:19 Go to previous messageGo to next message
Xandot
Messages: 235
Registered: January 2014
Location: India
Senior Member
When i am going to put this condition as you mention above so the application raise ORA-06550 (You tried to execute an invalid block of PLSQL code)..
Re: Termination Message [message #614776 is a reply to message #614774] Tue, 27 May 2014 02:33 Go to previous messageGo to next message
Littlefoot
Messages: 21806
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
True; I wasn't careful enough when replying to your question, sorry. I didn't have Apex at hand at the moment so I didn't test it.

As it is a function that returns error text, you should return that text directly. So:
declare
  v_count number;
begin
  select count(*)
    into v_count
    from xyz
    where col1 = <what? Can't be a question mark, as you put it>;

  if v_count > 1 then
     return ('Records exist somewhere else');
  end if;
end;

You don't have to enter anything into the "Error message" (the one I called "Message text" previously) field.

[Updated on: Tue, 27 May 2014 02:34]

Report message to a moderator

Re: Termination Message [message #614784 is a reply to message #614776] Tue, 27 May 2014 02:54 Go to previous message
Xandot
Messages: 235
Registered: January 2014
Location: India
Senior Member
Yup , Its working correctly ....

Again Thank you Littlefoot...Smile
Previous Topic: Limited data export in excel
Next Topic: Export Database
Goto Forum:
  


Current Time: Thu Mar 28 15:07:12 CDT 2024