0
votes
BEGIN
:P2_RESTUSER ='Y'; 
IF:P2_USERCOMMENT IS NOT NULL
THEN
 Return True;
ELSE
 Return False;

end if;
end;

I am trying to add validate in a page.what I am trying to do is if p2_restuser value is 'y' and p2_usercomment is not null then return true, and any other condition returns the error prompt. However, I am getting following error.

ORA-06550: line 6, column 16: PLS-00103: Encountered the symbol "BEGIN" when expecting one of the following: ( - + case mod new not null continue avg count current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date pipe

How can I fix this code to work the way I wanted?

thank you

2
Two thoughts. First, your error says BEGIN is on line 6 which doesn't line up with the code you've posted. The error it failed on could very well be on a preceding line. Second, you definitely have an error in your assignment to :P2_RESTUSER. The assignment operator in PL/SQL is :=.Chris Hep
First of all if you assign value use := instead of = For future help provide information about type of validation that you use: - PL/SQL Expression - PL/SQL Error - PL/SQL Function Returning Boolean (i believe this is the one) - PL/SQL Function Returning Errorjareeq
I tried to change = to :=, but it still gives me the same error...terny
As mentioned before, you also need to give us the full code. The only BEGIN in the code you posted is on line 1. Your error indicates it is on line 6. Unless I'm crazy, that should mean you have more code you haven't shown us.Chris Hep
Also, glancing over again, I noticed that you have IF:P2_USERCOMMENT all strung together. You should have a space before the colon.Chris Hep

2 Answers

0
votes

Ok, as I understand your way - you are complicating simple things. Basing on data you provided (not much detail of problem but only idea of result) probably simplest will be to create 2 validations

  • validation for P2_RESTUSER as string comparison to 'Y'

  • validation for P2_USERCOMMENT as null comparison

    There is no PL/SQL required in this approach. As other already said - if you insist with PL/SQL - deliver more info.

0
votes

I agree with Jareeq, take a declarative approach instead of PLSQL block. It is simpler and better performance wise.

I am not sure if it helps, but here is a screenshot of how you would go about doing it.

enter image description here

Below link is a good read on various validation types,

http://tonyandrews.blogspot.com/2013/04/apex-conditions-and-performance.html

Also, related article on statistics involved.

http://roelhartman.blogspot.com/2013/05/apex-conditions-and-performance.html