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.
I need to insert multiple rows in SQL 2005 table, so my code is
-SET &CURR_DATE= EDIT(&YYMD,'99999999');
-SET &BUYOUT_RISK_RATING = 33;
SQL
DECLARE @JobNo VARCHAR(12), @PMEmail VARCHAR(50)
DECLARE abc CURSOR
FOR
SELECT F2.[JOB NUMBER] AS JobNo, F1.[PROJECT MANAGER EMAIL] AS PMEmail
FROM DW.VJOBACCOUNTBALANCESUMMARYDAILY_FACT F1, DW.VJOB_DIM F2
WHERE F1.JOBID = F2.JOBID
AND F1.YYYYMMDD = &CURR_DATE
AND F1.[BUYOUT RISK SCORE] >= &BUYOUT_RISK_RATING
AND (F2.[JOB NUMBER]+F1.[PROJECT MANAGER EMAIL] NOT IN
(SELECT JOB_NUMBER+SENT_TO FROM DW.TALERTS_SENT))
OPEN abc
FETCH NEXT FROM abc INTO @JobNo, @PMEmail
WHILE (@@FETCH_STATUS = 0)
BEGIN
INSERT INTO DW.TALERTS_SENT (Alert_Name, Job_Number, Date_Sent, Sent_To)
VALUES ('Buyout-PM', @JobNo, GETDATE(), @PMEmail)
FETCH NEXT FROM abc INTO @JobNo, @PMEmail
END
CLOSE abc
DEALLOCATE abc
GO
END
As it states in the case you referenced in your post, this type of SQL is not supported in SQL pass-thru. It is also my understanding that you cannot 'stack' SQL statements like this in a single pass-thru statement like you could if you were creating a SQL Server stored procedure. Reference case #12282088. I would suggest actually creating a SQL Server stored procedure and calling it from your focexec or try using MODIFY or MAINTAIN.
Data Migrator 5.3, 7.1, 7.6 WebFOCUS 7.1, 7.6, 7.7 SQL Server, Oracle, DB2 Windows
Thank you for reply. Creating a SQL Server stored procedure the way I tried to do it is not going to work per case #23032569 (http://techsupport.informationbuilders.com/sps/23032569.html). Can you please provide some examples which show Inserting / Updating MULTIPLE records in LOOP using any of the methods you mentioned (creating a SQL Server stored procedure and calling it from your focexec or try using MODIFY or MAINTAIN). Thanks again.
WF 7.6.4, Win XP, SQL 2005
Posts: 42 | Location: California | Registered: August 17, 2007
Still having trouble with inserting multiple rows. The code is
-SET &TIME = EDIT(&TOD,'99:$99:$99')||'.000';
-SET &DAY = EDIT(&YYMD,'9999/99/999');
-SET &TS = &DAY||&TIME;
-TYPE "TS is " &TS -* this line shows "TS is " 2007/10/08 10:50:55.000
ENGINE SQLMSS SET DEFAULT_CONNECTION DW_DEV_SV
SQL SQLMSS PREPARE SQLOUT FOR
SELECT 'Buyout-PM' AS ALRTNM, RTRIM(F2.[JOB NUMBER]) AS JOBNUM, GETDATE() AS CURDATE, F1.[PROJECT MANAGER EMAIL] AS PMEMAIL
FROM ...
WHERE ...
END
TABLE FILE SQLOUT
PRINT *
ON TABLE HOLD AS #HLIST1 FORMAT SQLMSS
END
-RUN
-*-- Insert all the rows from the temporary table ----------
SQL
INSERT INTO DW.TALERTS_SENT (ALERT_NAME, JOB_NUMBER, DATE_SENT, SENT_TO)
SELECT ALRTNM, JOBNUM, '&TS', PMEMAIL FROM #HLIST1
;
END
-RUN
I'm getting errors like (FOC428)TRANS 1 REJECTED FORMAT COL 43 FLD DATE_SENT Buyout-PM6 20071008105055000test987@aol.com What interesting is that if I replace line
SELECT ALRTNM, JOBNUM, '&TS', PMEMAIL FROM #HLIST1
SQL SQLMSS PREPARE SQLOUT FOR
SELECT id, name , GETDATE() AS CURDATE
FROM sysobjects
END
TABLE FILE SQLOUT
PRINT *
ON TABLE HOLD AS #HLIST1 FORMAT SQLMSS
END
-RUN
SQL
INSERT INTO HLIST_COPY (E01,E02,E03)
SELECT E01,E02,E03 FROM #HLIST1
END
1. I do not understand how you can even TABLE HOLD AS #HLIST1 FORMAT SQLMSS MSSQL creates #-tables in tempdb, and I think that such command can be executed only if your default database is tempdb. I get error: Microsoft OLE DB Provider for SQL Server: [42S02] Cannot create an index : on '#HLIST1', because this table does not exist in database '....'.
2. INSERT Your INSERT is in SQL, not in SQL SQLMSS. So it's FOCUS SQL. And I see in docs: "The SQL Translator does not support subqueries, such as: INSERT...INTO...SELECT...FROM..."
3. MSSQL #-tables, part2 AFAIK, WF does not hold connection by default to MSSQL, and MSSQL drops temp tables when session ends. So it must be dangerous to use them as hold-files (I can be wrong)
4. Ideas:
My way for WF+MSSQL is : a) Incapsulate everything into SP and UDF (UDF is good, I use them extensively) b) Run data modification procs in EX, reporting procs in EXEC
That's all my ideas at this moment.
I'm also interested in tips and tricks for MSSQL.
WF 7.6.2, WinNT/2K, MSSQL 2K, MSOLAP 2K, BID
Posts: 79 | Location: Moscow | Registered: April 27, 2007