This project is read-only.

Fail to insert datetime and ForeignKey

Jan 15, 2011 at 3:53 AM
Edited Jan 15, 2011 at 12:09 PM

Hi,

I failed to insert the datetime and Foreign key to KDB....

1. create table test1 with datatime field in Q
q) test1:([]time:`datetime$();price:`float$();size:`int$())

 

Result 1.a
client.ExecuteOneWayNonQuery("`test1 insert(`2003.03.23T09:10:35.000;93.5;300)");   --> ok

 

Result 1.b

object[] x = {  DateTime.Now, 93.5, 300 };
client.ExecuteOneWayNonQuery("insert", "test1", x);      --> q)'type

2. create table test2 contain FK of sym in Q
sym:([sym:`symbol$()]exch:`symbol$();indust:`symbol$();subindust:`symbol$())
test2:([]sym:`sym$();price:`float$();size:`int$())

Result 2.a
client.ExecuteOneWayNonQuery("`test2 insert(`IBM;93.5;300)");        --> ok

 

Result 2.b

object[] y = {  "`IBM", 93.5, 300 };
client.ExecuteOneWayNonQuery("insert", "test2", y);    --> q)'cast

Apr 5, 2011 at 9:18 AM

Hi!

What concerns the first problem, as far as i remember datetime should not be used actively in kdb+ after some specific version.

Timespan should be used on kdb+ side. I think the .Net DateTime object comes into KDB+ as timespan, thus causing "type" exception.

What concerns the second task, please try to accomplish the task directly in kdb+: call insert as function with table name as the first param and values array as the second.

In my opinion the problem may be hiding in KDB+.

Thanks,

Aliaksandr.