need help with query sql:param null

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

need help with query sql:param null

fritz
Hi all,
I'm trying to implement through database service a query were inside parameter is present the null  boolean switch.

insert into rooms-res
(id-res,date-res)
 values
(<sql:param type="xs:string" select="" null="normalize-space(.......) = ''"/>,
 <sql:param type="xs:dateTime" select="" null="normalize-space(.......) = ''"/>);

Instead of dots I've used @select, ./select, ../select, /id-res, /query/id-res and others
but I'm not able to get it working and there is no error in log.
Can someone help me with this?

I need null values for first field because of  key constraint and second for optional field ( there are other fields i've removed).


Fritz
Reply | Threaded
Open this post in threaded view
|

Re: need help with query sql:param null

fritz
No idea anyone?
Reply | Threaded
Open this post in threaded view
|

Re: need help with query sql:param null

Erik Bruchez
Administrator
What if you write, for testing:

     null="true()"

Does it work?

What about:

    null="normalize-space(…) = ''"

-Erik
Reply | Threaded
Open this post in threaded view
|

Re: need help with query sql:param null

fritz
Hi Erik,
sorry for late answering , I think I've not been clear in expose the probem.
If I use <sql:param type="xs:dateTime" select="" null="normalize-space(.......) = ''"/>);
when I pass a parameter ( and I see in inspector instance is correct valorized ) the query always inserts null,
is like I cant address correctly to the parameter.
I've uploaded a sample  to better explain my intentions, if you enter a value in 'IN' input and click on the without
button you get the value in 'OUT'.
If I use the with button I always get null value and not the value from parameter.

Test.xml
Reply | Threaded
Open this post in threaded view
|

Re: need help with query sql:param null

Alessandro  Vernet
Administrator
Hi,

I'm trying to understand what you'd like to do with the expression inside the null="...". I imagine you'd like to set the date-time to NULL in the database based on some condition. The value for the date comes from your input. Would you also like to test on that input, and if the input field is empty set the value to NULL?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: need help with query sql:param null

fritz
Yes Alex is it right, but now I'm getting null values in the db even if the field is populated  with a value.
Reply | Threaded
Open this post in threaded view
|

Re: need help with query sql:param null

Erik Bruchez
Administrator
Do you actually use:

    select=""

without any content in the attribute? The `select` attribute is the one selecting a value, so it should not remain blank.

-Erik
Reply | Threaded
Open this post in threaded view
|

Re: need help with query sql:param null

fritz
No Erik,
when I look at the query instance the select actribute is valorized with field data, I think
my problem is I'm not  instancing null="normalize-space(.......) the right way and so exit always null.
I don't know if in null="normalize-space(.......) I shoud put something like
instance('fr-form-instance')/section-1/field1 or  /sql:query/sql:param/@select etc.
I've done several test but maybe I've missed the right one.

Fritz
Reply | Threaded
Open this post in threaded view
|

Re: need help with query sql:param null

Erik Bruchez
Administrator
Ok. So the result of the expression in the `null` attribute must be a boolean.

Expressed in high-level terms, what is the condition that should trigger a null value?

-Erik
Reply | Threaded
Open this post in threaded view
|

Re: need help with query sql:param null

fritz
my parameter='' , I've tried /sql:query/sql:param='' but had not worked.