Relatively new to webfocus. Using WebFocus 5.2.3 - not using Maintain.
I have a simple request. I have looked at the online help but I can't find a good example.
I want to do some simple table maintenance. I don't want to write a java program. People have told me that you can use SQL passthru to update the database from a webfocus report.
So, if I have an employee table in Oracle comprised of of three fields, lastname, firstname and address and I want the user to be able to update the address, how do I connect to the Oracle table, how do I capture the 'changed' address and what command do I use to actually update the table?
Forget any security restrictions or things like that - how do I connect, retrieve and update a table using SQL passthru?
Thanks in advance
The code below is the simplest connection to an oracle table you can do where "MYSERVER" is the name of the database and "MYTABLE" is the name of the table. Any SQL statment can be executed instead of the select statement below.
<br /><br />SQL SQLORA SET SERVER MYSERVER<br />SQL SQLORA<br /><br />SELECT * FROM MYTABLE<br /><br />END<br />You can also put focus amper-variables in your query...
SQL SQLORA SET SERVER MYSERVER<br />SQL SQLORA<br />SELECT * <br />FROM MYTABLE <br />WHERE EMPLOYEE_ID = &ER_ID<br />END<br />When you execute this query you will be prompted for the value of amper_id. After you enter a value and click submit, the request goes through to your database.
You can also use the results of a sql passthrough to create a hold file.
<br />SQL SQLORA SET SERVER MYSERVER<br />SQL SQLORA<br />SELECT * <br />FROM MYTABLE <br />WHERE EMPLOYEE_ID = &ER_ID<br />TABLE<br />ON TABLE HOLD AS MYHOLD FORMAT FOCUS INDEX EMPLOYEE_ID<br />END<br />Then you can use the result as the base of different report.
<br />TABLE FILE MYHOLD<br />PRINT<br />FIRST_NAME<br />BY EMPLOYEE_ID<br />END<br />
You can also use the techniques described above to update your database.
<br />SQL SQLORA SET SERVER MYSERVER<br />SQL SQLORA<br />UPDATE MYTABLE SET FirstName = &FIRST_NAME<br />WHERE EMPLOYEE_ID = &ER_ID<br />END<br />
A word of caution...
Using SQL passthrough has helped me create a lot of good reports quickly but it also has no error checking for rediculously large queries. I suggest testing your SQL statements in software tool such as PL/SQL developer or Toad (Free download at [URL=http://www.quest.com).]www.quest.com).[/URL] That way your DBAs won't be angry with you.
|Powered by Social Strata|