Developer2000 OPEN_FORM built-in - oracle

I am a newbie in Developer2000.
I have an Oracle pl/sql procedure (say, proc_submit_request) that fetches thousands of requests and submits them to dbms_job scheduler. The calling of dbms_job is
coded inside a loop for each request fetched.
Currently, i have a button (say, SUBMIT button) in oracle forms screen clicking which calls proc_submit_request.
The problem here is... the control does not return to my screen untill ALL of the requests fetched are submitted to the dbms_job (this takes hours to complete)
The screen grays out and just the hour-glass appears untill the completion of the procedure proc_submit_request.
proc_submit_appears returns a message to screen telling "XXXX requests submitted".
My requirement now is, once the user clicks the SUBMIT button, the screen should no longer gray out. The user should be able to navigate to other screens and not just struck with the submit screen untill the called procedure is completed.
I suggested running listeners (shell scripts and perl stuff) that can listen for any messages in pipe and run requests as back-ground process.
But the user is asking me to fix the issue in the application rather running listeners.
I've heard a little of OPEN_FORM built-in.
Suppose, I have two forms namely Form-1 and Form-2. Form-1 calls Form-2 using OPEN_FORM.
Now are the following things possible using OPEN_FORM?
On calling open_form('Form-2',OTHER-ARGUMENTS...), control must be in Form-1 (i.e. USer should not know that another form is getting opened) and Form-2 should call proc_submit_request.
User must be able to navigate to other screens in the application. But Form-2 must still be running until proc_submit_procedure is completed.
What happens if the user closes (exits) Form-1 ? Will Form-2 be still running?
Please provide me answers or suggest a good solution.

Good thought on the Form-1, Form-2 scenario - I'm not sure if that would work or not. But here is a much easier way without having to fumble around with coordinating forms being hidden and running stuff, and coming to the forefront when the function actually returns...etc, etc.
Rewrite your function that runs the database jobs to run as an AUTONOMOUS_TRANSACTION. Have a look at the compiler directive PRAGMA AUTONOMOUS_TRANSACTION for more details on that. You must use this within a database function/package/procedure - it is not valid with Forms (at least forms 10, not sure about 11).
You can then store the jobs result somewhere from your function (package variable, table, etc) and then use the built-in called CREATE_TIMER in conjunction with the form level trigger WHEN-TIMER-EXPIRED to go and check your storage location every 10 seconds or so - you can then display a message to the user about the jobs, and kill the timer using DELETE_TIMER.

You could create a single DBMS_JOB to call proc_submit_request. That way your form will only have to make one call; and the creation of all the other jobs will be done in a separate session.

Related

How to find where an Alert is initiated in Oracle Forms 6i?

in a Oracle 6i form, I have an alert defined, and a database block. Because it's a database block, when some data is entered, but not saved, when you try to exit this form, this alert pops up (asking 'Do you want to save this data?'). However, all this happens BY DEFAULT, I don't see any triggers/program units where this alert is called... Also, the text for this alert is also assigned dynamically, and I can't find any triggers/programs where it is being done... What am I missing? Thank you.
I'm not sure you can find it anywhere in Forms Builder; that behavior is built-in, Oracle Forms raises the alert when it finds out that one (or more) database items have been changed, and those changes not saved at the moment you're trying to e.g. exit the form, enter query mode, navigate to another record etc.
In order to prevent changes to be lost (end users would hate it, spending minutes to enter data which is gone without notice), Forms informs you about it and lets you choose whether you want to keep (save) those changes or not.
Therefore, just say "Thank you" every time you see it because those nice people at Oracle did it so that us, developers, wouldn't have to in each and every form we create.

PL/SQL triggers won't run

