Your where clause is guarenteeing that the else condition will never
occur.

Try this instead, it might be closer to what you want

 

 

for $entry in doc("uri")//root/entry

   let $entry1_exists = $ent...@id = $entryid]

return 

if (empty($entry1_exists))

then

 $entry1

else

$entry2

 

 

 

 

 

From: [email protected]
[mailto:[email protected]] On Behalf Of Pragya
Kapoor
Sent: Wednesday, May 19, 2010 9:37 AM
To: [email protected]
Subject: [MarkLogic Dev General] query on If else

 

Hi,

I have a query regarding the if-else statement in query.the code below
describes the query:

 

let $entryid="1"

let $entry1:="1"

let $entry2:="2"

 

for $entry in doc("uri")//root/entry

where $entry/@id = $entryid

return 

if (empty($entry))

then

 $entry1

else

$entry2

 

Now if there is a entry with entryid=1 then it gives $entry2=2 . whereas
if no entry exists with entryid=1 then it gives "no results". Please
suggest me some other way to check the if condition so that I can get
the desired result.

 

Thanks,

Pragya  

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to