problem in update text item - oracle

I Have problem in update one of my datablock textitem.
the problem will raise up because I use where condition for my datablock,and after I load the data block, I try to get new value to my text item,but after I put value there is no change...
I dont know how I can change a text item database value when my block has where condition.(the problem is it replace the value with database value.
I use oracle 6i.

When you execute a query in a block, Oracle Forms first clears the block before it populates it with the data retrieved from the database.
If you want to change what is shown in the database item after the query is done, you would normally add code to the POST-QUERY trigger on the block. This trigger fires once for each record retrieved from the database.

Related

i have two table with foreign key and i want to press in foreign key in first table and the second table appear data

I have two blocks. First one is wizard and second is manual in Oracle Forms 11g with relational.
I execute the data into first block and I want to press in foreign key in first table and the second table appear data which is link together by the same number foreign key?
Which trigger should I use please? And which code should I put into trigger?
You can use WHEN-NEW-RECORD-INSTANCE trigger at block level of Block1 with code :
declare
v_skulist table1.skulist%type;
begin
v_skulist := :Block1.f_skulist; --> represents left uppermost field
go_block('Block2');
execute_query;
go_block('Block1'); --> go back to the upper block again, if don't want to come back, then starting from this line upto `end;`(exclusive) should be removed.
while v_skulist != :Block1.f_skulist
loop
next_record;
end loop;
end;
where
Query Data Source Name property is set to table1 for Block1
and
Query Data Source Name property is set to myuser1.table2 with
WHERE Clause set to
skulist = :Block1.skulist for Block2
assuming the second table is on the other user at least
with granted select privilege to your current user as mentioned in your comment.
This way, whatever record touched in the first block, the counterpart foreign key column is brought in the second block.
You should have used the data block wizard which creates all necessary triggers and procedures that take care about it.
If you're going to do it manually, well ... you probably shouldn't do that, there are too many procedures involved.
I suggest you remove detail block and create it from scratch, this time using the wizard. Pay attention to what it asks and - once you're done - the form will automatically do what you want it to.
Then, you can review what objects Forms created for you and - if you really REALLY want to do it manually, try to mimic its steps.

Is it possible to create master-detail relationship in Oracle Forms when both of the blocks are based on procedure?

I have two blocks that are based on procedure and I want to create master-detail relationship between them.
I do this using Data Block Wizzard. It create trigger ON-CHECK-DELETE-MASTER, this trigger assumes that my detail block is based on table (FRL_XXX.TRIGGERS_QUERY, but it is a procedure) and generates cursor:
CURSOR TRIGGERS_cur IS
SELECT 1 FROM FRL_XXX.TRIGGERS_QUERY F
WHERE F.PTG_PST_CODE = :S_TYPES.PST_CODE;
Is there any workaround to solve this problem?
When I try delete this trigger or remove the cursor I get error:
FRM-30409: Delete Record Behavior for the relation is invalid.
I've never done that, but - let me think aloud.
If data block is based on a procedure, it means that procedure returns (as its IN OUT parameter) an array. I'd say that you'll have to
create your own trigger (i.e. replace the one created by the Wizard
note that these triggers usually have a comment "don't modify it!". If you run the Wizard again, it might overwrite your code, so safer approach is to create a procedure which will do the job, and call that procedure from the trigger
declare a local variable (array) and fetch data into it; pass all parameters to the procedure as you did while calling it in order to populate data block
review array's contents and check whether there's any row that satisfies condition PTG_PST_CODE = :S_TYPES.PST_CODE
if so, do what Wizard's trigger does in that case
Basically, I think that you'll have to write your own process which will replace default Forms behavior.
In Procedure based blocks, If you choose the Relation type as Isolated , Oracle form will allow the Master Detail relationship between two blocks because in that case ON-CHECK-DELETE-MASTER trigger won't be there.
You will be able to retrieve the records from detail block as ON-POPULATE-DETAILS trigger will work as-usual.
In my case, only detail block was based on Procedure and it's working fine.
Note : Isolated type of relationship will delete the master records even if child records exist. You need to handle this case separately.
Please share your approach step by step, if you went ahead as per littlefoot

plsql batch blocked by forms screen

I have an Oracle Forms 6i application and there is a plsql batch and both are doing updates to the same table. There are fields that are directly mapped to table columns in a form of the Forms application. Whenever the form accessing the table is open, the plsql batch is blocked. How to create the form so that it does not block any other db sessions. Is there a way to load/create instance of the Form so that it does not hold any lock on the table?
You can try one of 2 possibilities:
1) For block there is property "Locking Mode" and one of it's values is "Delayed". Text from help:
Form Builder locks the row only while it posts the transaction to the database, not while the end user is editing the record. Form Builder prevents the commit action from processing if values of the fields in the block have changed when the user causes a commit action.
So if this value is set, then DB record will be locked only on update time.
2) Create ON-LOCK trigger for this block, with "Execution Hierarchy" property - "Override" (this is default one). And in trigger put code:
NULL;
In this case form's will not lock record and it will be done by DB only when necessary (after UPDATE statement is issued and till COMMIT or ROLLBACK is processed).
Forms locks the record only when a database-bound item is changed either by the user or by a trigger.
You probably have some WHEN-NEW-RECORD-INSTANCE or POST-CHANGE triggers that changes the values of database-bound items.
Before messing with locking modes, you should take a look on what causes forms to request a row lock. I bet you will be surprised!
Try first to disable ALL WHEN & POST trigger at Block & Item level, and examine if the form still locks the batch. After that start by enabling triggers until you spot the one that causes the problem.

Oracle Forms 6i Resolve LOV code

I have a LOV with two columns one is code and the other is description. I know that text items have a property which says validate from list however my code field and description field are display items. We do not want to force the user to click on a button to show the LOV. In the pre-form trigger i am setting a default value in the code field.
I would like to get/resolve the code to its description from the list without having to do a select from the database. Does anyone know of a way to get this done?
I have had also this very same problem. There might not be a solution to retrieve the label column from record group in the runtime.
But you could do this:
Store the record group query somewhere (package header or DB column).
Populate your record group with query in the runtime.
Create DB function which takes query and key value as parameters. The function would then return description of the key value (use dynamic SQL, execute immediate / dbms_sql).
Use the function in the POST-QUERY trigger:
:block.item_description := your_new_function(l_query, :block.item_value);

How to pass new PK to stored proc in Oracle Apex

I have your standard Oracle apex page to create / edit / delete a record.
I now wanted to call a stored proc when a new record is created (only on INSERT, not update/delete), so I created a Process on the page and tied it to the create button.
All is well so far....it calls the stored procedure as expected as verified by the debug messages I put in there. However, I wanted to pass the new PK created as part of the new record to the stored proc. However it is receiving null.
The process I created is set to run "On Submit - after Computations and Validations" which I think is right.
Can someone suggest why I might not be getting the new key? Is it still not available yet at that point in the form processing?
Any help appreciated.
If you are using a standard Apex "form on a table", then you can set the Return Key into Item property of the Process Row of ... process to specify a page item that will get populated with the PK of the inserted row:
You can then reference the item in your procedure call.

Resources