|
|
|
|
|
|
Re: Item Level Validation checking [message #601455 is a reply to message #601454] |
Thu, 21 November 2013 03:55 |
cookiemonster
Messages: 13937 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
And to go over a conversation we had the other week - what happens if the users use the mouse to navigate out of the item? or key down? or key up? or key prev?
You can not use key-next-item for validation, it can be bypassed.
|
|
|
Re: Item Level Validation checking [message #601459 is a reply to message #601455] |
Thu, 21 November 2013 04:33 |
|
mughals_king
Messages: 392 Registered: January 2012 Location: pakistan
|
Senior Member |
|
|
Yes @cookiemonster you are right for mouse navigation it will be problem i given just example and also for @stalin4d.
for that we need to create timer one timer
------------------------WHEN-VALIDAT-ITEM------------form-level
DECLARE
mughal_timer TIMER;
BEGIN
mughal_timer:=FIND_TIMER('VALIDATE');
IF NOT ID_NULL(mughal_timer) THEN
DELETE_TIMER(mughal_timer);
END IF;
mughal_timer:=CREATE_TIMER('VALIDATE', 1, NO_REPEAT);
END;
------------------WHEN-TIMER-EXPIRED--------------form-level
DECLARE
A NUMBER(1):=0;
F_NAME VARCHAR2(35);
BEGIN
F_NAME:=:EMPNO;
FIRST_rECORD;
WHILE :EMPNO IS NOT NULL LOOP
IF F_NAME=:EMPNO THEN
A:=A+1;
END IF;
NEXT_RECORD;
END LOOP;
PREVIOUS_RECORD;
IF A=2 THEN
MESSAGE('DUPLICATE RECORD');
MESSAGE('DUPLICATE RECORD');
ELSE
NEXT_ITEM;
END IF;
END;
AND THANKS
Regard
Mughal
[Updated on: Thu, 21 November 2013 04:33] Report message to a moderator
|
|
|
|
Re: Item Level Validation checking [message #601483 is a reply to message #601477] |
Thu, 21 November 2013 07:33 |
cookiemonster
Messages: 13937 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
I already pointed out it wouldn't work.
When-timer-expired won't work either - you'll get the message but the wrong data can still be entered.
Littlefoot's suggestion looks like your best bet but it would help if you explained why the block isn't a database block and how the data from it is inserted into the DB.
|
|
|
|
Re: Item Level Validation checking [message #601496 is a reply to message #601441] |
Thu, 21 November 2013 08:14 |
cookiemonster
Messages: 13937 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Make your mind up:
stalin4d wrote on Thu, 21 November 2013 06:46
how to acheive this it in non database block?
In that case the simple answer is to post each record as you go, use when-new-record-instance for this, then you can just put a simple select in the when-validate-item trigger to check if the value is already present.
|
|
|
|
Re: Item Level Validation checking [message #601510 is a reply to message #601477] |
Thu, 21 November 2013 14:00 |
|
mughals_king
Messages: 392 Registered: January 2012 Location: pakistan
|
Senior Member |
|
|
stalin4d wrote on Thu, 21 November 2013 07:22Yes this fires from key-next-item,
but when mouse click or just copy the context of 1st field into 2nd field and
click the save button its not working.
Dear @stalin4d but you did not tell us what are the problem you are facing with my 2nd suggestion when-validate-item and when-timer-expired which i uploaded with code & fmb please let me know. Yes problem could be there i accepted but i wanted to sort out that issue. what kind of problem you are facing please let me know better you upload your .FMB file
Regard
Mughal
[Updated on: Thu, 21 November 2013 14:06] Report message to a moderator
|
|
|
Re: Item Level Validation checking [message #601518 is a reply to message #601510] |
Thu, 21 November 2013 14:57 |
cookiemonster
Messages: 13937 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
when-timer-expired doesn't work for the simple reason that it isn't when-validate-item.
Validation works on the basis that if a when-validate-item fails then the item it belongs to is marked as invalid and the record can't be saved.
If when-validate-item fires a timer and the when-timer-expired fails then the item is still marked as valid and record can still be saved.
For validation to work properly it has to be done in the validate triggers.
|
|
|
|
|
|
Re: Item Level Validation checking [message #601535 is a reply to message #601533] |
Thu, 21 November 2013 23:23 |
|
stalin4d
Messages: 226 Registered: May 2010 Location: Chennai, Tamil Nadu, Indi...
|
Senior Member |
|
|
MK i have checked the TABULAR_DUPLICATE_TIMER with Database table, just changed the EMP block as a database block and checked the validation, its perfectly validation as DUPLICATE RECORD, but when i just copy the first data and put into the second line and save it should not allowed into the database, this is what we need to stop, we must not allow the user to save the data which is duplicated in the columns.
EMPNO ENAME
123 STALIN
123 MUGHAL
i should not allow to save the above data into table,
but without pressing a tab button or Enter button i should just save!
is this possible?
[Updated on: Thu, 21 November 2013 23:25] Report message to a moderator
|
|
|
|
|
|
Re: Item Level Validation checking [message #601557 is a reply to message #601552] |
Fri, 22 November 2013 02:55 |
cookiemonster
Messages: 13937 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
@mughals_king - I don't have a working form builder installation at the moment, so I won't be creating any fmbs. So you're going to have to make do with words and suggestions.
I already stated the correct solution: use post and a select statement in when-validate-item.
A bit more detail:
POST:
If you run an insert statement in sqlplus a row is inserted into the DB but not committed. It's visible to your session only and no other.
If you perform a commit it's made permanent and becomes visible to everyone else, if you rollback it's gone as though it never existed.
Post tells forms to send the required insert or update commands for the block changes to the DB, without a commit. So it does the same as the above. So the records you already entered are in the DB, but only your forms session can see them. If you click on save then become permanent. If you exit the form and say you don't want to save changes they are rolled back.
So if you put a post in when-new-record-instance, wrapped in an if statement to check form or block status to see if there are any outstanding changes to send to the DB, you can then write a simple when-validate-item trigger, which will look something like this:
DECLARE
l_exists VARCHAR2(1);
BEGIN
SELECT null
INTO l_exists
FROM emp
WHERE empno = :block.empno;
message('Emp No already exists');
message('Emp No already exists');
raise form_trigger_failure;
EXCEPTION WHEN no_data_found THEN
--No duplicates, not a problem
NULL;
END;
|
|
|
Re: Item Level Validation checking [message #601559 is a reply to message #601557] |
Fri, 22 November 2013 04:05 |
|
mughals_king
Messages: 392 Registered: January 2012 Location: pakistan
|
Senior Member |
|
|
@cookiemoster's Example code. This is not fulfill the requirement of @stalin4d as you knew and it does not match with @stalin4d requirement your code will check when only data already saved in table does not suits for multirecordblock specially in the case of @stalin4d's demands.
Empno
101---already saved data
your code will check if 101 is already exist in the table then there will be message "already exist" it won't to go for next item please check my above fmb if you are having a form builder 6i or 10g or take this FMB to anywhere for checking purpose your suggestion is alwayz appreciable this fmb which i uploaded this will fulfill the requirement of @stalin4d. now my .FMB won't allow you even copy from first line to 2nd line anyway you have a good knowledge i never denied this i alwayz acknowledge if any body giving a good suggestions and you are my good FORUM friend and alwayz will be your are also helping the peoples who needs your helps and my self is doing the same job.
Thanks & best regards
Mughal
[Updated on: Fri, 22 November 2013 04:08] Report message to a moderator
|
|
|
|
Re: Item Level Validation checking [message #601563 is a reply to message #601559] |
Fri, 22 November 2013 04:15 |
cookiemonster
Messages: 13937 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
mughals_king wrote on Fri, 22 November 2013 10:05@cookiemoster's Example code. This is not fulfill the requirement of @stalin4d as you knew and it does not match with @stalin4d requirement your code will check when only data already saved in table does not suits for multirecordblock specially in the case of @stalin4d's demands.
If you think that then you've completely failed to understand what post does. Re-read my above post, plus the form builder help topics on the subject and if there's something you don't understand about how it works then say what.
mughals_king wrote on Fri, 22 November 2013 10:05
your code will check if 101 is already exist in the table then there will be message "already exist" it won't to go for next item
what's next item got to do with anything?
mughals_king wrote on Fri, 22 November 2013 10:05
please check my above fmb if you are having a form builder 6i or 10g or take this FMB to anywhere for checking purpose your suggestion is alwayz appreciable this fmb which i uploaded this will fulfill the requirement of @stalin4d.
If you want me to check your code then you're going to have to paste the code here in code tags. I can't open fmbs.
|
|
|
|
Re: Item Level Validation checking [message #601569 is a reply to message #601566] |
Fri, 22 November 2013 04:31 |
cookiemonster
Messages: 13937 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
I'm not displeased, just trying to work out where the misunderstandings are.
It's up to you, but if I was you I'd learn what post is and what effect it has, it is incredably useful to addressing situations like the OP's.
When I did work with forms the entire application used post as a matter of course and it worked like a charm. We didn't get duplicates in the DB and the code to avoid them was always very simple.
|
|
|