As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.
Join the TIBCO Community TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.
From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
Request access to the private WebFOCUS User Group (login required) to network with fellow members.
Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.
I have a scenario like this: There are two tables,table A and table B. A has three columns:ID,CardName,CardNum.B also has three columns:ID,UserName,Account. I create a form with five edit box and the user could type the value into it. I hope these values could be written in the database. The ID will be typed once but it will be written in two tables.How to do this?
WF 7702 Database Oracle 9iThis message has been edited. Last edited by: Kerry,
I tested it with your code, but it just could write in one table named info. Here is my code:
MAINTAIN FILE info AND customer
$$Declarations
Case Top
init( );
disp_form( );
-* Replace the Winform Show command with the following code
-* when to display your form in a non-persistent state
-* Winform Show_And_Exit Form1;
EndCase
Case init
INFER info.INFO.SSN INTO AddInfoStk;
INFER customer.CUSTOMER.SSN INTO AddCustomerStk;
EndCase
Case disp_form
Winform Show Form1;
EndCase
END
The button on-click event is: Case OnButton1_Click For 1 revise info.INFO.SSN from AddInfoStk ; For 1 revise customer.CUSTOMER.SSN from AddCustomerStk ; EndCase
Could it be that the ssn value already exist in the customer table? The revise command does an update or include depending on whether the row exist or not. Can you revise another column?
The form uses AddInfoStk for SSN, and I presume some of the elements are bound to that stack, others bound to AddCustomerStk.
Therefore there is no SSN in AddCustomerStk to be input.
You must compute the values in AddCustomerStk from the values in AddInfoStk.
Case OnButton1_Click
For 1 revise info.INFO.SSN from AddInfoStk ;
compute AddCustomerStk.SSN = AddInfoStk.SSN;
$$ repeat for all values required.
For 1 revise customer.CUSTOMER.SSN from AddCustomerStk ;
EndCase
All of this is covered in the basic training course which I highly recommend you attend. Maintain is a powerful language, but not that easy to understand all the syntax and how it all fits together. The supervised workshops help put everything into perspective.
Alan. WF 7.705/8.007
Posts: 1451 | Location: Portugal | Registered: February 07, 2007
and it works. But I found that if I don't close the display page,there are always three locks in my database and if I close the page the value would be inserted into the tables immediately.How could this happen? What should I do if I want to insert the value immediately after I click the add-button.
Structure is very important to the maintainability(!) of the Maintain code, and to ensuring that you can develop easily and control what happens.
May I suggest the following structure:
MAINTAIN FILE info AND customer
$$Declarations
Case Top
$$ The top case is the controlling case, keep the infers and initial winforms up here
$$ If you are retrieving data, make a case call though
Infer info.info.ssn into addinfostk;
Infer customer.customer.ssn into addcustomerstk;
Winform Show Form1;
EndCase
Case update
declare error/i8;
errorFile/a20;
errorMsg/a0;
AddCustomerStk.SSN = AddInfoStk.SSN;
$$ Using a dummy repeat lets you control the commits and rollbacks quite easily
repeat 1
For 1 revise info.INFO.SSN from AddInfoStk ;
$$ Check error, and if gt 0 rollback and exit dummy repeat
if FocError ne 0 then begin
error = FocError;
errorFile = 'info';
$$ The errorMsg can be displayed back to the user, and/or other action taken
errorMsg = 'Error ' | error | ' in file ' | errorFile || '. Data not updated';
rollback
goto exitrepeat;
endbegin
For 1 revise customer.CUSTOMER.SSN from AddCustomerStk ;
if FocError ne 0 then begin
error = FocError;
errorFile = 'customer';
errorMsg = 'Error ' | error | ' in file ' | errorFile || '. Data not updated';
rollback
goto exitrepeat;
endbegin
$$ commit only if no errors
commit
endrepeat
EndCase
END
and for the handler. (Oh and please name the form objects, don't use the default name like button1, edit1 etc.)
Case OnButton1_Click
$$ Keep as much code out of the handlers as possible. It is easier to develop and maintain.
update();
EndCase
I know that this is personal, but after 12 years of WebFOCUS maintain, this is the structure I have settled on, and it works.
Alan. WF 7.705/8.007
Posts: 1451 | Location: Portugal | Registered: February 07, 2007
It is a personal preference, we are all different. I would move the Winform call separate if running with multiple forms rather than a single form though.
However, training is still important, there is a huge amount that can be achieved in the Maintain, but also techniques for controlling Winforms etc.
Alan. WF 7.705/8.007
Posts: 1451 | Location: Portugal | Registered: February 07, 2007