Home » Developer & Programmer » Forms » WNRI
WNRI [message #641585] Tue, 18 August 2015 09:41 Go to next message
palpali
Messages: 138
Registered: December 2014
Location: India
Senior Member
Hallo

I have master-detail block. and when i navigate my cursor in master_block (ID field) then change the records in the detail block, but when I move to the other ID then it prompts message:
(Do you want to save the chagens you have made? Yes/No/Cancel), though i don't have done anything in the detail block.
Can anyone please help me, what could be the reason?

and also, is there any other options to do instead of duplicate_record;
actually I have in my detail block, WNRI, as:


if :system.block_status = 'QUERY' then
   if :system.record_status = 'NEW' then
	duplicate_record;
  	set_block_property('blk1', INSERT_ALLOWED, PROPERTY_TRUE);
	:blk1.text := null;
	set_record_property (:system.trigger_record, :system.trigger_block, status, new_status); 
  end if;
end if;



and when i navigate the records with key-down arrow, it did not go to the new row, when it is in last record.

Help please

regards,
Re: WNRI [message #641586 is a reply to message #641585] Tue, 18 August 2015 09:47 Go to previous messageGo to next message
xebec
Messages: 37
Registered: July 2014
Location: Miraflores
Member
Why don't use; POST - CHANGE O WHEN-VALIDATE-ITEM

try to use these Smile
Re: WNRI [message #641587 is a reply to message #641585] Tue, 18 August 2015 09:48 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Of course you've done something in the detail block - you've run duplicate_record and then set an item to null.
That's data that the form assumes needs to be saved.
This is the downside of defaulting in data as soon as the user enters a new record.
Re: WNRI [message #641588 is a reply to message #641587] Tue, 18 August 2015 09:51 Go to previous messageGo to next message
palpali
Messages: 138
Registered: December 2014
Location: India
Senior Member
Hallo CM,
Thanking you for your prompt reply, but it is not in all ID, which i navigate in control block, just in one ID, prompt this error, though my cursur is in control block.
Re: WNRI [message #641599 is a reply to message #641588] Wed, 19 August 2015 00:57 Go to previous messageGo to next message
palpali
Messages: 138
Registered: December 2014
Location: India
Senior Member
Hallo...

Would it be possible to duplicate records many times when we press function key (like in my case: F7).
Actually, it duplicats the record one time, when i press the F7 key and if i press F7 key again then it did not duplicate records.
I have Key-Down
IF :SYSTEM.LAST_RECORD = 'TRUE' then
	 DUPLICATE_RECORD;
	 SET_BLOCK_PROPERTY('BLK1, INSERT_ALLOWED, PROPERTY_TRUE);
	 :blk1.text1 := NULL;
ELSE 
	NEXT_RECORD;
END IF;

and Key-F7 Trigger, which is

	if :system.record_status = 'NEW' then
		duplicate_record;
  	set_block_property('BLK1', INSERT_ALLOWED, PROPERTY_TRUE);
		:blk1.text1 := null;
	end if;

Any Suggestion please?

regards,
Re: WNRI [message #641603 is a reply to message #641599] Wed, 19 August 2015 01:36 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
If F7 - pressed for the second time - doesn't do anything, then IF condition you used in a trigger isn't met.
Re: WNRI [message #641605 is a reply to message #641603] Wed, 19 August 2015 01:42 Go to previous messageGo to next message
palpali
Messages: 138
Registered: December 2014
Location: India
Senior Member
Hallo LF, thanking you for your reply.
Could you please, let me clear, how can i do this?
I am trying to make duplicate records, when i press 2nd time F7 key. It works when i press first time F7 and give the value for text1 field then i press F7 key again, then it did not duplicate the records, but just insert a blank row.
Re: WNRI [message #641607 is a reply to message #641605] Wed, 19 August 2015 01:50 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
DUPLICATE_RECORD duplicates previous record. Is it, by any chance, empty (none of the items contains values so nothing is, actually, duplicated)?
Re: WNRI [message #641609 is a reply to message #641607] Wed, 19 August 2015 01:59 Go to previous messageGo to next message
palpali
Messages: 138
Registered: December 2014
Location: India
Senior Member

in my Detail block there are already some records it showed and when i press F7 in one of them records then it duplicates of the above records in the new row below it, except text1 (which user Need to Input), and without saving first enterd record, when i press F7 again then it inserts just a blank row and did not duplicate, even the above records have data in it.
That means, we Need to save first, the first entered record then F7? would not it be possible to duplicate previous record with F7 without saving previous record?

thanking you again LF.

Regards.
Re: WNRI [message #641611 is a reply to message #641609] Wed, 19 August 2015 02:43 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
As far as I remember, record doesn't have to be saved in order to be duplicated. Unfortunately, I can't test it now.

What happens if you modify current trigger's code to (substituted SET_BLOCK_PROPERTY and DUPLICATE_RECORD)
if :system.record_status = 'NEW' then
   set_block_property('BLK1', INSERT_ALLOWED, PROPERTY_TRUE);
   duplicate_record;
   :blk1.text1 := null;
end if;
or even (CREATE_RECORD first, then DUPLICATE_RECORD)
if :system.record_status = 'NEW' then
   set_block_property('BLK1', INSERT_ALLOWED, PROPERTY_TRUE);
   create_record;
   duplicate_record;
   :blk1.text1 := null;
end if;


Form's menu (at the top of the screen) contains "Record" menu - click it and choose "Duplicate" (instead of using F7 key). What happens?
Re: WNRI [message #641612 is a reply to message #641611] Wed, 19 August 2015 03:16 Go to previous messageGo to next message
palpali
Messages: 138
Registered: December 2014
Location: India
Senior Member
Hallo LF,

Well,. I changed my code as per your Suggestion.

But the Problem is same. sry
I mean, it works fine when i press F7 first time, and Input the required field but when i press F7 2nd time then, it just insert blank row, below the current record.

I pressed first F7 then, Record --> Duplicate, it duplicates the above record, and again when i press F7 then it insert the blank row again but, when i go through Record --> Duoplicate then i duplicates all the record agin as above it.

The same function, I am trying to do with F7 key.
Any Suggestion please.
Regards
Re: WNRI [message #641613 is a reply to message #641612] Wed, 19 August 2015 03:25 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
What is F7 mapped to (which function)? Check it in key mappings Help.

Suppose that it is mapped to "insert record". That would be equal to "create record", which is covered by the KEY-CREREC trigger. So, what happens if you drop KEY-F7 trigger and - instead - put that code into the KEY-CREREC trigger?

(If F7 is mapped to something different, say what it is. Then we'll find out which KEY-... trigger does that job).
Re: WNRI [message #641614 is a reply to message #641613] Wed, 19 August 2015 03:39 Go to previous messageGo to next message
palpali
Messages: 138
Registered: December 2014
Location: India
Senior Member
F7 key is mapped for insert record.
and now I did the same code in key-crerec Trigger. But the Problem now is, i can not insert new row in the block, neither with F7 key nor with add record (+ Icon above) work.
any Suggestion ?
thanking you agian.

Re: WNRI [message #641615 is a reply to message #641614] Wed, 19 August 2015 03:45 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
The simplest form of KEY-CREREC trigger is
create_record;


The simplest modification you want to make is
create_record;
duplicate_record;
What does it do?
Re: WNRI [message #641616 is a reply to message #641615] Wed, 19 August 2015 04:23 Go to previous messageGo to next message
palpali
Messages: 138
Registered: December 2014
Location: India
Senior Member
Hallo LF

Thank you very very much for your great support and great help. It works now, what i was trying to do for. Smile

well, i have dropped my KEY-F7 trigger and instead of that created KEY-CREREC trigger as:

create_record;
duplicate_record;
:blk1.text1 := null;


But, now i am having another problem, in my detail block, user are allowed to input just the one field, i.e. text1, and sometimes the value is very long text, and i would like to have that user can just click and select the above value of text1 field and paste into new row and just need to change some.
would it be possible to do so?
i do have, WNRI trigger in my detail block as:
if :system.block_status = 'QUERY' then
	if :system.record_status = 'NEW' then
		set_block_property('BLK1', INSERT_ALLOWED, PROPERTY_TRUE);
		create_record;
		duplicate_record;
		:blk1.text1 := null;
		set_record_property (:system.trigger_record, :system.trigger_block, status, new_status); 
  end if;
end if;


but it did not do that. Any suggestion please?

Regards.
Re: WNRI [message #641617 is a reply to message #641616] Wed, 19 August 2015 04:35 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Are you saying copy and paste didn't work or do you have some code you're not showing us to automatically copy the value?
Re: WNRI [message #641618 is a reply to message #641616] Wed, 19 August 2015 04:39 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Quote:

i would like to have that user can just click and select the above value of text1 field and paste into new row

What's the purpose of setting TEXT1 item to NULL after the previous record has been duplicated, then?
Quote:

WNRI trigger ... did not do that

Well, how would it? If anything, it does just the opposite - clears the TEXT1 item.

Maybe you are over-complicating things using all that code in all those triggers. Even if you did absolutely nothing and left the form intact (after Data Block Wizard created it), you would have been able to accomplish everything you are looking for: Forms would let you duplicate previous record (as you already tried it from form's "Record - Duplicate" menu). It would also duplicate TEXT1 item's contents and let you modify it (so that you wouldn't have to type that long text again) or delete it and type something new.

If I were you, I'd think it over and most probably discard all those triggers, SET_BLOCK_PROPERTY, IFs etc. which only caused mess and produced just a little bit of help.
Re: WNRI [message #641621 is a reply to message #641618] Wed, 19 August 2015 05:54 Go to previous messageGo to next message
palpali
Messages: 138
Registered: December 2014
Location: India
Senior Member
Hallo CM, LF,
Sry, no i don't have any other code to copy the value automatically, except that duplicate_record do that for me. but,


I think i will consider your @LF Suggestion, because, before, i thought that to set that field text1 null, but now i am considering your Suggestion, not Setting that field to null, instead of, it duplicates the all record and the user should Change the text1 field as per Need. Besides, I have also WVI Trigger at text1 field to check if the entered value same is.

Anyway, thanking you all for your great Suggestion and Help.
Regards,
Re: WNRI [message #641666 is a reply to message #641621] Thu, 20 August 2015 03:04 Go to previous messageGo to next message
palpali
Messages: 138
Registered: December 2014
Location: India
Senior Member
Hallo

As I have done as per my previous post, that duplicating all the records as above, but getting while inserting data.
I got the error:
"FRM-40735: ON-INSERT Trigger raised unhandled exception ORA-00001"

On-Insert Trigger :
insert into table1 (id, pid, text) values (120, 10, 'product');


and also i do have WVI Trigger at text field, which checks that if there are same product Name in the block is, and throw when saving the records. But, in my case, id did not Show any message or it did not throw WVI Trigger but just give the above error.
WNI trigger:
declare
 rec number
begin
 select Count(*) into rec from table 1
   where id = :blk1.id
    and pid = :blk1.pid
    and text= :blk1.text;
if rec > 0 then
 message('The product is same, please enter new Name !');
 raise form_failure_trigger;
end if;
end;

Any suggestion please?

Regards,
Re: WNRI [message #641668 is a reply to message #641666] Thu, 20 August 2015 03:06 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Do you really have hard-coded values in the insert statement in on-insert?
Re: WNRI [message #641669 is a reply to message #641668] Thu, 20 August 2015 03:10 Go to previous messageGo to next message
palpali
Messages: 138
Registered: December 2014
Location: India
Senior Member
No, sry it was my fehler,
actually it is like:

insert into table1 (id, pid, text) values (:ctl_blk.id, :blk1.pid, :blk1.text);
Re: WNRI [message #641670 is a reply to message #641669] Thu, 20 August 2015 03:13 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
fehler?

1) Why have you got :ctl_blk.id in there rather than :blk1.id?
2) You should probably check that :ctl_blk.id and :blk1.id actually match
3) Why have an on-insert at all?
4) I'd check that the WNVI is actually firing - stick a message in the start of it.
Re: WNRI [message #641671 is a reply to message #641670] Thu, 20 August 2015 03:16 Go to previous messageGo to next message
palpali
Messages: 138
Registered: December 2014
Location: India
Senior Member
Thank you CM,

actually, it master-Detail block and id Comes from control block and it displays the respective records that belongs to that id.
And i am using FROM Clause Query in my blk1 thats why i have used ON-Insert Trigger.

help please Smile
Re: WNRI [message #641678 is a reply to message #641671] Thu, 20 August 2015 03:42 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
You should still have id in blk1 and it should have the same value as the control block. So there's no good reason not to have :blk1.id in the on-insert.
You still need to check 2 and 4.
Re: WNRI [message #641682 is a reply to message #641678] Thu, 20 August 2015 03:56 Go to previous messageGo to next message
palpali
Messages: 138
Registered: December 2014
Location: India
Senior Member
I mean to say is, yes, I do have id in blk1 too, but i am just displaying pid and text in blk1 and id in control_blk, and yes the id have the same value as in ctrl_blk.id.

Well, in my case, in Detail block, when i press key F7, it will insert a new row and duplicate the values as above it and user Need to just Change the text field, it should not be the same, thats why i use WVI Trigger, but it did not fire, and just give this error.
that means, when i insert new row and give new product Name then, it should update table1 with These 3 values, the id and pid will be same and product Name will be different.



Re: WNRI [message #641686 is a reply to message #641682] Thu, 20 August 2015 04:26 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Have you specifically checked that the WVI is not firing or are you just assuming it's not because you don't get the Product is the same message?
Re: WNRI [message #641688 is a reply to message #641686] Thu, 20 August 2015 04:38 Go to previous messageGo to next message
palpali
Messages: 138
Registered: December 2014
Location: India
Senior Member
Ya, I did check it, but it did not fire this Trigger thats why i did not see the message.
actually, it should fire, after entering new text field and clicking on save Icon, but when i click on save Icon, i see just error:
"FRM-40508: Orace error unable to insert record" and when i Display error : 'ORA-00001: unique constraint violated.....'
I am really confused, where my failure is?



Re: WNRI [message #641689 is a reply to message #641688] Thu, 20 August 2015 04:44 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Not entirely sure. Whether WVI fires is basically down to the item_is_valid property. If it's false then WVI should fire before you can save.
So put messages in to display that property of the text item before and after the call to duplicate record.
Re: WNRI /WVR [message #641694 is a reply to message #641689] Thu, 20 August 2015 07:08 Go to previous messageGo to next message
palpali
Messages: 138
Registered: December 2014
Location: India
Senior Member
I changed the WVI into WVR Trigger, but it did not fire the Trigger when i click save Icon.
Instead of it Display the same error.

actually, when i click save Icon then, it should insert id, pid, text in the respective table and These all 3 fields are PK.
I dont know how to overcome this Problem, please help

thanking you all
Re: WNRI /WVR [message #641697 is a reply to message #641694] Thu, 20 August 2015 07:27 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
If you want help do what I asked in the previous post and tell us the results.
Re: WNRI /WVR [message #641698 is a reply to message #641697] Thu, 20 August 2015 07:33 Go to previous messageGo to next message
palpali
Messages: 138
Registered: December 2014
Location: India
Senior Member
I did try to put the normal message which it gives me back, but i dont know how can i put the message to get the item_is_valid property :/
can you please make me clear Mr CM Smile ?

Re: WNRI /WVR [message #641699 is a reply to message #641698] Thu, 20 August 2015 07:54 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
use the get_item_property builtin
Re: WNRI /WVR [message #641700 is a reply to message #641699] Thu, 20 August 2015 08:24 Go to previous messageGo to next message
palpali
Messages: 138
Registered: December 2014
Location: India
Senior Member
Hallo CM,

Thank you very much for your Suggestion.

I put the following code in key-crerec Trigger:
begin
create_record;
 if get_item_property(:System.cursor_item, item_is_valid) = 'FALSE' then
    message('Input item is invalid');
    raise form_trigger_failure;
 end if;
duplicate_record;
  if get_item_property(:System.cursor_item, item_is_valid) = 'FALSE' then
    message('Input item is invalid');
    raise form_trigger_failure;
 end if;
go_item('blk1.text');

end;


so, now it throw the message when i insert a new row (F7), and then when i click to save record it gives me still the same error
Quote:
"FRM-40508: ORACLE error unable to insert record" and when i display error then:
SQL statement in error: INSERT into table1 (id, pid, text) values (:1, :2, :3)

Error: ORA-00001: unique constraint(db.blk1_pk) violated

Any suggestion please?

thankx
Re: WNRI /WVR [message #641701 is a reply to message #641700] Thu, 20 August 2015 08:30 Go to previous messageGo to next message
palpali
Messages: 138
Registered: December 2014
Location: India
Senior Member
Sry, I forgot to mention, when insert a new row it inserts new row with duplicate records and throws the message too, when i put the code before duplicate_record and after create_record.
Re: WNRI /WVR [message #641702 is a reply to message #641700] Thu, 20 August 2015 08:34 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
palpali wrote on Thu, 20 August 2015 14:24
Any suggestion please?


Yes. Tell us what the value of item_is_valid actually is before and after the call to duplicate record like I asked.

We're in the process of determining the cause of the issue here, which has to be done before we can fix it, so there's no point repeatedly telling us you're getting ORA-00001.
Re: WNRI /WVR [message #641703 is a reply to message #641702] Thu, 20 August 2015 08:36 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Also having the same message text before and after is pointless. You need to be able to tell from the message whether it's displaying the property before or after duplicate record.
Re: WNRI /WVR [message #641704 is a reply to message #641703] Thu, 20 August 2015 08:38 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Also specify the actual item you're interested in in the call to get_item_property. :System.cursor_item should be correct but why take the risk that it isn't.
Re: WNRI /WVR [message #641705 is a reply to message #641704] Thu, 20 August 2015 08:39 Go to previous messageGo to next message
palpali
Messages: 138
Registered: December 2014
Location: India
Senior Member
Yes, I did try both with :System.cursor_item and :blk1.text, but still the Trigger doesnot fire:/
Re: WNRI /WVR [message #641708 is a reply to message #641702] Thu, 20 August 2015 08:48 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
As I said previously:
cookiemonster wrote on Thu, 20 August 2015 14:34
We're in the process of determining the cause of the issue here, which has to be done before we can fix it


I didn't expect the WVI to fire. We currently have no idea why it isn't firing. Adding some messages to get the item status isn't going to magically fix it. Hopefully though it'll give us enough information to determine the cause of the problem.
But that's only going to happen if you actually give us the information we ask for

Seriously - we're doing basic debugging here, which is a basic programming skill which you need to wrap your head around fast.
Re: WNRI /WVR [message #641722 is a reply to message #641708] Fri, 21 August 2015 00:48 Go to previous messageGo to previous message
palpali
Messages: 138
Registered: December 2014
Location: India
Senior Member
Hallo CM,

Well, i did Change some code in my key-crerec Trigger after your Feedback to check the return value of item_is_vlid property,

declare
  var  varchar2(10);
begin
 create_record;
 var := get_item_property('blk1.text1', item_is_valid);
 message ('Value is ' || var);
 duplicate_record;
 var := get_item_property('blk1.text1', item_is_valid);
 message ('Value is ' || var);
 go_item('blk1.text1');
end;


so, after doing this,
when i press the F7 key then it inserts the new rows with duplicating values from above and give message, value is FALSE, (BEFORE DUPLICATE_RECORD)
and AFTER DUPLICATE_RECORD : it gives message, value is TRUE.

But did not fire the trigger.

Any feedback?

Thanking you alot.

Regards,


Previous Topic: I want to do following (how to create a form like this)
Next Topic: commit_form is not working in Called Form
Goto Forum:
  


Current Time: Fri Apr 19 20:51:15 CDT 2024