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.
Hi, I have a hold file with multiple rows and I need to insert the rows to a table in database using SQL pass thru via scheduled report every week.
Earlier I tried using just one row with all values in the INSERT statement and it works but how to insert multiple rows from a hold file to a table(similar toe ETL)? Also the table has WF_ID as the primary key.
Please let me know. Thanks in advance.
RKThis message has been edited. Last edited by: FP Mod Chuck,
HOLD FORMAT to RDBMS creates a new table. I need to load it to the existing table with new rows based on the report date. Also increment the auto generate the primary key.
If your database supports creating multiple VALUES rows, you can generate the SQL for that.
For example:
INSERT INTO CAR (COUNTRY, CAR)
VALUES
('JAPAN', 'MAZDA')
, ('ITALY', 'FIAT')
, ('FRANCE', 'PEUGEOT')
, ('FRANCE', 'CITROEN');
The lines under VALUES is what you would generate the code for.
WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010 : Member of User Group Benelux :
-DEFAULTH &LOOP_CNTR = 0;
-DEFAULTH &CAR = '';
-DEFAULTH &COUNTRY = '';
-DEFAULTH &MODEL = '';
TABLE FILE CAR
PRINT
CAR
COUNTRY
MODEL
ON TABLE SAVE AS COL_VALUES
END
-RUN
-SET &LOOP_CNTR = &LINES;
-REPEAT :Fetch_Data &LOOP_CNTR TIMES
-READ COL_VALUES &CAR.A16 &COUNTRY.A10 &MODEL.A20
-TYPE VALUES ARE &CAR &COUNTRY &MODEL
-*Have your sql statement here
INSERT INTO CAR (COUNTRY, CAR, MODEL)
VALUES
('&COUNTRY', '&CAR','&MODEL');
-:Fetch_Data
WF 8.2.04 Windows/Unix All Formats In Focus since 2006
Posts: 74 | Location: UK | Registered: September 17, 2018
Actually, that looks like a great task for my new favourite WebFOCUS function: PUTDDREC
-SET &LIST = 'INSLIST';
FILEDEF &LIST DISK INSLIST.ftm
TABLE FILE CAR
PRINT
COMPUTE COMMA/A1 = IF LAST COUNTRY EQ '' THEN ' ' ELSE ','; NOPRINT
COMPUTE INSTUPLE/A256 = COMMA | '(''' || COUNTRY || ''', ''' || CAR || ''', ''' || MODEL || ''')'; NOPRINT
COMPUTE RESULT/I1 = PUTDDREC('&LIST', &LIST.LENGTH, INSTUPLE, ARGLEN(256, INSTUPLE, 'I3'), RESULT); NOPRINT
-* Other useful stuff you may want to hold unrelated to the insert list
BY COUNTRY NOPRINT
BY CAR NOPRINT
BY MODEL NOPRINT
ON TABLE HOLD
END
-RUN
SQL SQLMSS PREPARE SQLOUT FOR
INSERT INTO CAR (COUNTRY, CAR, MODEL)
VALUES
-INCLUDE INSLIST.ftm
;
END
WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010 : Member of User Group Benelux :
Originally posted by Frans: How many rows do you want to insert? Looping with insert statements is limited, MODIFY is the best way to properly insert data in existing tables.
This helps, I will try and update you.:FETCH_DATA is the webfocus command? What does it do?
Thank you
quote:
Originally posted by Addy: To add to Wep's suggestion
-DEFAULTH &LOOP_CNTR = 0;
-DEFAULTH &CAR = '';
-DEFAULTH &COUNTRY = '';
-DEFAULTH &MODEL = '';
TABLE FILE CAR
PRINT
CAR
COUNTRY
MODEL
ON TABLE SAVE AS COL_VALUES
END
-RUN
-SET &LOOP_CNTR = &LINES;
-REPEAT :Fetch_Data &LOOP_CNTR TIMES
-READ COL_VALUES &CAR.A16 &COUNTRY.A10 &MODEL.A20
-TYPE VALUES ARE &CAR &COUNTRY &MODEL
-*Have your sql statement here
INSERT INTO CAR (COUNTRY, CAR, MODEL)
VALUES
('&COUNTRY', '&CAR','&MODEL');
-:Fetch_Data
Depending on the volume I use SQL Insert, the SQL Loader, and MODIFY. For just a few hundred records, I'd use MODIFY and if all you are doing is inserting then make sure to use "SET SQL LOADONLY" right after the MODIFY statement. This tell MODIFY that all you are doing is loading and it cuts the I/O in half. Without it, MODIFY doesn't know if you are loading, updating or both. As a result, MODIFY will do an unnecessary SQL SELECT first to see if the row exist then do the SQL INSERT when it doesn't. You can see this if you turn traces on.
In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
Posts: 975 | Location: Oklahoma City | Registered: October 27, 2006