Assuming I have just started the kdb server and its a clean state.
The following command works fine and creates a table [INTENTION:batch insert]
trade8 upsert flip
col1col2
col3!(1 2; 4389 4397; 2015.12.01T07:56:50 2015.12.01T07:56:58)
The following command throws a rank error- invalid rank or valence. [INTENTION:single insert]
trade8 upsert flip
col1col2
col3!(1; 4389; 2015.12.01T07:56:50)
What is the difference?And where am I going wrong?
All I want to do is make sure upsert works in case there is 1 or more row of data available.
Thanks
When ‘upserting’ a single record you shoud use enlist:
q)trade8 upsert flip
col1col2
col3!(enlist 1;enlist 4389;enlist 2015.12.01T07:56:50)
`trade8
q)trade8
col1 col2 col3
---------------------------------
1 4389 2015.12.01T07:56:50.000
Cheers
Francisco
Each value should be a list in your dict;
q)/clean state upsert
q)trade8 upsert flip
col1col2
col3!(1 2; 4389 4397; 2015.12.01T07:56:50 2015.12.01T07:56:58)
`trade8
q)/values must be enlisted - can apply to the dict rather than each value
q)trade8 upsert enlist
col1col2
col3!(1; 4389; 2015.12.01T07:56:50)
`trade8
q)/if you don’t know ahead of time whether each value is an atom or list, you can apply the below logic to your dict
q)trade8 upsert flip(),/:
col1col2
col3!(1; 4389; 2015.12.01T07:56:50)
`trade8
q)trade8 upsert flip(),/:
col1col2
col3!(1 2 3; 4389 5454 455; 2015.12.01T07:56:50 2015.12.01T07:56:50 2015.12.01T07:56:50)
`trade8
Thanks