On Thu, 2012-03-01 at 14:11 +0000, Mark Stanton wrote:
> Hi Fernand,
>
> > so "?" works for native SQL
> > ":" works for OO-SQL
>
> I'm not sure if you are asking me a question or making a statement.
> What you are saying is not what I was saying, I'm not certain it is right,
> I don't think it is. I may be wrong :-)
1) For all datasource types Base supports - When a query definition is
parsed by LibreOffice before being sent to the database engine, allowing
for named parameters and nested queries, the syntax is :<parameter_name>
When the LibreOffice query definition is run a dialog box will prompt
the user for the parameter value(s), displaying the string
<parameter_name>.
select * from foo where bar = :MyBar
When run will prompt the user using the string "MyBar". All input by the
user is treated as a string and then converted the appropriate data
type.
2) For all datasource types Base supports - When using a basic script
you can create a parameterized query also, by using a prepared
statement. In this case the parameters are not named and are designated
by a ? character. You can assign values to the parameters by parameter
count (or place) starting with 1. You also must use setxxx functions
appropriate for the data type.
So - lets assume the table foo with structure:
id - integer
name - text
Then in the basic script you might use something like this
pstmt = <connection object>.prepareStatement("insert into foo
values( ?, ?)")
pstmt.setInt(1, 100)
pstmt.setString(2, "John Doe")
Best wishes,
//drew
--
For unsubscribe instructions e-mail to: [email protected]
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted