Home » Developer & Programmer » Forms » Validating the Item (Forms 10g)
Validating the Item [message #526224] Mon, 10 October 2011 04:33 Go to next message
sivaora
Messages: 119
Registered: October 2009
Location: Hyderabad
Senior Member
Hi All,

I created a block for EMP table on tabular style.
if in first line empno entered is 1
then i dont want to allow the end user to enter 1 in second line.
but when-validate-item is not working because first_record and next_record is not allowed.
i need to validate before saving the data into emp table and immediately after empno is entered into empno item.

Please help me on this...
Re: Validating the Item [message #526226 is a reply to message #526224] Mon, 10 October 2011 04:37 Go to previous messageGo to next message
cookiemonster
Messages: 13931
Registered: September 2008
Location: Rainy Manchester
Senior Member
Post the Data to the DB using the post builtin (when-new-record-instance is probably the best place for this). Then you can use a select statement in the WVI trigger to check if the user has already entered the value.
Re: Validating the Item [message #526228 is a reply to message #526226] Mon, 10 October 2011 04:44 Go to previous messageGo to next message
sivaora
Messages: 119
Registered: October 2009
Location: Hyderabad
Senior Member
Thanks for your quick reply,

i used the Post built in already, It causes error because of my validation the total no of employees must be 10 before saving it to DB.
So i need to check for each line before storing the data into DB.

Re: Validating the Item [message #526229 is a reply to message #526228] Mon, 10 October 2011 04:50 Go to previous messageGo to next message
Littlefoot
Messages: 21817
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
POST <> COMMIT.

Are you sure you used POST and not COMMIT?

By the way, that restriction sounds interesting. You'll prevent entering employees' data if there's less than 10 of them? How cool.
Re: Validating the Item [message #526232 is a reply to message #526229] Mon, 10 October 2011 04:56 Go to previous messageGo to next message
sivaora
Messages: 119
Registered: October 2009
Location: Hyderabad
Senior Member
Hi,

Can you please tell me how to use Post with no commit.

My code is:

IF :SYSTEM.BLOCK_STATUS = 'CHANGED' THEN
POST;
END IF;
Re: Validating the Item [message #526237 is a reply to message #526232] Mon, 10 October 2011 05:06 Go to previous messageGo to next message
cookiemonster
Messages: 13931
Registered: September 2008
Location: Rainy Manchester
Senior Member
Post doesn't commit. That's kind of the point of it.

Your 10 emp restriction is going to be very hard to implement correctly. I wouldn't even try.
Re: Validating the Item [message #526238 is a reply to message #526232] Mon, 10 October 2011 05:06 Go to previous messageGo to next message
Littlefoot
Messages: 21817
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
That seems to be OK.

It seems that I didn't understand how it prevents you to do what Cookiemonster said.
Re: Validating the Item [message #526241 is a reply to message #526238] Mon, 10 October 2011 05:17 Go to previous messageGo to next message
sivaora
Messages: 119
Registered: October 2009
Location: Hyderabad
Senior Member
How to implement Post does not Commit, there is no such type of built ins to use...
Re: Validating the Item [message #526245 is a reply to message #526241] Mon, 10 October 2011 05:31 Go to previous messageGo to next message
cookiemonster
Messages: 13931
Registered: September 2008
Location: Rainy Manchester
Senior Member
You don't understand the difference between post and commit obviously. Post does not commit. Ever. There's nothing to do to make it not commit.

Post - applies changes to the DB but does not issue a commit. So if the user decides not to save changes, those changes are rolled back.
Re: Validating the Item [message #526246 is a reply to message #526245] Mon, 10 October 2011 05:38 Go to previous messageGo to next message
sivaora
Messages: 119
Registered: October 2009
Location: Hyderabad
Senior Member
Post Doesn't commit the data which i knew already it's ok.

But if i apply post for the first record my validation fails as the no of employees should be 10. so i can't apply post here.

Re: Validating the Item [message #526247 is a reply to message #526246] Mon, 10 October 2011 05:42 Go to previous messageGo to next message
cookiemonster
Messages: 13931
Registered: September 2008
Location: Rainy Manchester
Senior Member
How are you doing the validation to check the number of employees?
Re: Validating the Item [message #526261 is a reply to message #526247] Mon, 10 October 2011 06:30 Go to previous messageGo to next message
sivaora
Messages: 119
Registered: October 2009
Location: Hyderabad
Senior Member
i created a button to save the form, and in that i am checking with :SYSTEM.CURSOR_RECORD is 10 or not.
Re: Validating the Item [message #526263 is a reply to message #526261] Mon, 10 October 2011 06:32 Go to previous messageGo to next message
cookiemonster
Messages: 13931
Registered: September 2008
Location: Rainy Manchester
Senior Member
Trouble with that is that if the user enters some data, then clicks on the exit button, forms will ask them if they want to save changes. If they click yes, forms will write all data from the datablocks to the DB and commit it. Bypassing your code in the save button in the process.
Re: Validating the Item [message #526265 is a reply to message #526263] Mon, 10 October 2011 06:40 Go to previous messageGo to next message
sivaora
Messages: 119
Registered: October 2009
Location: Hyderabad
Senior Member
I am restrictint those standard message by :system.message_level := '25';
Re: Validating the Item [message #526266 is a reply to message #526265] Mon, 10 October 2011 06:44 Go to previous messageGo to next message
sivaora
Messages: 119
Registered: October 2009
Location: Hyderabad
Senior Member
So, is there is any way to Validate the lines before saving to Data base.
Re: Validating the Item [message #526269 is a reply to message #526266] Mon, 10 October 2011 06:50 Go to previous messageGo to next message
Littlefoot
Messages: 21817
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
You said that you are checking whether :system.cursor_record = 10. If it is not, you raise an error and everything Cookiemonster suggested isn't even executed.

So, put that ("10 records") condition to the end of the procedure, so that everything else is checked first, and that condition would be the last.
Re: Validating the Item [message #526272 is a reply to message #526269] Mon, 10 October 2011 07:06 Go to previous message
cookiemonster
Messages: 13931
Registered: September 2008
Location: Rainy Manchester
Senior Member
1) I don't believe any setting of system.message_level can supress the "do you want to save changes message"
2) LF - you miss the point. He's doing validation in a button, because he can't do it in validate triggers. But the button can be bypassed completely. You can't trap the "do you want to save" message.
3) I know of no way of reliably validating multiple records against each other in the same datablock in oracle forms (which is effectively what you are doing). I simply wouldn't try to implement this restriction.
If there really is an issue with entering too few records have a job or something monitor the number the of records and have that raise an alert or send an email or something if there aren't enough.
Previous Topic: LOV dynamic automatic filtering
Next Topic: Preventing Form from thinking it's in 'changed' mode
Goto Forum:
  


Current Time: Sun Aug 11 12:10:04 CDT 2024