how to set parameter in sql query ?

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

how to set parameter in sql query ?

Suganda
hi all,

i saw the example xforms-sql-address-book

i want to ask , how do i  change the query in service-get.xpl

from this query

"select * from orbeon_address_book"

into this query

"select * from orbeon_address_book where first in ( <sql:param type="xs:string" select="/form/first"/> ) "

because when i tried to use second syntax mysql , i got strange behaviour that return null result set
what i want is like this

when after i fill in data in the add part, my current data will be displayed , NOT all data that are retrieved like this example

hmm any help from expert ?

thanks in advance,
suganda:)

Reply | Threaded
Open this post in threaded view
|

Re: how to set parameter in sql query ?

Erik Bruchez
Administrator
Suganda,

When the SQL processor runs, the sql:param element will be replaced with
the value of the XPath expression applied to the input document to the
SQL processor's "data" input.

Am I understanding well that what you are trying to get is the first
result from the table? If so, try something like:

   select top 1 * from orbeon_address_book

-Erik

Suganda wrote:

> hi all,
>
> i saw the example xforms-sql-address-book
>
> i want to ask , how do i  change the query in service-get.xpl
>
> from this query
>
> "select * from orbeon_address_book"
>
> into this query
>
> "select * from orbeon_address_book where first in ( <sql:param
> type="xs:string" select="/form/first"/> ) "
>
> because when i tried to use second syntax mysql , i got strange behaviour
> that return null result set
> what i want is like this
>
> when after i fill in data in the add part, my current data will be displayed
> , NOT all data that are retrieved like this example
>
> hmm any help from expert ?
>
> thanks in advance,
> suganda:)
>
>
>

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: how to set parameter in sql query ?

Suganda
Hi Erik,

thats not what i mean....

ok i explain the scenario to you

in current example application sql-book address , after we create book records, and press add button , all of data will be display right because after adding submission , in the view.xhtml will also call get-submission which is retrieve the result set using "select * from ........"

my scenario is quite same like the book scenario except instead of displaying all data , i would like to display the data that user has inputted.

for example there are 5 column (b,c,d,e,f) in table A which b is ID or primary key

then i added data (fill in 5 fields) using xforms (view.html) calling add-submission.xpl .
after that i want to pass the id of that data , so that when i call get-submission.xpl the query will not retrieve all data in database using "select * from A" , but the query will retrieve the data based on last ID using "select * from A WHERE b= ?" where ? is the id parameter

so after press adding , i want to show the data that user added not the whole data from database

hmmm i get stuck this scenario almost 1 week before i posted to the forum
i already try to passing parameter, but why the results still not work properly ?

confuse....

hopefully , you can give me some clues

thanks in advance,
suganda:)
 
Erik Bruchez wrote
Suganda,

When the SQL processor runs, the sql:param element will be replaced with
the value of the XPath expression applied to the input document to the
SQL processor's "data" input.

Am I understanding well that what you are trying to get is the first
result from the table? If so, try something like:

   select top 1 * from orbeon_address_book

-Erik

Suganda wrote:
> hi all,
>
> i saw the example xforms-sql-address-book
>
> i want to ask , how do i  change the query in service-get.xpl
>
> from this query
>
> "select * from orbeon_address_book"
>
> into this query
>
> "select * from orbeon_address_book where first in ( <sql:param
> type="xs:string" select="/form/first"/> ) "
>
> because when i tried to use second syntax mysql , i got strange behaviour
> that return null result set
> what i want is like this
>
> when after i fill in data in the add part, my current data will be displayed
> , NOT all data that are retrieved like this example
>
> hmm any help from expert ?
>
> thanks in advance,
> suganda:)
>
>
>


--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/


--
You receive this message as a subscriber of the ops-users@ow2.org mailing list.
To unsubscribe: mailto:ops-users-unsubscribe@ow2.org
For general help: mailto:sympa@ow2.org?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: how to set parameter in sql query ?

Alessandro Vernet
Administrator
Suganda,

On 11/1/07, Suganda <[hidden email]> wrote:
> for example there are 5 column (b,c,d,e,f) in table A which b is ID or
> primary key
>
> then i added data (fill in 5 fields) using xforms (view.html) calling
> add-submission.xpl .
> after that i want to pass the id of that data , so that when i call
> get-submission.xpl the query will not retrieve all data in database using
> "select * from A" , but the query will retrieve the data based on last ID
> using "select * from A WHERE b= ?" where ? is the id parameter

So you will need to post an instance that contain this "b" value to
the XPL that does the query, and then use a <sql:param
type="xs:string" select="/path/to/b"/> that points to this "b". Does
this make sense? Do you already have code that calls the XPL passing
the instance that contains the "b"?

Alex
--
Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise
http://www.orbeon.com/


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws