Dash DB support for timestamp with time zone - ibm-cloud

I want to store timestamp with time zone in dashdb. I see that db2 supports data type TIMESTAMP WITH TIME ZONE for this purpose. But when I am trying to create table in dash db using this type, I am getting below error. Is this because dash db just doesn't support this type, even though db2 does. Or is there something I am doing wrong? Appreciate the help
DDL failed with message
_ Exception. _ state = 42601; error code = -104; error Message = Error for >batch element #1: An unexpected token "time" was found following "COL2" >timestamp with". Expected tokens may include: "REFERENCES".. _CODE=-104, >_STATE=42601, DRIVER=3.66.46

Related

How to upload a data including "timestamp" in postgres

I am using Postgres, but every time when I try to upload data including timestamp type to one of its columns, Postgres gives me this error message :
ERROR: date/time field value out of range: "21/04/2020 18:19"
HINT: Perhaps you need a different "datestyle" setting.
CONTEXT: COPY get_safe, line 2, column joined_getsafe_at: "21/04/2020 18:19"
how to upload the data including timestamp type successfully in Postgres?

Open JPA Query fails to execute from second time in DB2 ( because of byte[] parameter)

I am trying to execute the below query using Open JPA on DB2 database, it is executing fine for the 1st time after the server start up but it is failing from second time.
Query:
Select * from table t where t.column = ?1
The column is defined as CHAR(n) FOR BIT DATA in database and I am passing the parameter as String.
Though i pass the parameter as String, it is getting executed fine for the 1st time and afterwards giving below error.
<openjpa-2.2.3-SNAPSHOT-r422266:1715851 fatal general error> org.apache.openjpa.persistence.PersistenceException:
[jcc][1083][10403][3.69.49] Illegal conversion: can not convert from
"java.lang.String" to "byte[]" ERRORCODE=-4474, SQLSTATE=null**
I can see a similar post, below is the link, however the solution provided not working
OpenJPA query fails second time (possibly because of byte array parameter)

Cannot update the timestamp with timezone in postgres using golang

I am using golang and postgreSQL version 9.5.5 in my application. I am using "github.com/lib/pq" as my database driver to connect to the database. One of my fields have the type timestamp with timezone. I would like to update to the current time. So I used the following code:
Note:I m using beego as my framework and use orm to compute my
queries.
_, err := o.Raw("UPDATE leave SET resultdate=? WHERE leaveid=?", time.Now(), leaveResult.LeaveId).Exec()
When I execute this I'm getting the following error:
"pq: invalid input syntax for type timestamp with time zone: \"09:24:29\""
Appreciate any help.
High probability that DB expects a different date/time format. For example RFC3339. Try saving instead of time.Now() with time.Now().Format(time.RFC3339)

Getting an error inserting a timestamp using JDBC and PostgreSQL

I am new to PostgreSQL. I am trying to insert data to a table using JDBC.
One of the column values to be inserted are of following type.
2014-04-04T19:56:42.784Z (Please note the T and Z in the string).
I first used timestamp as a datatype for corresponding column. However, I am getting the following ERROR :
org.postgresql.util.PSQLException: ERROR: syntax error at or near "T19"
I then changed it to character(40) thinking might be my format is wrong. However, still getting the same error.
Later, when I removed the T and Z from the string, the error stopped. Also please note I also thought colon could be the problem. However, that is not the case through my testing.
Java code snippet
String line = 1,2014-04-04T19:56:42.784Z,456,0
String[] tempStr = strLine.split(",");
String sql = "INSERT INTO Table (A , TimeOfSess , B , C )"
+ "VALUES("+tempStr[0]+","+tempStr[1]+","+tempStr[2]+","+tempStr[3]+")";
stmt.executeUpdate(sql);
Please note I am using TimeOfSess as a character(40). For my analysis it is not important to store the time as time. Character will also work. So I am going the easy way around here.

Using the Time data type in Postgres with a Microsoft Access Front-end

I have a field in my postgres database using the time (without time zone) data type. I have a Microsoft Access front-end for the database connected using psqlODBC, which reads this field as a "Date/Time" data type.
If I try to insert something into the field through the front end, I get the following error:
ODBC - insert on a linked table "table_name" failed.
ERROR: column "column_name" is of type time without time zone but expression is of type date;
I'm assuming that access is trying to input a time stamp instead.
Basically my question is it even really possible to use the time data type with Access? Or should I just be using the timestamp datatype instead?
If you are manually typing data into a linked table then no this won't be possible at present, if you have the option of updating your table via forms or VB then you could try this to get access to produce only a time value:
TimeSerial(Hour(Now()), Minute(Now()), Second(Now()))
Otherwise as you say, it's probably a good idea to change your data type to timestamp.