Hi kamal this works fine and i included it into my overall query thanks.
So my final question on this would be

1) how to know that you have to put   " " around the query part of the
query following the condition  ?

2) how do you know that the syntax of "param"   is like    {w:w}  ...
or    by some trial / error  for my use case it was  {x:x , y:y}   ..
(since  i provided  a node x and a listy to the apoc procedure

Where is that document ? Or can i interpret that from the apoc help info ?

thanks koen

2017-12-01 7:37 GMT+01:00 Kamal Murthy <ameyas...@gmail.com>:

> Hi Koen,
>
> Here is a sample code with call apoc.do.case() procedure:
>
> MERGE (w:Winery {testval:1})
> WITH w
> call apoc.do.case([w.testval=1, "SET w.a = 'bla1', w.b = 'bla2'",
> w.testval=2, "SET node.a = 'bla3', node.b = 'bla4'"], "SET node.a = 'bla5',
> node.b = 'bla6'", {w:w}) YIELD value
> RETURN w;
>
> Syntax requires to add YIELD value and you do not have to use that 'value'.
>
> Hope this works for you.
>
> -Kamal
>
>
>
>
>
> On Thursday, November 30, 2017 at 10:47:31 AM UTC-8, koen wrote:
>>
>> Hi Kamal, thanks, i have seen this "construct" before and will test it.
>>
>> However i am still very interested to learn how to use the call
>> apoc.do.case() procedure to implement this .. i expect that the result
>> might look somewhat more straightforward (to say the least)  i.. and ideas
>> how to apply that specific procedure for this use case ?
>>
>> Thanks Koen
>>
>> 2017-11-30 19:29 GMT+01:00 Kamal Murthy <amey...@gmail.com>:
>>
>>> Hi Koen,
>>>
>>> Create a conditional statement by using FOREACH. If there’s a value for
>>> your condition then it loops once and set the property and if not no
>>> property will be set.
>>>
>>> MERGE (server:Server { name: line.`Machine Name`, uuid: call
>>> apoc.create.uuid() })
>>>
>>> FOREACH(ignoreMe IN CASE WHEN testval=1 THEN [1] ELSE [] END |
>>>
>>> SET server.a="bla1", server.b="bla2"
>>>
>>> )
>>>
>>> FOREACH(ignoreMe IN CASE WHEN testval=2 THEN [1] ELSE [] END |
>>>
>>> SET server.a="bla3", server.b="bla4"
>>>
>>> )
>>>
>>> Hope this works for you.
>>>
>>> -Kamal
>>>
>>> On Thursday, November 30, 2017 at 2:25:52 AM UTC-8, koen wrote:
>>>>
>>>> Hi kamal. thanks, thats also how i do it now.
>>>>
>>>> Maybe one other question to the community
>>>>
>>>> Is there an example of a cypher query using a *call apoc.do.case()*
>>>> procedure where you want to have multiple "condition,query" pairs and where
>>>> each "query" performs multiple operations such as a property SET operations
>>>> that are comma seperated (such as :  SET node.a = "bla1", node.b = "bla2")
>>>> .. or maybe even whole complex MATCH etc queries
>>>>
>>>> What would be the exact syntax for that -- i guess something like ..
>>>>
>>>> call apoc.do.case([testval=1,SET node.a = "bla1", node.b = "bla2"],[
>>>> testval=2, SET node.a = "bla3", node.b = "bla4"], SET node.a = "bla5",
>>>> node.b = "bla6" ??????
>>>>
>>>> This is the "help" info ...
>>>>
>>>> "apoc.do.case([condition, query, condition, query, ...], elseQuery:'',
>>>> params:{}) yield value - given a list of conditional / writing query pairs,
>>>> executes the query associated with the first conditional evaluating to true
>>>> (or the else query if none are true) with the given parameters"
>>>>
>>>> It looks like the square brackets should be around a single condition /
>>>> query pair ?   And what about the ....elseQuery ", params:{} ...    part ..
>>>> is that correct in the help info ?
>>>>
>>>> thanks koen
>>>>
>>>> ps.. are there any plans to descibe the usage (with examples) / valid
>>>> paramaters and their values etc of most apoc functions and procedures in a
>>>> little more detail and consistency ?   imho that would make using several
>>>> of these more easy and also make more clear what hey are really meant for
>>>> in some cases..
>>>>
>>>>
>>>>
>>>>
>>>> 2017-11-30 0:16 GMT+01:00 Kamal Murthy <amey...@gmail.com>:
>>>>
>>>>> Hi Koen,
>>>>>
>>>>> If one GUUID for one machine name, then you can create unique
>>>>> constraint on name property and this avoids duplicate records.
>>>>>
>>>>> CREATE CONSTRAINT ON (s:Server) ASSERT s.name IS UNIQUE;
>>>>>
>>>>> After creating this constraint, I ran MERGE (server:Server { name:
>>>>> "Test", uuid: apoc.create.uuid() } statements twice and got only one  node
>>>>> with name "Test".
>>>>>
>>>>> I do not know if this satisfies your requirement.
>>>>>
>>>>> -Kamal
>>>>>
>>>>>
>>>>> On Wednesday, November 29, 2017 at 11:48:30 AM UTC-8, koen wrote:
>>>>>>
>>>>>> H kamal thanks, that works too. i guess the original problem was due
>>>>>> to the "call" statement being there .. removing that seems to work 
>>>>>> although
>>>>>> i thought i tested that already .. it also needed small rewrite to SET 
>>>>>> the
>>>>>> uuid property to avoid duplicate record conflicts
>>>>>>
>>>>>> so for apoc functions no call stetement in front i guess
>>>>>>
>>>>>> thanks
>>>>>>
>>>>>> 2017-11-29 20:30 GMT+01:00 Kamal Murthy <amey...@gmail.com>:
>>>>>>
>>>>>>> Hi Koen,
>>>>>>>
>>>>>>> It is missing WITH line statement. Try this:
>>>>>>>
>>>>>>> USING PERIODIC COMMIT
>>>>>>> LOAD CSV WITH HEADERS
>>>>>>> FROM "file:///test.csv" AS line FIELDTERMINATOR ';'
>>>>>>> *WITH line, * *apoc.create.uuid()  as uid*
>>>>>>> MERGE (server:Server { name: line.'Machine Name`, uuid: *uid* })
>>>>>>>
>>>>>>> Or,
>>>>>>>
>>>>>>> USING PERIODIC COMMIT
>>>>>>> LOAD CSV WITH HEADERS
>>>>>>> FROM "file:///test.csv" AS line FIELDTERMINATOR ';'
>>>>>>> *WITH line*
>>>>>>> MERGE (server:Server { name: line.'Machine Name`, uuid:
>>>>>>> *apoc.create.uuid()* })
>>>>>>>
>>>>>>> I prefer the first one.
>>>>>>>
>>>>>>> -Kamal
>>>>>>>
>>>>>>> On Wednesday, November 29, 2017 at 10:45:42 AM UTC-8, koen wrote:
>>>>>>>>
>>>>>>>> Hi, when using the following simple cypher query with the apoc
>>>>>>>> function apoc.create.uuid()
>>>>>>>>
>>>>>>>> USING PERIODIC COMMIT
>>>>>>>> LOAD CSV WITH HEADERS
>>>>>>>> FROM "file:///test.csv" AS line FIELDTERMINATOR ';'
>>>>>>>> MERGE (server:Server { name: line.`Machine Name`, uuid: call
>>>>>>>> apoc.create.uuid() })
>>>>>>>>
>>>>>>>> I keep getting an error message like
>>>>>>>>
>>>>>>>> Invalid input 'p': expected 'n/N' (line 4, column 63 (offset: 158))
>>>>>>>> "MERGE (server:Server { name: line.`Machine Name`, uuid: call 
>>>>>>>> apoc.create.uuid() })"
>>>>>>>>
>>>>>>>>
>>>>>>>> I am running latest version of desktop, all procedures and
>>>>>>>> functions are active and show in the browser (when running the list
>>>>>>>> procedutes / functions command) and without the   -- uuid: call
>>>>>>>> apoc.create.uuid() --   part the query works fine
>>>>>>>>
>>>>>>>> Do i have to do / configure something so that i can use apoc
>>>>>>>> functions in queries ? Or is the query syntax not ok ?
>>>>>>>>
>>>>>>>> Thanks Koen
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>> You received this message because you are subscribed to a topic in
>>>>>>> the Google Groups "Neo4j" group.
>>>>>>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>>>>>>> pic/neo4j/3OedUQ8P2i0/unsubscribe.
>>>>>>> To unsubscribe from this group and all its topics, send an email to
>>>>>>> neo4j+un...@googlegroups.com.
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>>
>>>>>> Groeten / Best Regards,
>>>>>>
>>>>>> Koen
>>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to a topic in the
>>>>> Google Groups "Neo4j" group.
>>>>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>>>>> pic/neo4j/3OedUQ8P2i0/unsubscribe.
>>>>> To unsubscribe from this group and all its topics, send an email to
>>>>> neo4j+un...@googlegroups.com.
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> Groeten / Best Regards,
>>>>
>>>> Koen
>>>>
>>> --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "Neo4j" group.
>>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>>> pic/neo4j/3OedUQ8P2i0/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> neo4j+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>>
>> Groeten / Best Regards,
>>
>> Koen
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Neo4j" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/neo4j/3OedUQ8P2i0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> neo4j+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Groeten / Best Regards,

Koen

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to