I was wondering why such a Cypher statement was currently not possible with the latest milestone:
CREATE UNIQUE (n:Person { name : 'Andres' , title : 'Developer' })
Drop UNIQUE and it will just work.
Any reason?
You should try the MERGE keyword with neo4j 2.0. The CREATE UNIQUE will be replaced by that. If no matching node exists a new one will be created. Otherwise the already existing one is used. Please have a look at http://blog.neo4j.org/2013/05/new-milestone-release-neo4j-200-m03.html
Related
Background
We have a very old database design. The worst example is the config table. It's one row with a separate column for each value. It should be a key value pair setup (obviously). It's used everywhere in both our old legacy code, and now in our new web based code. Horrifyingly there are now over 300 columns and worse more are added every now and again.
Goal
I'd love to chuck the table in the bin and replace it with a correct key value pair. However coding time is short so I'm trying to come up with a clever way of displaying it as the old one row for the old legacy code retrieving it from a key value pair.
Attempted Solution
Ordinarily I'd use a view - but given that the best code to display it (pinched from here: https://stackoverflow.com/a/15745076/12059261) is dynamic SQL, I've come unstuck as I cannot use dynamic SQL in a view (my searching tells me that views do not allow dynamic SQL - I'm assuming this is correct?)
Table example
CurrentConfig
Key Name Address etc.
1 My Company My Address etc.
WantedConfig
ID Key Value
1 Name MyCompany
2 Address My Address
3 etc. etc.
I want to change the table from its current form to the new form, but still be able to display it as the current form to legacy code.
If the issue is displaying the new config to legacy code, then use conditional aggregation:
create view oldconfig as
select max(case when key = 'Name' then value end) as name,
max(case when key = 'Address' then value end) as address,
. . .
from newconfig;
Don't worry about dynamic SQL. There are a fixed set of columns used in the legacy code and that is what needs to go in the view. If you add new keys, they will not go in the view, but presumably the new keys are not used by the old code anyway.
You can use apply :
select tt.id, tt.Key, tt.Val
from table t cross apply
( values (1, 'Name', Name),
(2, 'Address', Address),
(3, 'etc.', etc)
) tt(id, Key, Val)
I want to update all the external ids of res.partner in system while creating partners using create() method. Also, I am not getting the functionality where the default external id name(res_partner_id) is generating.
Example :
Default generated external_id : res_partner_[id]
External id to be updated : abcd_res_partner_country_id_[id]
An External ID is an identifier for a data record. The mechanism behind this is quite simple: Odoo keeps a table with the mapping between the named External IDs and their corresponding numeric database IDs. That is the ir.model.data model.
To inspect the existing mappings, go to the Technical section of the Settings menu, and select the Sequences & Identifiers | External Identifiers menu item.
Recommended link: https://www.odoo.com/forum/help-1/question/how-to-update-external-id-50395
I'm very new to Oracle, and I've created a basic application which uses Oracle Text to perform a text search on an index.
My table structure is as follows:
[ Table: Stores ]
------------------
store_id PK
name VC2
description VC2
My description field then has an index assigned against it:
CREATE INDEX stores_desc_ctx_idx ON stores(description) INDEXTYPE IS ctxsys.context;
I've validated in SQLDeveloper that the INDEX exists under my Index tab, however when I run a query the results returned are always null, even when I can clearly see that the data in any given row matches the input string.
Let description A:
Local GAME store in Plymouth, selling all the latest titles as well as legacy ones!
let description B:
Local Morrison's store in Plymouth, selling all the food you could possibly want!
Let query:
SELECT * FROM stores WHERE contains(description, 'GAME') > 0;
I would expect the result of the query to return description A, however no results are returned...what am I doing wrong here?
For future users who face a similar problem.
SQLDeveloper has somehow invalidated my INDEX, I simply navigated to the INDEX tab, right clicked and selected "Rebuild". Doing this re-validated the INDEX and the code now works as expected.
You can specify when the full text index will be updated by the DB system using the "Parameters" syntax with the "Create index" statement.
For example the following statement creates a full text index that is updated after each commit.
CREATE INDEX stores_desc_ctx_idx ON stores(description) INDEXTYPE IS ctxsys.context PARAMETERS ('SYNC(ON COMMIT)');
See the oracle docs for all possible "SYNC" options
I have duplicated a new group in OpenERP 6.1.1 .
Now I need to create an external reference id for it since I need to refer it in a view.
Normally, I guess, I should have created the group using an xml file but now I have already been using the group and assigned users to it so I don't wan't to redo the whole thing again.
Is there a simpler way ? Please suggest. Thanks in advance.
You can manually insert a row in the table ir_model_data. name is the external id and res_id is integer id. Other required fields are module and model.
According to the REST philosophy, a PUT request should update the resource at a URL if it exists, and create it if it doesn't exist. So in other words, if I use the following URL:
PUT http://server/item/5
If an Item exists with an ID of 5, it will be updated. If an Item doesn't exist with an ID of 5, a new Item will be created with an ID of 5.
However, I'm using NHibernate for persistence, and I mapped my IDs as Identity. This means that no matter what value I assign the ID, NHibernate will replace it with its own when I save a new Item.
How do I get NHibernate to save an Item with the ID that I assign it, without changing the ID mapping to Assigned?
If you use Identity, the DB won't allow you to enter a value.
That said, if your DB has some special syntax to allow inserting with explicit values in Identity fields, you can implement your own generator, which I guarantee will be error prone, hard to debug, and not very useful. But it's possible.
Study everything in https://nhibernate.svn.sourceforge.net/svnroot/nhibernate/trunk/nhibernate/src/NHibernate/Id and start creating your Frankenstein :-)