Focal Point
[CLOSED] Passing hold files values into a query one after the other.

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/6847032276

August 18, 2014, 07:56 AM
Prabhakar
[CLOSED] Passing hold files values into a query one after the other.
I am in need of some assistance.
Scenario:
I use a sql query to fetch some information like for example emp_id from emp table and I created a hold file (say SQL_DATA).
And in the same fex file I have another query wherein I need to pass emp_id (from the previous hold file SQL_DATA ) one at a time.

At present I’m preparing a string by concatenating all the emp id’s with a “,” and then passing one by one into the query using a loop and GETTOK. Looks is getting broken when we have more id’s. I need to know if there is any other way that we can do this much better and effectively. Thank you

This message has been edited. Last edited by: <Kathryn Henning>,


WebFOCUS 7.7.05 and 8.x
Windows, All Outputs
August 18, 2014, 09:23 AM
J
You don't need the string concatenation, you can loop while you are doing the read:
TABLE FILE EMPLOYEE
BY EMP_ID
ON TABLE HOLD
END
-RUN

-SET &NBREMPLOYEES = &LINES;
-REPEAT READEMPLOYEE &NBREMPLOYEES TIMES

-READFILE HOLD
-TYPE &EMP_ID -*Just for debugging purposes
...insert your query for each employee here

-READEMPLOYEE



WebFOCUS 7.7.03/8.0.08
Dev Studio 7.7.03/8.0.08
App Studio 8.0.08
Windows 7
ALL Outputs
August 18, 2014, 09:25 AM
Ram Prasad E
There are multiple options available. One way is to convert your first query as subquery and use it directly in filter clause of second query. Other way is to use IN FILE option available in SQL, so that there is no need to read one by one and concatenate with comma separation.
Let me know if this works.

Thanks,
Ram


WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
August 18, 2014, 05:33 PM
Waz
Is the second query FOCUS code or SQL ?

You could join from the hold file to the second query.

With a HOLD file join to RDBMS tables, multiple queries are sent for each record in the hold file.

Without more information about the code you have, a good answer is difficult.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

August 19, 2014, 02:50 AM
Prabhakar
@Ram - I cant use a sub query as the query has to get executed for each emp id seperatly.
@Waz - Both are sql queries.
@J - Option provided you seems to be working in my scenario.
When the loop run for 600 or so it is working fine and when it goes over 700 or so, it is showing "Task error: ERROR WRITING OUTPUT FILE: @0000057. No report to distribute." Do we need to make any settings change on the server. Please guide me. Thank all for your support.


WebFOCUS 7.7.05 and 8.x
Windows, All Outputs
August 19, 2014, 04:04 AM
Alan B
Initial thought is that you could try setting agent_refresh=1 on the server. This has been know to help sometimes.


Alan.
WF 7.705/8.007
August 19, 2014, 08:27 AM
J
quote:
Task error: ERROR WRITING OUTPUT FILE: @0000057
Does it give you a line number? that makes it sound like it is erring out on the hold file, not the readfile. Maybe you could provide us with your code so we can get a better idea of what you are trying to do and why you need to use my method instead of the others.


WebFOCUS 7.7.03/8.0.08
Dev Studio 7.7.03/8.0.08
App Studio 8.0.08
Windows 7
ALL Outputs
August 19, 2014, 05:33 PM
Waz
The performance issue seems similar to something I had a while ago.

http://forums.informationbuild...587079106#8587079106

I would suggest creating a temporary table in the database and add that to your SQL query, so its one step, not hundreds.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

August 20, 2014, 06:38 AM
Rifaz
Hi Prabhakar,

Just a thought, try once with NOCLOSE in READ command.


-Rifaz

WebFOCUS 7.7.x and 8.x