Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Insert Record to table in SQL server
Go
New
Search
Notify
Tools
Reply
  
[CLOSED] Insert Record to table in SQL server
 Login/Join
 
Gold member
posted
I hold the file in the FEX and then I want to insert the hold file content to table in SQL server. How can I do that ?

This message has been edited. Last edited by: Kerry,
 
Posts: 55 | Registered: May 15, 2004Reply With QuoteReport This Post
<Pietro De Santis>
posted
Besides any WebFOCUS licencing issues, you can use MODIFY to update the SQL table

Something like:

MODIFY FILE table-name
FIXFORM FROM hold-file-name
MATCH key-field1 key-field2...
ON MATCH UPDATE *
ON NOMATCH INCLUDE
DATA ON hold-file-name
END

Or, you could use SQL pass-through.
 
Reply With QuoteReport This Post
Gold member
posted Hide Post
But how can I insert data from a HOLD file to the table in SQL server?

Please help !
 
Posts: 55 | Registered: May 15, 2004Reply With QuoteReport This Post
Master
posted Hide Post
Ringo, If you are licensed to update database with WebFOCUS you can do what was suggested. Here's a more detail example using the famous car file and lets say that car2 is a SQL table that has the same fields and formats that I am printing and holding as HOLDCAR.

TABLE FILE CAR
PRINT DCOST RCOST
BY COUNTRY
BY CAR
BY MODEL
BY BODYTYPE
-*DEFAULT HOLD NAME IS HOLD WHEN AS IS NOT USED
ON TABLE HOLD AS HOLDCAR
END
-RUN
MODIFY FILE CAR2
FIXFORM FROM HOLDCAR
MATCH COUNTRY CAR MODEL BODYTYPE
ON MATCH UPDATE *
ON NOMATCH INCLUDE
DATA ON HOLDCAR
END
 
Posts: 865 | Registered: May 24, 2004Reply With QuoteReport This Post
Gold member
posted Hide Post
Thank you very much !
 
Posts: 55 | Registered: May 15, 2004Reply With QuoteReport This Post
Platinum Member
posted Hide Post
The absolutely easiest way to put a HOLD file into a relational database is to do it directly.
eg
TABLE FILE CAR
stuff
ON TABLE HOLD FORMAT ORACLE AS tabname
END
or whatever database you have (the keywords are in the doc). Remember that your id is probably going to be the first part of the table name in the rdbms when you look for it.
 
Posts: 226 | Registered: June 08, 2003Reply With QuoteReport This Post
Virtuoso
posted Hide Post
quote:
GeraldCohen wrote:
[qb] The absolutely easiest way to put a HOLD file into a relational database is to do it directly.
[/qb]
...but note that, at least with earlier releases (4.x) of WF, the column names for the resulting table will be the standard HOLD MFD aliases: E01, E02,....
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Reply With QuoteReport This Post
Platinum Member
posted Hide Post
Ringo, I need to do the same thing. But, I don't see in this code anywhere where it actually writes it to the database? Where do you actually write the contents of the hold file to the database/table?


7.7.02
Windows
EXCEL, PDF, CSV, TEXT
 
Posts: 106 | Registered: June 25, 2009Reply With QuoteReport This Post
Expert
posted Hide Post
This code creates a HOLD file and then uses MODIFY to update a table based on the data in the HOLD file:

-SET &ECHO=ON;

SET ASNAMES=ON
SET HOLDLIST=PRINTONLY
SET HOLDFORMAT=ALPHA

TABLE FILE CAR
PRINT
COMPUTE DEALER_COST1/D7 = DEALER_COST * 1.001; AS DEALER_COST
BY COUNTRY
BY CAR
BY MODEL
BY BODYTYPE
ON TABLE HOLD AS H001
END
-RUN

MODIFY FILE CAR
FIXFORM FROM H001
MATCH COUNTRY CAR MODEL BODYTYPE
ON MATCH   UPDATE DEALER_COST
ON NOMATCH INCLUDE
DATA ON H001
END
-RUN

This message has been edited. Last edited by: Francis Mariani,


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Reply With QuoteReport This Post
Expert
posted Hide Post
This example creates a HOLD file containing SQL UPDATE commands:

-SET &ECHO=ON;

SET ASNAMES=ON
SET HOLDLIST=PRINTONLY
SET HOLDFORMAT=ALPHA

TABLE FILE CAR
PRINT
COMPUTE DEALER_COST1/D7 = DEALER_COST * 1.001; NOPRINT
COMPUTE DEALER_COST2/A10 = FTOA(DEALER_COST1, '(D7c)', 'A10'); NOPRINT

COMPUTE SQLUPDATE/A200 = 'UPDATE CAR ' |
  'SET DEALER_COST = '  | DEALER_COST2 |
  ' WHERE COUNTRY = ''' | COUNTRY      || '''' |
  ' AND CAR = '''       | CAR          || '''' |
  ' AND MODEL = '''     | MODEL        || '''' |
  ' AND BODYTYPE = '''  | BODYTYPE     || ''';';

BY COUNTRY  NOPRINT
BY CAR      NOPRINT
BY MODEL    NOPRINT
BY BODYTYPE NOPRINT
ON TABLE HOLD AS H001
END
-RUN

SQL
-INCLUDE H001
END
-RUN


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Reply With QuoteReport This Post
Platinum Member
posted Hide Post
Thanks for all the suggestions, but I still can't get it to work. Here's what I need to do:

I have the following SQL Server tables:
tableA
tableB

Both tables have different keys.

What I want to do is get the result of column1 + column2 in table A and store it in column4 of tableB.

tableB has 3 key fields: column1, column2 and column3

How should this be coded?


7.7.02
Windows
EXCEL, PDF, CSV, TEXT
 
Posts: 106 | Registered: June 25, 2009Reply With QuoteReport This Post
Expert
posted Hide Post
Ted,

Don't you feel we've provided enough information to enable you to try different methods. You're now asking us to solve your particular business problem.

"Both tables have different keys" - you haven't told us what the keys are in BOTH tables, just one.

This might get you closer:

-SET &ECHO=ON;

SET ASNAMES=ON
SET HOLDLIST=PRINTONLY
SET HOLDFORMAT=ALPHA

TABLE FILE TABLE1
PRINT
COMPUTE COLUMN4/D15 = TABLE1.COLUMN1 + TABLE1.COLUMN2;
BY TABLE1.COLUMN??? AS COLUMN1
BY TABLE1.COLUMN??? AS COLUMN2
BY TABLE1.COLUMN??? AS COLUMN3
ON TABLE HOLD AS H001
END
-RUN

MODIFY FILE TABLE2
FIXFORM FROM H001
MATCH COLUMN1 COLUMN2 COLUMN3
ON MATCH   UPDATE COLUMN4
ON NOMATCH INCLUDE
DATA ON H001
END
-RUN


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Reply With QuoteReport This Post
Expert
posted Hide Post
Something along the lines of -
SQL SQLDBC
  update [your target teradata table] T1
     set column4 = (select column1 | column2
	             from [your source teradata table] S1
                     where T1.column1 | T1.column2 | T1.column3
                         = S1.column1)
;
END
Not entirely WebFOCUS but, providing you get your SQL correct, then it should work.

One advantage of using SQL passthru with SQLDBC is that it doesn't need a .mas or .acx.

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 
 
Posts: 5681 | Location: United Kingdom | Registered: April 08, 2004Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Insert Record to table in SQL server

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.