Retrieval using logical operator
Author: satheesh.balu.m@gmail.com (Satheesh)
I have a problem in retrieval using the below condition:
clear/e "entity"
prop_code.entity/init = $1
pp_typ.entity/init = "S"
bp_ref.entity/init = $gemag$ | $gemmo$
retrieve/e "entity"
I want to retrieve the records from the "entity", if the bp_ref is either $gemag$ or $gemmo$. So, I am looking for both $gemag$ and $gemmo$ records after the retrieval. How can this be done?
In this present code, I could retrieve only one record.

--
Regards,
B.Satheesh Muthu Gopal,
6 Comments
Local Administrator
Hello
I am getting the error, if I use either GOLD OR or only the OR.
bp_ref.pro_sub_com/init = $concat($bmwag$,·|,$bmwmo$)
error: 1000 - Syntax error (Argument not valid)
Author: Satheesh (satheesh.balu.m@gmail.com)
Local Administrator
I got the solution from Uniface expert.
bp_ref.entity/init = "%%$gemag$%%% GOLD+|| %%$gemmo$%%%"
This works fine
Author: Satheesh (satheesh.balu.m@gmail.com)
Local Administrator
Hi,
with $concat you have to put the pipe into quotes (=$concat($x$, "Gold-|", $y$)
But be aware, you can have some side-effects if one varable is empty, especailly the second one.
so it is not nice, but to advice to put some if around it:
if ($x$ != ")
z = $x$
endif
if ($y$ != "")
if (z != "")
z = $concat( "|", $x$)
else
z = $x$
endif
field/init = z
Best regards
Thomas
Author: Thomas.Young (thomas.young@young-consulting.de)
Local Administrator
v_BP_REF=""
IF($GEMAG$!="") v_BP_REF="%%v_BP_REF%%%·|%%$GEMAG$%%%"
IF($GEMMO$!="") v_BP_REF="%%v_BP_REF%%%·|%%$GEMMO$%%%"
... ; IF there are more OR-conditions
v_BP_REF=v_BP_REF[2] ; Cut off first GOLD-| (An empty v_BP_REF will not cause any error)
clear/e "entity"
prop_code.entity/init = $1
pp_typ.entity/init = "S"
bp_ref.entity/init = v_BP_REF
retrieve/e "entity"
Or if you like $concat
v_BP_REF=""
IF($GEMAG$!="") v_BP_REF=$concat(v_BP_REF,"·|",$GEMAG$)
IF($GEMMO$!="") v_BP_REF=$concat(v_BP_REF,"·|",$GEMMO$)
... ; IF there are more OR-conditions
v_BP_REF=v_BP_REF[2] ; Cut off first GOLD-| (An empty v_BP_REF will not cause any error)
clear/e "entity"
prop_code.entity/init = $1
pp_typ.entity/init = "S"
bp_ref.entity/init = v_BP_REF
retrieve/e "entity"
Ingo
Author: istiller (i2stiller@gmx.de)
Local Administrator
Hello THomas and Hello Ingo
Thanks for your suggestion. This works fine with the below code:
bp_ref.entity/init = "%%$gemag$%%% GOLD+|| %%$gemmo$%%%"
Thanks
Satheesh
Author: Satheesh (satheesh.balu.m@gmail.com)
Local Administrator
On your original message if the $gemag$ is null, the retrieve criteria sent to the driver is like this:
select * from entity
where prop_code=$1
and pp_type ='S'
or bp_ref= $gemmo$
and not
select * from entity
where prop_code=$1
and pp_type ='S'
and bp_ref = $gemmo$
(replace $1 and $gemmo with the appropriate value)
Marco
Author: Marco (marco.aquino@dedalus.eu)