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     Insert SQL with datetime field

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Insert SQL with datetime field
 Login/Join
 
Silver Member
posted
I have SQL 2005 table with DateTime field Data Type. Table name is TALERTS_SENT. Field name is DATE_SENT. This field is DateTime Data Type. I need to be able to insert records to this table from WebFocus procedure (*.fex).
If I do this
SQL
INSERT INTO TALERTS_SENT (ALERT_NAME, JOB_ID, DATE_SENT, SENT_TO) VALUES
('AN2', 1, 9/26/2007, 'test2@aol.com');
END
or this
SQL
INSERT INTO TALERTS_SENT (ALERT_NAME, JOB_ID, DATE_SENT, SENT_TO) VALUES
('AN2', 1, &DATEMDYY, 'test2@aol.com');
END
then I get error
(FOC14069) SYNTAX ERROR ON LINE 2 AT '/' -- Expected ')'
So it doesn't like forward slash inside date value. How can I insert date value in DateTime field?
Note -
I was able to prove that this problem is related to DateTime field.
I created new table tAlerts_Test1 in SQL 2005 with the same field names, but I did change Data Type for Date_Sent field from datetime to
nvarchar(30).
I was able to run the code below from WebFocus and it successfully inserted row in tAlerts_Test1 table.
SQL
INSERT INTO DW.TALERTS_TEST1 (Alert_Name, Job_ID, Date_Sent, Sent_To)
VALUES
('AN4', 4, '09/26/2007', 'test4@aol.com');
END


WF 7.6.4, Win XP, SQL 2005
 
Posts: 42 | Location: California | Registered: August 17, 2007Report This Post
Guru
posted Hide Post
Hi Seva,

I think the datetime is expecting something like "2005/1/1 00:00:00" . Can you not change the type to varchar?


WF 8.x and 7.7.x Win/UNIX/AS400, MRE/Portal/Self-Service, IIS/Tomcat, WebSphere, IWA, Realmdriver, Active Directory, Oracle, SQLServer, DB2, MySQL, JD Edwards, E-BIZ, SAP BW, R/3, ECC, ESSBASE
 
Posts: 285 | Location: Texas | Registered: June 27, 2006Report This Post
Silver Member
posted Hide Post
Yes, I just figured it out that datetime will accept something like '2007/09/26 12.12.12', so now I know what I should do. Thanks.


WF 7.6.4, Win XP, SQL 2005
 
Posts: 42 | Location: California | Registered: August 17, 2007Report This Post
Silver Member
posted Hide Post
It works if I do just 1 line insert using 'Values' syntax like this:
 -SET &TIME = EDIT(&TOD,'99:$99:$99')||'.000';
-SET &DAY = EDIT(&YYMD,'9999/99/999');
-SET &TS = &DAY||&TIME;
-TYPE "TS is " &TS
SQL
  INSERT INTO DW.TALERTS_SENT (ALERT_NAME, JOB_NUMBER, DATE_SENT, SENT_TO)
  VALUES ('Buyout-PM','987','&TS','test987@aol.com');
END 


If I try to insert multiple lines like this:
 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, CURDATE, PMEMAIL FROM #HLIST1
  ;
END
-RUN 
then it fails with errors like
 (FOC428)TRANS     1 REJECTED  FORMAT  COL    43 FLD DATE_SENTBuyout-PM6           20071008115040807test123@aol.com 
Any ideas?


WF 7.6.4, Win XP, SQL 2005
 
Posts: 42 | Location: California | Registered: August 17, 2007Report This Post
Platinum Member
posted Hide Post
btw, i don't think you have to have the timestamp to insert. SQL expects datetimes to be in quotes (eg, '9/27/2007')


Thanks.

Mark
WF 7.6 Windows
 
Posts: 150 | Registered: July 26, 2007Report This Post
Silver Member
posted Hide Post
Mark,
looks like I do have to have timestamp because if I do
 -SET &TIME = EDIT(&TOD,'99:$99:$99')||'.000';
-SET &DAY = EDIT(&YYMD,'9999/99/999');
-SET &TS = &DAY||&TIME;
-TYPE "TS is " &TS
-*-- 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, '&DAY', PMEMAIL FROM #HLIST1
  ;
END
-RUN 
then error says
 (FOC14091) INSERT VALUE FOR 'DATE_SENT' IS NOT COMPATIBLE WITH COLUMN FORMAT 
However, if I do
 -*-- 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 
then error says
 (FOC428)TRANS     1 REJECTED  FORMAT  COL    43 FLD DATE_SENT 
. As you see, I included this field in single quotes. So, based on the 1st example I do need timestamp and format should be like '2007/10/08 13:07:48.000'. Any ideas how to fix error in the 2nd example?
Thanks


WF 7.6.4, Win XP, SQL 2005
 
Posts: 42 | Location: California | Registered: August 17, 2007Report This Post
Expert
posted Hide Post
Seva,

Try it in one process rather than hold it temporarily first -
ENGINE SQLMSS SET DEFAULT_CONNECTION DW_DEV_SV
SQL SQLMSS
  INSERT INTO DW.TALERTS_SENT (ALERT_NAME, JOB_NUMBER, DATE_SENT, SENT_TO)
  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 *
END
-RUN

Unless there's a reason that you're holding 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 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Silver Member
posted Hide Post
Tony,
your suggestion worked. THANK YOU VERY MUCH!
Seva


WF 7.6.4, Win XP, SQL 2005
 
Posts: 42 | Location: California | Registered: August 17, 2007Report This Post
Expert
posted Hide Post
You are most welcome, glad it helped 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 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report 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     Insert SQL with datetime field

Copyright © 1996-2020 Information Builders