Focal Point
Can you create a temp table?

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

April 25, 2006, 03:11 PM
rc
Can you create a temp table?
Can you create a temp table in WF
Something like

Define File TempTable
BR/A45 = &InBR
END

Now use the TempTable and BR field

Table File TempTable
Print BR
bal bal
All I'm doing is print out what the user is sending in through a input parameter. Can this be done?
April 25, 2006, 03:34 PM
codermonkey
Is this just for testing and debugging? If so, would using -TYPE accomplish what you need?

-TYPE &InBR
April 25, 2006, 03:42 PM
rc
This will be more for production. I'm figuring I can use this approach to show the first report of 3 compound reports(excel and pdf). The first is the front page and it will display the user input. The subsequent reports will print with the data coming back from a sql stored proc. The issue I have is if I tie the first report to a result set and that result set comes back empty then the front page will not show. I need the front page to show always.
April 25, 2006, 04:25 PM
reFOCUSing
Let me see if I can explain this right.
Try following the below steps and see if this is what you want.

1) Running the following code will place data into an edapath (appath) folder.
FILEDEF TESTCAR DISK C:\ibi\apps\baseapp\testcar.ftm
TABLE FILE CAR
SUM
     RETAIL_COST
     DEALER_COST
BY
     COUNTRY
BY
     CAR
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE SAVE AS TESTCAR FORMAT ALPHA
END
-RUN


2) You will need to create a master file for the data you placed on the edapath.
FILENAME=TESTCAR,	SUFFIX=FIX
FIELDNAME=COUNTRY,	COUNTRY,	A10,$
FIELDNAME=CAR,		CAR,		A16,$
FIELDNAME=DEALER_COST,	DEALER_COST,	D7,$
FIELDNAME=RETAIL_COST,	RETAIL_COST,	D7,$


3) Then you will need to be able to read the data you placed on the edapath.
FILEDEF HOLDMAST DIR C:\ibi\apps\baseapp\
FILEDEF TESTCAR DISK C:\ibi\apps\baseapp\testcar.ftm
-RUN

TABLE FILE TESTCAR
PRINT *
END
-RUN
FILEDEF HOLDMAST CLEAR
-RUN


I hope this will give you some ideas.
April 25, 2006, 04:29 PM
codermonkey
Can you turn EMPTYREPORT on and make the user supplied parms a report heading?
Example with the infamous car file:

SET EMPTYREPORT=ON
-DEFAULT &FIELD1 = 'CAR';
-DEFAULT &FIELD2 = 'MODEL';
TABLE FILE CAR
ON TABLE PAGE-BREAK AND SUBHEAD
"Fields selected: &FIELD1"
"&FIELD2"
"More fields... etc. PRINT &FIELD1 &FIELD2
BY COUNTRY
WHERE COUNTRY EQ 'MONKEY'
ON COUNTRY PAGE-BREAK
ON TABLE PCHOLD FORMAT PDF
END

You'd need to tweak this but it might get you started...
April 25, 2006, 04:29 PM
rc
Architecturally you need to create a physical table, define it and then populate it. Is there some way to do it in memory?
April 25, 2006, 04:55 PM
reFOCUSing
If you are running on an Oracle db you could do some like this:

-SET &VAR00 = 'HI';
-SET &VAR01 = 'BYE';
-RUN

SQL SQLORA
SELECT
'&VAR00' var00,'&VAR01' var01
FROM
  dual
;
TABLE
ON TABLE HOLD AS H0 ALPHA
END
-RUN
TABLE FILE H0
PRINT *
END
-RUN

April 26, 2006, 04:00 AM
Tony A
rc,

This is a piece of code that I use occasionally to generate the contents for a combo box when I need to "invent" data. The basic principle is creating a dummy file that resides only in the EDATEMP folder and, providing you don't have TEMPERASE=OFF, the file will be deleted when the agent process ends.

APP FI mcgyver DISK mcgyver.MAS
-RUN
-WRITE mcgyver FILE=mcgyver,SUFFIX=FOC
-WRITE mcgyver SEGNAME=SEG1
-WRITE mcgyver FIELD=DATA_KEY,,I9,I4,$
-RUN
USE mcgyver.FOC NEW
END
-RUN
CREATE FILE mcgyver
-RUN
MODIFY FILE mcgyver
FIXFORM DATA_KEY/A9
MATCH DATA_KEY
  ON NOMATCH INCLUDE
DATA
        1
        2
        3
        4
        5
        6
        7
        8
