How to solve FRM:40105- Unabel to resolve reference to item problem? - oracle

I am new in Oracle forms and reports. I am facing this error.
I have created Employees data block and displaying it to the canvas. I triggered my module as new form instance with execute_query. Then took one display text item and set it's database as no and set this name as search_box and another one is push button, I set it's name as search.
In search block button I have triggered this When button pressed and wrote this code.
begin
set_block_property('EMPLOYEES',default_where,'EMPLOYEE_ID='||':search.search_box');
go_block('EMPLOYEES');
execute_query;
set_block_property('EMPLOYEES',default_where,'');
end;
My Employee_Id is one of my block item but still i can't understand where should I fix to solve this problem.
Please help!

Should be like this - based on Forms Help which says:
Set_Block_Property('emp', ONETIME_WHERE, 'deptno <= :dept.deptno');
Also, you'd rather use onetime_where.
Therefore:
begin
set_block_property('EMPLOYEES', onetime_where, 'EMPLOYEE_ID = :search.search_box');
go_block('EMPLOYEES');
execute_query;
end;
Saying that you can't make it work ... well, I can. Here's a demo.

Related

How to highlight specific record using SET_BLOCK_PROPERTY

I have form in which when open form then all records shown on the block. User enter number on search option and specific record shown on the block. Now I want when search then all records remain on the block and highlight searched data.
BEGIN
SET_BLOCK_PROPERTY('block',default_where,'column= '||:block2.column);
GO_BLOCK ('block');
EXECUTE_QUERY;
END;
How to achieve this target in oracle forms 11g
Thanks
Please refer below link . This will solve your problem.
You need to create a visual attribute and need to assign at item_instance_property level.
http://www.orafaq.com/forum/t/171952/
Firstly, set Current Record Visual Attribute Group property of block to a spesific Visual Attribute which you'd like to highlight to the visited row of the block.
Then, provided the records are already queried and appears on the screen, a text field( :block2.column ) with a
WHEN-BUTTON-PRESSED trigger with the below code might be used to search among those records by entering the desired value and pressing enter :
go_block('block');
first_record;
while :block2.column != :block.column
loop
next_record;
end loop;

Oracle Forms Clear Record in When-Validate-Record Trigger

When user begin filling the record then they click other record before committing i want to clear the last record like it never filled.
So i create when-validate-record in data block as below:
begin
if :MYBLOCK.SEQ is null then --if there is no seq yet, means its not committed
Clear_Record;
end if;
end;
But clear_record causes error that says Invalid limited CLEAR_RECORD procedure and usage seems correct to me. And i also tried Clear_Record(no_validate) but it also doesn't work. I saw some usage of clear_record and i can't get why it doesn't work. I could use some help.
Thanks in advance.
Restricted procedures (not limited, as you put it) can't be called from all triggers; WHEN-VALIDATE-RECORD being one of them.
One option you might choose is to interact with the user and tell them what to do. Still the WHEN-VALIDATE-RECORD trigger:
if :MYBLOCK.SEQ is null then -- if there is no seq yet, means its not committed
message('Save the record or - if you do not need it - delete it');
raise form_trigger_failure;
end if;
Benefit of such an approach is that user (not the procedure in background) decides what to do. I wouldn't want to enter 20 fields on the screen, accidentally click one of previous records and lose everything I've done so far.

How to call a set focus on a form creation

I'm creating a small application with some 'Search' hotkeys, F1 to F4 to search into different tables of a database, so I've created a TPageControl to hold the search fields and also display the results, so I have 1 PageControl and 4 tab sheets, but I'm trying to put one if statement to set the focus on the proper search field and I'm calling it on the OnShow event of the TPageControl, but I'm getting a error message: Form:TForm cannot focus
If I didnt got it all wrong, it's because the text field cannot be found, considering I'm showing the page before the application can create the elements inside of this page, so, how can I edit this code or where can I use it to make it works, just remembering that I need to call this procedures with the hotkeys later on.
The procedure I'm using to set the focus is just a simple IF with 4 conditions in my real case:
procedure TForm.searchFocus; begin
if pgcSearches.TabIndex=0 then begin
editFieldNames.SetFocus;
end
else if pgcSearches.TabIndex=1 then begin
editFieldAdresses.SetFocus
end;
end;
A more 'explicit' help from another forum:
procedure TfrmMain.pcSearchesChange;
begin
case pcSearches.TabIndex of
0: ActiveControl:=edtSearchSongs;
1: ActiveControl:=edtSearchBibles;
2: ActiveControl:=edtSearchWarning;
end;
if Visible then
ActiveControl.SetFocus;
end;

