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.



Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] PostgreSQL
 Login/Join
 
Guru
posted
I've got the following problem inserting data into a PostgreSQL table. The SQL code below works fine from pgAdmin, but not from WebFOCUS.
There are no error messages at all. Any ideas?

SET SQLENGINE=SQLPSTGR
SQL SET SERVER server
SQL
INSERT INTO table (col1, col2, col3) VALUES (12345 ,'row 1','19870814 00:00:00.000');
INSERT INTO table (col1, col2, col3) VALUES (23456 ,'row 2','19870814 00:00:00.000');
INSERT INTO table (col1, col2, col3) VALUES (34567 ,'row 3','19870814 00:00:00.000');
COMMIT;
END

We're running WF 7.7.03 on Ubuntu 12.04 LTS (Precise Pangolin) and PostgreSQL 9.2.1

This message has been edited. Last edited by: Håkan,


WebFOCUS DS 8.0.06/08 DS/AS
WebFOCUS RS 8.0.08 (Linux/IBM i)
WebFOCUS Client 8.0.06 (Linux)
 
Posts: 319 | Location: Stockholm, Sweden | Registered: February 04, 2004Report This Post
Virtuoso
posted Hide Post
Perhaps the postgres logs contain some errors? You may need to turn on statement logging to see what happens.

Also, you could insert those 3 records with a single insert statement, which is a little more efficient:
INSERT INTO table (col1, col2, col3) VALUES (12345 ,'row 1','19870814 00:00:00.000'),
(23456 ,'row 2','19870814 00:00:00.000'),
(34567 ,'row 3','19870814 00:00:00.000');


What data-type is col3? If that's a timestamp type field, the formatting of your values probably doesn't match what the database expects.

Another thing that may be in play here; your pgadmin session probably uses different session settings than WF does, which could mean datetime values are interpreted different between the two. You can test that by setting such parameters before the first insert in your transaction.


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
Guru
posted Hide Post
I did change the date column to char(8) but still no luck. BTW, the reason for having multiple INSERT statements was that I extracted the data from a WebFOCUS db and generated the statements on the fly. I'll have to leave it for now and attack it in a few days.


WebFOCUS DS 8.0.06/08 DS/AS
WebFOCUS RS 8.0.08 (Linux/IBM i)
WebFOCUS Client 8.0.06 (Linux)
 
Posts: 319 | Location: Stockholm, Sweden | Registered: February 04, 2004Report This Post
Expert
posted Hide Post
Hi Håkan,

I seem to remember that you have to do something like this -
SET SQLENGINE=SQLPSTGR 
SQL SET SERVER server 
SQL
INSERT INTO table (col1, col2, col3) VALUES (12345 ,'row 1','19870814 00:00:00.000'); 
END
SQL
INSERT INTO table (col1, col2, col3) VALUES (23456 ,'row 2','19870814 00:00:00.000'); 
END
SQL
INSERT INTO table (col1, col2, col3) VALUES (34567 ,'row 3','19870814 00:00:00.000');
END
SQL
COMMIT;
END


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
Virtuoso
posted Hide Post
Well, obviously '19870814 00:00:00.000' doesn't fit in a char(8).

You have a few options:

  • specify your field as varchar(21) or char(21), or, since we've basically just thrown out the length constraint: text.
  • Truncate your string to 8 characters.
  • Format your date according to a known date format. I suspect that just changing '19870814 00:00:00.000' to '1987/08/14 00:00:00.000' would make it work as a timestamp, but I don't have a psql at hand to verify.


You could also ask database-related questions like these on the pgsql-general mailing list (pgsql-general@postgresql.org). I haven't met a tech support desk yet that comes even close to the support you get there. I know IBI wins prizes for their tech support; that's a joke in comparison.


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
Guru
posted Hide Post
Eventually I got it working. This is how:

SET HOLDLIST = PRINTONLY
SET PAGE = NOPAGE
DEFINE FILE infile
insert_string/A255 = 'INSERT INTO tablename (col1, col2, col3) VALUES (' | '''' | COL1 | '''' | ',' | '''' | COL2 || '''' || ',' || '''' || COL3 || '''' || ');' ;
END
TABLE FILE tablename
PRINT
insert_string AS ''
BY
COL1 NOPRINT
ON
COL1 SUBHEAD
"SQL"
ON
COL1 SUBFOOT
"END"
ON TABLE HOLD AS outfile FORMAT WP
END
-RUN
-*

Which gives us this file:

SQL
INSERT INTO tablename (col1, col2, col3) VALUES ('12345 ','row 1','19870814');
END

etc

and the SQL:

SET SQLENGINE=SQLPSTGR
SQL SET SERVER server
-INCLUDE outfile
-RUN

Thanks guys for your help
Håkan


WebFOCUS DS 8.0.06/08 DS/AS
WebFOCUS RS 8.0.08 (Linux/IBM i)
WebFOCUS Client 8.0.06 (Linux)
 
Posts: 319 | Location: Stockholm, Sweden | Registered: February 04, 2004Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic


Copyright © 1996-2020 Information Builders