Focal Point Banner


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.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] SQL PASS THRU - insert multiple rows to a table

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] SQL PASS THRU - insert multiple rows to a table
 Login/Join
 
Member
posted
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.

RK

This message has been edited. Last edited by: FP Mod Chuck,


WebFOCUS 8.1.05
Excel, PDF, Pivot, HTML
Windows
 
Posts: 29 | Registered: August 12, 2009Report This Post
Virtuoso
posted Hide Post
Have you considered HOLD FORMAT SQLORA or whatever RDBMS you want to populate? It seems a lot less effort than what you describe.


WebFOCUS 8206, Unix, Windows
 
Posts: 1853 | Location: New York City | Registered: December 30, 2015Report This Post
Member
posted Hide Post
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.

Thank you
RK


WebFOCUS 8.1.05
Excel, PDF, Pivot, HTML
Windows
 
Posts: 29 | Registered: August 12, 2009Report This Post
Expert
posted Hide Post
Do you need to use SQL pass thru ?

You could use MODIFY (Depending on the content like clobs and blobs)


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!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Virtuoso
posted Hide Post
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 :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Gold member
posted Hide Post
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 


WF 8.2.04
Windows/Unix
All Formats
In Focus since 2006
 
Posts: 74 | Location: UK | Registered: September 17, 2018Report This Post
Guru
posted Hide Post
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.


Test: WF 8.2
Prod: WF 8.2
DB: Progress, REST, IBM UniVerse/UniData, SQLServer, MySQL, PostgreSQL, Oracle, Greenplum, Athena.
 
Posts: 454 | Location: Europe | Registered: February 05, 2007Report This Post
Virtuoso
posted Hide Post
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 :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Gold member
posted Hide Post
quote:
PUTDDREC

Good One


WF 8.2.04
Windows/Unix
All Formats
In Focus since 2006
 
Posts: 74 | Location: UK | Registered: September 17, 2018Report This Post
Member
posted Hide Post
quote:
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.


Every week 200 to 300 rows.


WebFOCUS 8.1.05
Excel, PDF, Pivot, HTML
Windows
 
Posts: 29 | Registered: August 12, 2009Report This Post
Member
posted Hide Post
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 


WebFOCUS 8.1.05
Excel, PDF, Pivot, HTML
Windows
 
Posts: 29 | Registered: August 12, 2009Report This Post
Gold member
posted Hide Post
Hi Riya,
:Fetch_data is a label that I created so that I can loop throught a segment.

You can call it whatever you want. I generally create my labels starting with : but it is not a compulsion.

have a look at following documentation

Looping in WF
Branching


WF 8.2.04
Windows/Unix
All Formats
In Focus since 2006
 
Posts: 74 | Location: UK | Registered: September 17, 2018Report This Post
Master
posted Hide Post
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, 2006Report This Post
Guru
posted Hide Post
Riya, Using BabakNYC's idea.

Do your
 
HOLD FORMAT SQLORA
 


into a temp table (say TEMP_DATA)

Then run an insert into your table using the temp table.

Insert into MY_TABLE (col1,col2)
Select a.col1 AS col1, 
a.col2 AS col2
FROM TEMP_DATA


Fernando


Prod WF 8.1.04, QA WF 8.2.03, Dev WF 8.2.03
 
Posts: 278 | Registered: October 10, 2006Report This Post
Expert
posted Hide Post
Fernando, thats a great idea.


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!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] SQL PASS THRU - insert multiple rows to a table

Copyright © 1996-2020 Information Builders