I have an Oracle Forms 11 g application running on Weblogic server. The default form/login page has a few PL/SQL triggers that simply will not fire. The rest of the configuration seems successful.
Can anyone give me pointers as to where to start looking?? Thanks in advance.
As their name suggests, triggers fire when something triggers them. For example,
a WHEN-BUTTON-PRESSED trigger is triggered by pushing a button
a POST-QUERY trigger fires after executing a query in a data block
a WHEN-NEW-FORM-INSTANCE trigger fires when the form is being run
and so on.
Therefore, make sure that triggers really are triggered. The fact that you have them doesn't mean that they'll run, just because.
In order to find that out, you have two options:
run a form in debug mode:
in one of the triggers (for example in a WHEN-NEW-FORM-INSTANCE) set a breakpoint by right clicking its left margin (you'll see what to do next)
then run the form; that green toolbar icon you use to run it shouldn't be used, but the one next to it, with something reddish on it
as soon as execution gets to the breakpoint, it'll stop, you'll be transferred to Forms Builder, a debug console will open and will let you navigate through the rest of the code step-by-step
do that, and you'll know what's going on, i.e. whether those triggers are called and what they do
as of you being suspicious: did you, by any chance, put some exception handlers that use WHEN OTHERS THEN NULL or something similar? If so, get rid of them. Even if an exception is raised (such as NO_DATA_FOUND or TOO_MANY_ROWS, just to mention two of the most popular and frequent ones), THEN NULL will silently mask it
another one is to put MESSAGE calls into the triggers, such as
begin
message('running WBP trigger: step 1');
... the rest of your code goes here
end;
Doing so, message-after-message will raise an "alert" on the screen (as you'll have to click OK that you saw what it said), and you'll quickly see which triggers fired and which did not. Then investigate it further - debugging described previously will help.
If none of that helps, you'll have to describe what's going on, but this time providing some more info. What you wrote isn't very descriptive. Anyway, best of luck.

How to test two interacting browsers (e.g. chat app)

I want to test the interaction between two users, communicating through a remote server, using CasperJS. My app is not a chat app, but that is an easy way to illustrate what I want to do.
So I'll login browser window A, then login to browser window B, then back in browser window A I'd input the chat message, call click() on the send button, and then back in browser B I'd wait for the message to appear. Then write a message, and go back to browser A to make sure it arrives.
I found this discussion on parallel browsing, which turns out to be serial. Serial is fine for me, but it appears doing more than one action in each browser is going to get very messy. It'd be something like this:
A.start(...);
A.then(...);
A.then(...);
B.start(...);
B.when(...);
A.run(function(){
B.run(function(){
A.start(...);
A.then(...);
A.run(function(){
B.start(...);
B.run(function(){
//and so on
});
});
});
});
(I've not actually tested that will work; I started writing it that way and thought there must be a better way?!)
and let each of them run asynchronously from the commandline
+1
I would do it that way :
Two scripts :
script A with A login
script B with B login
Then script A first step (after login) : writing in the chat.
Script B first step : waiting for A text then sending its answer.
Script A second step : waiting for B answer etc...
You launch these two scripts in parallel using node (child process) and they will interact with the wait() statements.
There is just one delicate point : wait for the two pages to be rendered -or to login- at the same time (approximatively), because if one of them freeze a little, you could get the timeouterror... So maybe increase the waitTimeout; to be safer. (though for me the 5sec default timeout should be sufficient).
You could also use an external file to 'synchronize' it, but I don't see how it could be helpful, because you would have to wait for the data to be updated in this file anyway.
So this solution it's asynchronous, but it works.
This will not work because of the step/scheduling nature of casperjs. See also Running multiple instances of casperjs.
In your code example the B instance is only started when A is finished, because the execution begins with the call to run.
The easiest would be to write two separate casperjs scripts (or one script, but invoked with different data for the two sides) and let each of them run asynchronously from the commandline. On linux I would use nohup ... & for this.
As for the specific test steps. I think it is easier to let your application handle the events that are needed for the synchronization of the two casperjs clients. If it is a chat app and you want to let the two caspers chat, you would write a dialog beforehand, which includes at what step a client says what.
You can then synchronize the clients using waitForText:
A sends some fixed/known text while B waits for this fixed text to appear
B receives this fixed text while A is in the next step and waits for B's response (also known text)
B sends the next fixed text and A is still waiting
Of course you would need to play around with wait timeouts.

Exit_form doesn't work as expected

I am using exit_form to close a form. But, when I call that form from another form and then press the exit key, it returns to the form which called it.
Example:
if form_a calls form_b. In form_b trigger exit_forms triggers, it will call form_b.
Well, I need to exit all opened form.
thanks
You need to use then new_form statement instead of open_form or call_form:
new_form exits the current form and enters the indicated form. The calling form is terminated as the parent form. If the calling form had been called by a higher form, Oracle Forms keeps the higher call active and treats it as a call to the new form. Oracle Forms releases memory (such as database cursors) that the terminated form was using.Oracle Forms runs the new form with the same Run form options as the parent form. If the parent form was a called form, Oracle Forms runs the new form with the same options as the parent form.NEW_FORM can be instructed to continue the database transaction, rollback to the current save point or perform a full rollback. It can also be instructed to open the new form in query only mode and to share or not share library data.
according to oracle forms help
call_form:
Runs an indicated form while keeping the parent form active. Oracle Forms runs the called form with the same Runform preferences as the parent form. When the called form is exited Oracle Forms processing resumes in the calling form at the point from which you initiated the call to CALL_FORM.
open_form:
Opens the indicated form. Use OPEN_FORM to create multiple-form applications, that is, applications that open more than one form at the same time.
so I suggested to try use open_form with no_active parameter then call exit_form to exit form (A), after form(A) closed the focus will gained by opened form(B).
so you finish working on form(B) and close it, it will exit all your forms.
to simplify :
on form_A on button trigger when_pressed_button (which responsible to open form_B) you can try
OPEN_FORM('form_b', NO_ACTIVATE, NO_SESSION, 'my_parameters');
exit_form(no_validate);

How to handle multiple asynch downloads

I recently moved my background synch downloads to a view controller and need some advice on how to best handle them asynch. I have written all the code to show a progressview as the download occurs but as you might have guessed it's not that simple. Here's how it works.
user sees a tableview with two entires one for each database. they can press a button to download the database and when the download starts that fires off the asynch URL connection,etc. This works to a certain extent however it's not that simple.
here's what i want it to do.
download the main update URL (works ok)
then download a secondary URL.
then apply the first URL content to the sqlite store (code written for that)
then apply the 2nd URL content to the sqlite store (code written for that)
(All the while showing progress to the user)
when the downloads were synch it was easy as i just waited for them to finish in order to fire the next activity off but when using the asynch method i'm struggling with how to get them to wait. Step 3 depends upon step 1 finishing and step 4 depends on step 2 finishing and overall success relies on all finishing. step 4 needs to wait for step 3 to finish otherwise the database locks will cause a clash.
the second complication is that if the user presses the second button while the first is downloading then steps 3, 4 will clash if they execute at the same time as the first row is accessing the database.
Has anyone done anything similar and if so what was the strategy you used to manage the flow of events.
Also i wanted to wrap this all up in a backgroundTask with ExpirationHandler so it would survive the user pressing the home button... but the delegate methods don't get called when i do that.
Ok Here is what i did to fix the problem.
Created an NSOperationQueue
Added the URL operations as NSURLInnvocationOperations
3.waited until the URL operations were complete (waituntilalloperationsarefinished).
Then set the max concurrent count to 1 which forced the subsequent database operations to execute in series one after the other and thus prevented SQLite from locking it's self out.

Resources