END
-RUN
DEFINE FILE mcgyver
  DISPLAY/A15 = DECODE DATA_KEY(1 'Display Value 1' 2 'Display Value 2' 3 'Display Value 3'
                                4 'Display Value 4' 5 'Display Value 5' 6 'Display Value 6'
                                7 'Display Value 7' 8 'Display Value 8' ELSE 'FOC_NONE');
END
TABLE FILE mcgyver
PRINT DISPLAY
BY DATA_KEY
ON TABLE PCHOLD FORMAT XML
END


T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
April 26, 2006, 10:14 AM
rc
I'm on MS SQL 2k the same possible?
April 26, 2006, 11:56 AM
Tony A
rc,

Yes, as all that this is doing is creating a FOCUS database in EDATEMP.

If you really mean "can I do this in MS SQL" then the answer is dependant upon the write perissions you have to the database to which you are connecting, plus create authority etc.

Basically you would perform SQL passthru to create the table with the specifications and then use INSERT to add the necessary rows of data.

HOWEVER, this does not create a temporary table and it will need to be deleted at the end of your process.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
April 26, 2006, 03:33 PM
rc
I would prefer not to have to go to those lengths. But if I have to I will, not yet as familiar with Focus to know it’s limitations.
If you’re familiar with any of these terms you'll know what I ultimately want to do in Focus.
SQL #temp table of type temp. A table that only exists in memory
VB.net table object. Only exist in memory not on the physical database
VB 6 or VBA recordset. Only exist in memory and is derived most of the time from the result of an SQL query.
Looking for a similar construct in Focus. An object that I can be populated with records and used and then discarded as soon as the procedure is done executing.
The most basic concept is a two dimensional array that can be populated used and discarded.


I hope this helps.

This message has been edited. Last edited by: rc,
April 26, 2006, 04:20 PM
Leah
You can also do a table file
.
..
...
on table hold as format focus
end
Then Focus builds the mfd for you and it goes away after.


Leah
April 27, 2006, 05:47 AM
Tony A
rc,

If I read your second post correctly, you basically want to accept user input (from an HTML page presumably?) and then display this on a first page of a compound report.

If this is the case then you do not have to tie it into another result set (per se). You could just place all the variables being passed to your procedure into a HEADING and then execute an empty report page,

For instance, suppose your user has to choose a number of variables from combo boxes on your HTML page - for example &Var1 through &Var8. Then your procedure could be something like -

-* Always default the incoming variables so that testing is easier.
-DEFAULT &Var1 = '', &Var2 = '', &Var3 = '', &Var4 = '', &Var5 = '', &Var6 = '', &Var7 = '', &Var8 = ''

-* Ensure empty reports are shown
SET EMPTYREPORT = ON

TABLE FILE filename
-* This extracts just one row from the resultset and doesn't print it.
PRINT somefield NOPRINT
IF RECORDLIMIT EQ 1
-* This is where your variables are used on the first page
HEADING
"Report for someone using parameter input as follows :-"
"&Var1"
"&Var2"
"&Var3"
"&Var4"
"&Var5"
"&Var6"
"&Var7"
"&Var8"
ON TABLE PCHOLD FORMAT format OPEN
END
-RUN

TABLE FILE filename
SUM numeric_field
    more fields
BY sort_field etc.
WHERE field1 EQ '&Var1'
  AND field2 EQ '&Var2'
  AND etc.
ON TABLE PCHOLD FORMAT format
END
-RUN

more reports as required.

SET COMPOUND = CLOSE


The first report will always have content, the second will have content if the result set is not empty or will show the HEADING and FOOTING components if the resultset is empty.

As I say, I think is what you really want and not a temporary file that you can push the user input into to then extract from it. If not then let us know and we'll try again. Smiler

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
April 27, 2006, 12:04 PM
rc
Thanks all.
Tony A approach worked great.
What is the run with "-" Why can I use the Set right before the Table File filename and inside the Table File I have to use -Set ??
April 27, 2006, 02:26 PM
Tony A
rc,

Glad it worked for you.

The -RUN forces the execution of the stack and, as all commands preceded by a hypen, is a dialogue manager command. There are some good explanations in this forum (somewhere).

As per the above, there is a difference between the -SET and just plain SET. What SET do you mean and what is the full string you are refering to?

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
April 28, 2006, 10:12 AM
rc
set emptyreport = on
vs
-Set &sdatey = &dateyy;

Why the "-" and ";"

Within the coding window there must be different flavors of code you can write i.e. dialogue manager vs. what?
April 28, 2006, 10:53 AM
Tony A
rc,
For a very old, but still relevant, example of how dialogue manager controls the flow of your procedure, check out this link. You will need an inforesponse login to view it.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10