Skip to main content
Solved

how to save an attribute to an oracle date type column?

  • July 4, 2017
  • 4 replies
  • 31 views

arthy
Contributor
Forum|alt.badge.img+8

Hi,

 

 

I have an attribute (timeattribute) that I would like to save to an oracle table
  timeattribute = '2017-06-30 18:39:05'

Within a sqlexecuor, I'm doing something like: 

INSERT INTO TEST_T
  (
    OBJECTID,    
    TIMEATTRIBUTE
  )
  VALUES
  (
    @Value(OBJECTID),
   '@Value(TIMEATTRIBUTE)'
   )    

and it failed. How can I make it work?

 

FYI, the query
INSERT INTO TEST_T
  (
    OBJECTID,    
    TIMEATTRIBUTE
  )
  VALUES
  (
    @Value(OBJECTID),
   sysdate
   )   

worked perfectly within the sqlexecutor.

Thanks

Best answer by david_r

This is more of an Oracle question, you'll have to use the to_date() function. Example:

INSERT INTO TEST_T
  (
    OBJECTID,    
    TIMEATTRIBUTE
  )
  VALUES
  (
    @Value(OBJECTID),
   to_date('@Value(TIMEATTRIBUTE)', 'YYYY-MM-DD HH24:MI:SS')
   ) 
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

4 replies

ebygomm
Influencer
Forum|alt.badge.img+46
  • Influencer
  • July 4, 2017

You need to use the to_date function to insert into oracle, e.g.


david_r
Celebrity
  • Best Answer
  • July 4, 2017

This is more of an Oracle question, you'll have to use the to_date() function. Example:

INSERT INTO TEST_T
  (
    OBJECTID,    
    TIMEATTRIBUTE
  )
  VALUES
  (
    @Value(OBJECTID),
   to_date('@Value(TIMEATTRIBUTE)', 'YYYY-MM-DD HH24:MI:SS')
   ) 

david_r
Celebrity
  • July 4, 2017

Just another thing, you should be careful about manually inserting OBJECTID values unless you've queried the relevant SDE function for the next value. The issue is that the OBJECTID column is tied to an Oracle sequence and if you insert your own values without simultaneously updating the sequence you risk primary key collisions down the line.

From the ESRI FAQ: http://support.esri.com/en/technical-article/000008996

More technical info here: http://desktop.arcgis.com/en/arcmap/10.3/manage-data/using-sql-with-gdbs/next-rowid.htm


arthy
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • July 4, 2017

This is more of an Oracle question, you'll have to use the to_date() function. Example:

INSERT INTO TEST_T
  (
    OBJECTID,    
    TIMEATTRIBUTE
  )
  VALUES
  (
    @Value(OBJECTID),
   to_date('@Value(TIMEATTRIBUTE)', 'YYYY-MM-DD HH24:MI:SS')
   ) 
@david_r,

 

Thanks