How to pass new PK to stored proc in Oracle Apex - oracle

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.

Related

How to Make Form w/ No underlying DB Table - APEX 19.2

Very noob question, but how can I create a form in APEX that is not based on a database table?
For example, I am looking to create a "Change Password" form that consists of 3 fields:
USERNAME (display only, value populated with &APP_USER. from URL)
NEW_PSWD
CONFIRM_PSWD
None of these fields will be saved to the database, so not sure how to handle the SOURCE for the underlying form. My first thought was to just use a SQL statement like this:
SELECT '' as username,
'' as new_pswd,
'' as confirm_pswd
FROM DUAL;
Is there a better / more APEX way to handle this?
UPDATE: I understand how to set up a process to handle the logic, but more asking what should I select for the SOURCE? It "yells" at me if I select a TYPE (TABLE/VIEW, SQL QUERY, PLSQL FUNCTION BODY...) and do not put something in there.
Thanks in advance.
Don't use "Form" page type. Pick "Blank" instead.
Then
create a region on it
put any number of items (3 in your case)
create a button
create a process which will fire when you press that button
it should do "smart" things in the database - insert user into a table, change their password, whatever you plan to do

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.

Passing parameters to stored procedure and then using it as data source in SSRS report

I want to do the following:
The user sets 3 parameters in MVC3 view: worker name, from date, to date.
This parameters are passed to a stored procedure, which return a table.
I want to use this table as data source for SSRS report and view the report in .aspx page.
Can you tell me how to do that?
I've already created the view and the procedure, but I don't know how to do the rest.
In your Report Builder/BIDS Environment create a new report.
Create a datasource which points to your database.
Create a new dataset which uses this datasource. In your dataset set the command type to a stored procedure and select your procedure from the drop down list. You can then add parameters to your stored procedure, i.e.: "#FromDate", "#ToDate".
You can also configure the report to prompt the user for these parameters by right clicking on the report and go to properties and adding parameters this way.
Then in ASP.NET you could direct the user to "http://yoursite.com/Reports/Report.aspx?FromDate=....&ToDate=....&WorkerName=Ivan"
I have included a few resources which may also help you achieve this.
Resources:
http://www.codeproject.com/Articles/20540/Using-StoredProcs-with-Parameters-in-SQL-Reporting
http://msdn.microsoft.com/en-us/magazine/cc188691.aspx

problem in update text item

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.

Resources