0

I have a problem with timestamp field in postgresql database its

scheduled_time timestamp without time zone,

And i would like to get posibility to set it to null on update. But its still

ERROR: column "scheduled_time" is of type timestamp without time zone but expression is of type bytea Wskazówka: You will need to rewrite or cast the expression.

I tried to set it null, i tried to set it empty string "" i tried to find solutions at internet, i know that its work when i set it at pgadmin to null, but when i set as a parameter in

 queryString = "UPDATE upload SET additional_info=:additionalInfo, customer_id=:customerId, scheduled_time=:scheduledTime WHERE upload_id=:uploadId"; 
        final Query query = entityManager.createNativeQuery(queryString);   
        query.setParameter("scheduledTime", upload.getScheduledTime());
        more setParameters ....
        query.executeUpdate();

Its still get me that message with type bytea. Can you tell me how to solve that?

I will do it by checking if scheduled is null. When true, i will make

UPDATE upload SET additional_info=:additionalInfo, customer_id=:customerId, scheduled_time= NULL WHERE upload_id=:uploadId

else i will

UPDATE upload SET additional_info=:additionalInfo, customer_id=:customerId, scheduled_time=:scheduledTime WHERE upload_id=:uploadId

couse i didn't find any normal solution.

9
  • What does upload.getScheduledTime() return? Commented Feb 8, 2016 at 8:33
  • i tried empty string, and null . I guess its set on query "null", but it should set null . Commented Feb 8, 2016 at 8:38
  • what kind of value does upload.getScheduledTime() return if its "null"? you will need to use an "if" condition to pass null value query.setParameter("scheduledTime",null) Commented Feb 8, 2016 at 8:42
  • i.gyazo.com/c645f0f6aed687a22f1627f7c2ba6324.png i tried to set it as , null ) its still not working. i.gyazo.com/e4da005bfe9e991656d33f31f482086f.png Commented Feb 8, 2016 at 8:47
  • What is the date format upload.getScheduledTime() return? Commented Feb 8, 2016 at 8:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.