[Solved] Difference in 2 ways of getting data from table

The Application Programming Interface and the OASIS Open Document Format

[Solved] Difference in 2 ways of getting data from table

Postby yaiban » Wed Jul 03, 2013 1:45 pm

Hello, sorry for the odd headline, was difficult to write down any helpful information when so short on characters. I am out of curiousity wondering about the difference between these two methods of getting the data from a form's underlying database-table.

oForm.getString(oForm.findColumn("a_database_column"))
and
oForm.columns.getByName("a_database_column").string

Is there any difference?

Thankful for replies,
yaiban
Last edited by yaiban on Fri Jul 05, 2013 7:36 am, edited 1 time in total.
Apache OpenOffice 3.4.1 on Linux Mint 14
yaiban
 
Posts: 59
Joined: Fri Jun 15, 2012 8:35 am

Re: What difference between two ways of getting data from ta

Postby Villeroy » Wed Jul 03, 2013 2:09 pm

The string displayed by a form control and the field value should be the same for any VARCHAR field. For any other data type, the displayed string has nothing to do with the field value.

1.234,99 (German)
1,234.99 (English)
1'234.99 (Swiss)
TRUE (Englisch boolean)
WAHR (German boolean)
123499% (percent)
or even: 1903-05-18 23:45:36 (day #1234 plus .99 of a day as ISO date-time)

are textual representations of the very same field value in a formatted form field.

In most cases the display string of a control must not be used as a programmatic value. Exception: You want to copy the formatted representation into a message to the user for mere display purposes. You must not try to calculate with formatted strings.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
 
Posts: 29693
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: What difference between two ways of getting data from ta

Postby yaiban » Wed Jul 03, 2013 2:26 pm

Thanks for replying. Which is field value and which is the string displayed by the form, of the two I mentioned above?
Apache OpenOffice 3.4.1 on Linux Mint 14
yaiban
 
Posts: 59
Joined: Fri Jun 15, 2012 8:35 am

Re: What difference between two ways of getting data from ta

Postby Villeroy » Wed Jul 03, 2013 3:27 pm

As a programmer you know the difference between data and information, between bytes on one side and numbers, strings etc. on the other.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
 
Posts: 29693
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: What difference between two ways of getting data from ta

Postby yaiban » Wed Jul 03, 2013 3:40 pm

Oh yes of course, perhaps I stated the question in a bad way. What I was asking was how the two ways of retrieving data work. To make it simple, does oForm.getString(oForm.findColumn("a_database_column")) retrieve the back-end data from the database, or the front-end data stored in the control? Does oForm.columns.getByName("a_database_column").string retrieve the back-end data stored in the database or the front-end data stored in the control?

As always, thankful for replies,
yaiban
Apache OpenOffice 3.4.1 on Linux Mint 14
yaiban
 
Posts: 59
Joined: Fri Jun 15, 2012 8:35 am

Re: What difference between two ways of getting data from ta

Postby Villeroy » Wed Jul 03, 2013 4:45 pm

Now I see more clearly what your problem is. The API has no fields of certain types.
Every field has a method to query a string, an integer, a blob, a date etc. and using the right method for the type of field is completely up to you. When you query a string from a non-VARCHAR you get some string representation which seems to be SQL compatible. Under a German locale getString(column_index) returns ISO date-times, decimals with points, booleans as "1" and "0". Under any circumstance the return value is a string.
When I query getTime(column_index) I get a com.sun.star.util.Time struct which is (0,0,0,0) for VARCHARs and my office crashes when I try to query the time from other interesting field types.

The only thing you can rely on is the type of return value.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
 
Posts: 29693
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: What difference between two ways of getting data from ta

Postby yaiban » Thu Jul 04, 2013 7:47 am

Yes, I know that you can ask for different variable types and I've experienced excessive crashes when I try to query something other than the type of the column which the control is bound to. Please ignore the data-types, I know it's just binary code anyway. It's not how I interpret the ones and zeroes, it's from where I get them.

1. The back-end database has values for all columns, it has the actual data.
2. The front-end, openoffice, or the form rather, has values for all columns.
Now, am I right that 1's and 2's values may differ? There is an inconsistency because otherwise I would not be able to change any data in the front-end. The front-end sometimes copies the values in all it's columns to the back-end, and vice versa. This is correct, right? I am wondering, whether oForm.getString(oForm.findColumn("a_database_column")) would get me the data from 1., the mysql back-end, or from 2., openoffice.

Sorry if I have been unclear. I haven't been studying or speaking much English since I left upper secondary :)

Thankful for replies,
yaiban
Apache OpenOffice 3.4.1 on Linux Mint 14
yaiban
 
Posts: 59
Joined: Fri Jun 15, 2012 8:35 am

Re: What difference between two ways of getting data from ta

Postby RPG » Thu Jul 04, 2013 9:03 am

Hello

As far I understand you, you need the getbytes method.

http://www.openoffice.org/api/docs/comm ... olumn.html

I have never used it.

Romke
LibreOffice 6.3.3.2 on openSUSE Leap 15
RPG
Volunteer
 
Posts: 2204
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: What difference between two ways of getting data from ta

Postby yaiban » Thu Jul 04, 2013 9:42 am

Hello Romke
Thank you but I do not need a way to obtain the data in a specific way, I do not care if the data is interpreted as a string, int, bytes, float, double, date, long long int or whatever. What I want to know is WHERE the data is taken from. The data can be found in two places, the mysql database, and the OOO-base-form.

The two described methods oForm.getString(oForm.findColumn("a_database_column")) and oForm.columns.getByName("a_database_column").string, do they get the data from the form or from the mysql-database?
Apache OpenOffice 3.4.1 on Linux Mint 14
yaiban
 
Posts: 59
Joined: Fri Jun 15, 2012 8:35 am

Re: What difference between two ways of getting data from ta

Postby RPG » Thu Jul 04, 2013 10:02 am

Hello

As far I understand all: You get data only from the API calls and never from the back end.
yaiban wrote:The two described methods oForm.getString(oForm.findColumn("a_database_column")) and oForm.columns.getByName("a_database_column").string, do they get the data from the form or from the mysql-database?

Maybe Villeroy can make it more clear to you if you do not understand the link.

Romke
LibreOffice 6.3.3.2 on openSUSE Leap 15
RPG
Volunteer
 
Posts: 2204
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: What difference between two ways of getting data from ta

Postby Villeroy » Thu Jul 04, 2013 10:43 am

RPG wrote:Maybe Villeroy can make it more clear to you if you do not understand the link.

Romke

I try my very best to avoid all macro coding. As a regular form user, I think that form data reflect table data at the time of the last refresh/insert/update/delete.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
 
Posts: 29693
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: What difference between two ways of getting data from ta

Postby RPG » Thu Jul 04, 2013 3:50 pm

Hello

When you want write macro then you need to understand how the services are working. You need to understand how a services can exported several interfaces.

It is possible you are not working with form data but with control data.

Macro programming is not easy. I have the idea when you need a lot of macros then possible you use the wrong tool.

I think users should first try to understand how OOo is working. In your case what you can do with normal documents. When you want work with a database and forms then you need a good understanding of all the things about what you can do with forms. Maybe more important is about what you can do not with forms. When you have important things to program in macros, I have the idea it indicates you should not use OOo.

Romke
LibreOffice 6.3.3.2 on openSUSE Leap 15
RPG
Volunteer
 
Posts: 2204
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: What difference between two ways of getting data from ta

Postby yaiban » Fri Jul 05, 2013 7:35 am

First and foremost, thank you for the answers, I think that the methods described above both return the data from the form, and I'll mark this as solved.

What I am doing is a fairly large project, with quite some data redundancy. Simplicity for the user has been the great goal, as well as functionality. This has required quite extensive macro use. Why is it wrong to use macro programming? Even if it was very difficult to do, when it works everything worked like a charm. You can make the computer do most work for YOUR users. I first wanted to do everything from scratch, preferably in java or perhaps python or cpp, but openoffice is even though some of its bugs (or peculiar logic) a good api. I am nearing an end and has recieved alot of help on these forums, and you have replied to alot of my posts Romke, for which I am grateful :)
Apache OpenOffice 3.4.1 on Linux Mint 14
yaiban
 
Posts: 59
Joined: Fri Jun 15, 2012 8:35 am


Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 3 guests