Oracle APEX Selection list

I have a form on a table with some values (text fields) and a select list. The select list is declared in shared components and shows me values from another table. Also I have some process (after submit) to modify and create new table entry. Everything works fine without propagating values from select list. There are no errors from the process. It looks like the process didn't get a value for :P22_WORKER_LIST from the selection list. It should work when I push the create or save buttons but nothing happened. Every instruction in BEGIN END block runs great without this one.
Process:
BEGIN
<some instructions>
UPDATE "WORKER" SET ACCOUNT_LOGIN = :P22_LOGIN
WHERE SURNAME = :P22_WORKER_LIST;
END;
Thank you for suggestion with the session state. After submiting page it turned out that the value for my :P22_WORKER_LIST is a WORKER_ID instead a SURNAME.
BEGIN
<some instructions>
UPDATE "WORKER" SET ACCOUNT_LOGIN = :P22_LOGIN
WHERE WORKER_ID = :P22_WORKER_LIST;
END;

FRM-40401 no changes to save after WHEN-CREATE-RECORD trigger

I googled this but, unfortunately, could not find any solution.
I have a simple form (Oracle Forms Builder 10g) with a single block. The form is written in Oracle EBS style, that is, the block is based on a view that fetches the base table fields together with the rowid and DML events (on-insert, on-update etc. triggers) are handled by a table handler package.
The functionality I wanted to add was the following: when a user creates a new record, the form automatically suggests values for all fields in the form. So, I created a WHEN-CREATE-RECORD trigger that calculates the field values and assigns them. All, except the primary key wich is based on a Sequence and is handled by the package.
Everything runs OK when I create the new record but when I attempt to save it, all I get is a FRM-40401 "no changes to save" error and nothing happens.
I tried to trace the error and it seems like the form considers the record as NEW with no changes on it. This happens even if I try to explicitly alter the record status to INSERT.
I already tried to change the default behaviour to STANDARD.COMMIT (created an ON-COMMIT trigger for that) but this did not dfix anything.
For the record, I tried to make the form table-based, getting rid of table handlers and leaving all DML to Forms. I still get FRM-40401.
I can't understand what is going wrong, any ideas please?
The record status is reset to NEW after the when-create-record trigger completes. This normally makes sense, since you are effectively setting the default values for items, but the user hasn't actually entered any data yet.
You need something to mark the record for insert after the trigger has finished - normally the user would do this when they enter some data into the record. If you want the user to be able to save the record without changing anything in it, you could perhaps add something to the save button to do a no-change assignment, e.g.
:MYBLOCK.ANYITEM := :MYBLOCK.ANYITEM;
This would cause the record to be marked for insert.
OK, for the time being I used the classic TIMER workaround and everything works as it should:
PACKAGE body form_timers IS
PROCEDURE CREATE_NEW_RECORD;
procedure do_create(name varchar2) is
timer_id TIMER;
Begin
timer_id := CREATE_TIMER(name,1,NO_REPEAT);
End;
procedure expired is
expired_timer CHAR(20);
BEGIN
expired_timer:=GET_APPLICATION_PROPERTY(TIMER_NAME);
IF expired_timer='CREATE_NEW_RECORD' THEN
CREATE_NEW_RECORD;
-- ELSIF expired_timer='T2' THEN
-- /* handle timer T2 */ NULL;
ELSE
NULL;
END IF;
END;
PROCEDURE CREATE_NEW_RECORD IS
/* create record logic goes here */
END;
END;
... but still, I'd like to know why this behaviour occurs.

Resources