Am Donnerstag, den 09.02.2006, 09:36 +0100 schrieb Frank Schönheit - Sun
Microsystems Germany:
> Hi Marc,
Hello Frank,
> > Hi,
> >
> > I'm searching an API for changing the appearance of values in self built
> > strings for use in SQL statements to the right form.
> > ...
> > If I want to make SQL strings myself and fire them from OO.o to a
> > connected DB this difference has to be detected and handled. At the
> > moment I have to ask the databases metadata for every single field what
> > type it is, have in mind what types are possible (decimal, float,
> > currnecy, ...) and do the right thing. That is a tedious and error prone
> > task.
> >
> > How is it done inside OO.o and is there a publicly available
> > service/inteface for shrinking my code?
>
> Inside OOo, this kind of string creation is deep inside some parser
> code, and not available as UNO service. At a low level, the
> XLocaleData.getLocaleItem might at least help you in obtaining the
> proper separators.
Okay, I'll have a look at it (although it'll take some time).
> At a higher level, the XSingleSelectQueryComposer, in particular its
> appendFilterByColumn method, are the only way to let an UNO service
> generate the string representations. However, this contradicts your wish
> to create the SQL strings yourself, it seems.
Yes, I do use a QueryComposer for quoting strings and identifiers the
right way, as you kindly told me. :)
Do you see any sense in making a helper service concentrating on this
kind of tasks?
Another use case is filling a Rowset for posting to the db. In a
Calc-makro I'm using something similar and have to carry it around as a
library:
' Umwandlung des Werts aus der Zelle in den passenden Spaltentyp
' fehlende Typen bitte ergänzen!
sub doUpdateValue(aRowSet as object, colnum as integer, ntype as
integer, value)
select case ntype
case com.sun.star.sdbc.DataType.BIT
aRowSet.updateBoolean(colnum, value)
case com.sun.star.sdbc.DataType.INTEGER, _
com.sun.star.sdbc.DataType.SMALLINT, _
com.sun.star.sdbc.DataType.TINYINT, _
com.sun.star.sdbc.DataType.BIGINT
aRowSet.updateInt(colnum, value)
case com.sun.star.sdbc.DataType.FLOAT
aRowSet.updateFloat(colnum, value)
... and so on and on and on ...
So I think demanding a "locale converter service" from and to the
current locale for base would be a good thing.
What do you think?
What do other script programmers think?
Regards,
Marc
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]