After looking around the msgboard, I did not readily find a function to create sql::arguments from a dot variable or property variable. The great team from Alpha helped me out with a solution. I thought this might be something that would be useful for many so here it is.
variable example as follows:
Patients.firstname = "Max"
Patients.lastname = "Hammond"
Patients.insurance.policy1 = "anthem"
Patients.insurance.policy2 = "united"
Patients.provider = 2
'xBasic as follows:
dim args as sql::arguments
makeArgs(patients,args)
showVar(args.xml)
******* begin note
This will create XML that looks like this.
<SQLArguments>
<SQLArgument>
<Name>firstname</Name>
<Data Type="C">max</Data>
<IsNull Type="L">0</IsNull>
<Usage>Input</Usage>
</SQLArgument>
<SQLArgument>
<Name>lastname</Name>
<Data Type="C">Hammond</Data>
<IsNull Type="L">0</IsNull>
<Usage>Input</Usage>
</SQLArgument>
<SQLArgument>
<Name>insurance_policy1</Name>
<Data Type="C">anthem</Data>
<IsNull Type="L">0</IsNull>
<Usage>Input</Usage>
</SQLArgument>
<SQLArgument>
<Name>insurance_policy2</Name>
<Data Type="C">united</Data>
<IsNull Type="L">0</IsNull>
<Usage>Input</Usage>
</SQLArgument>
<SQLArgument>
<Name>provider</Name>
<Data Type="N">2</Data>
<IsNull Type="L">0</IsNull>
<Usage>Input</Usage>
</SQLArgument>
</SQLArguments>
******* end note
'then xbasic as follows to create the var that will be used for the "name" of the argument recursively (to look beyond the "."):
function makeArgs as v (p as p, args as sql::arguments )
dim props as c
props = properties_enum(p,"r")
showvar(props)
***** begin note
This creates the enumerator for the arg that looks like this
firstname
lastname
insurance.policy1
insurance.policy2
provider
***** end note
'then loop over args.add with the stritran to replace the "." with "_" so it creates a valid arg name and add values from pp to populate the args.add.
for each pp in props
args.add(stritran(pp.value,".","_"),eval("p." + pp.value))
next
end function
I hope this helps someone! It sure helped me.
Thanks!
variable example as follows:
Patients.firstname = "Max"
Patients.lastname = "Hammond"
Patients.insurance.policy1 = "anthem"
Patients.insurance.policy2 = "united"
Patients.provider = 2
'xBasic as follows:
dim args as sql::arguments
makeArgs(patients,args)
showVar(args.xml)
******* begin note
This will create XML that looks like this.
<SQLArguments>
<SQLArgument>
<Name>firstname</Name>
<Data Type="C">max</Data>
<IsNull Type="L">0</IsNull>
<Usage>Input</Usage>
</SQLArgument>
<SQLArgument>
<Name>lastname</Name>
<Data Type="C">Hammond</Data>
<IsNull Type="L">0</IsNull>
<Usage>Input</Usage>
</SQLArgument>
<SQLArgument>
<Name>insurance_policy1</Name>
<Data Type="C">anthem</Data>
<IsNull Type="L">0</IsNull>
<Usage>Input</Usage>
</SQLArgument>
<SQLArgument>
<Name>insurance_policy2</Name>
<Data Type="C">united</Data>
<IsNull Type="L">0</IsNull>
<Usage>Input</Usage>
</SQLArgument>
<SQLArgument>
<Name>provider</Name>
<Data Type="N">2</Data>
<IsNull Type="L">0</IsNull>
<Usage>Input</Usage>
</SQLArgument>
</SQLArguments>
******* end note
'then xbasic as follows to create the var that will be used for the "name" of the argument recursively (to look beyond the "."):
function makeArgs as v (p as p, args as sql::arguments )
dim props as c
props = properties_enum(p,"r")
showvar(props)
***** begin note
This creates the enumerator for the arg that looks like this
firstname
lastname
insurance.policy1
insurance.policy2
provider
***** end note
'then loop over args.add with the stritran to replace the "." with "_" so it creates a valid arg name and add values from pp to populate the args.add.
for each pp in props
args.add(stritran(pp.value,".","_"),eval("p." + pp.value))
next
end function
I hope this helps someone! It sure helped me.
Thanks!