cancel
Showing results for 
Search instead for 
Did you mean: 

Problems inserting date values in Oracle 10g

Former Member
0 Kudos

Hi All,

I'm having SERIOUS problems trying to insert a simple date value in my oracle.

I did this one million times before in xMII 11.5, but now it appears that doesn't work anymore!

Here are some info:

Data Server Config:

Date Prefix: TO_DATE('

Date_Sufix: ', 'MM/DD/YYYY HH24:MI:SS')

Internal Date Format: yyyy-MM-dd HH:mm:ss

In my Query Template:

Date and Time Format: MM/dd/yyyy HH:mm:ss

In my Transaction

Parameter: datefromxmlformat(datenow, "MM/dd/yyyy HH:mm:ss")

I also tried change the parameter to datenow, no success.

I tried to change the Query Template format, no success.

Finally, I tried to change my Date prefix & sufix, no success too.

I really don't know what else I can do. I would appreciate some help.

PS: I'm using xMII 12.0.1 with ojdbc14.jar

Thanks in advance.

Pedro Sena

Accepted Solutions (1)

Accepted Solutions (1)

jcgood25
Active Contributor
0 Kudos

Pedro,

The Data Server config for InternalDateFormat should be: MM/dd/yyyy HH:mm:ss

This is because it is used in conjunction with the DatePrefix and DateSuffix whenever you use the DateColumn or the [SD] and [ED] tokens in a query template.

If you are inserting a date field with an arbitrary parameter (not a date token like above) then you need to use the TO_DATE wrapper pieces around your date field string.

The DateFormat in the query template controls the format of the StartDate and EndDate buttons in the applet toolbar if using an iChart/iSPCChart/iGrid and a time sensitive query, but when you build the string for an insert parameter you must manage the whole format yourself.

If you really just want datenow and the xMII server time is sufficient for your insert query then you can leverage the Data Server config settings like: INSERT INTO TABLE VALUES([ED)

This way the default query template time settings will use 'now' for the end date of the query and when the string is sent to Oracle it will actually look like:

INSERT INTO TABLE VALUES(TO_DATE('10/19/2007 08:41:00', 'MM/DD/YYYY HH24:MI:SS'))

Regards,

Jeremy

Former Member
0 Kudos

Hi Jeremy,

I was looking for a solution that doesn't include put a TO_DATE in every date field of my query but I think that this is not possible.

I changed my Internal Date Format like you said and my query template to:

INSERT INTO OI(TESTE) VALUES (TO_DATE('[Param.1]', 'MM/DD/YYYY HH24:MI:SS'))

and now its working...

It's not exactly what I wanted but at least works...

Thanks

jcgood25
Active Contributor
0 Kudos

Pedro - please re-read the last two sentences in my initial response to your post.

You can set the StartDate property of the query action (use the string format the matches the DateFormat or take a look at the QueryStartDate link in the SQLQuery action and notice that it uses the XML date format) and then use [SD] in your insert statement. The dateprefix and datesuffix handling will be done automatically.

To learn better how these work you can just build a simple select statement in a fixed query and see the responses, then turn it into the desired INSERT statement.

Regards,

Jeremy

Former Member
0 Kudos

Ahhh!

Now I understood, I can use [SD] and [ED] in my INSERT query, this way the xMII will handle any conversion needed.

But supposing that I need more than two date fields and should be able to insert null values on these field, what should I do ?

Thanks Jeremy

jcgood25
Active Contributor
0 Kudos

Then you will have to use the approach using [Param.x] with the TO_DATE() wrapper and handle the null aspects yourself.

Answers (0)