[Solved] A bit of help with get column by name

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
User avatar
misitu
Posts: 104
Joined: Mon Dec 16, 2013 5:34 am
Location: Trujillo - La Libertad - Perú

[Solved] A bit of help with get column by name

Post by misitu »

Hello!

I'm aware of the technique of rowset and have used it to read database data using RowSet.getstring(N).

I'm sure I've seen somewhere that it's possible to retrieve column data by column name. This is more maintainable, obviously.

Having a bit of a head-wall-bang issue here trying to locate said stuff in the documentation, AOO, Pitonyak, google, stackoverflow etc.

So, any tips or bits of code would be welcome!

to recap: retrieve database rows and process each row using column name

Thanks in advance
David
Last edited by misitu on Wed Nov 16, 2016 2:41 am, edited 1 time in total.
OpenOffice 4.1.1
HSQLDB 2.3.4
Windows 7 HP / Windows 10
OOBasic
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: A bit of help with get column by name

Post by Villeroy »

Why don't you use MRI?
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
misitu
Posts: 104
Joined: Mon Dec 16, 2013 5:34 am
Location: Trujillo - La Libertad - Perú

Re: A bit of help with get column by name

Post by misitu »

Because I do not understand how using MRI will help answer my original question.

Thanks...
OpenOffice 4.1.1
HSQLDB 2.3.4
Windows 7 HP / Windows 10
OOBasic
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: A bit of help with get column by name

Post by Villeroy »

MRI shows clearly that there is no method to get a column by name. There is a method findColumn(name) to get the column number by name. Nobody knows all that shit by heart. We all look it up with MRI or Xray.
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
misitu
Posts: 104
Joined: Mon Dec 16, 2013 5:34 am
Location: Trujillo - La Libertad - Perú

Re: A bit of help with get column by name

Post by misitu »

Why didn't you say that in the first place ...

My question was to be able to reference a column by name, which you just told me is possible.

What I would like to do is return my resultset "select * from ViewXXXXXX" and take each column and use as a field master.

Obviously, this can be done by getstring(n), and equally obviously I can structurally link n with its name using

Code: Select all

	col=Result.Columns.getByIndex(I)
	colLabel = String(col.DisplaySize, "*")
	LSet colLabel = CStr(col.Name)
This is all possible. I'll have to go this way but was hoping for something a bit more elegant, taking the database column name and using that as part of the field master name structure.

Before we start talking templates again, I can't go down that road because it hard codes the registered name into the database name part of the field master, and as I want to substitute that at run time that won't fly. In fact it won't even hatch.
 Edit: Yup. End of Road. It seems after all that resultset..getstring(N) is the simplest way to go. Thanks. 
David
OpenOffice 4.1.1
HSQLDB 2.3.4
Windows 7 HP / Windows 10
OOBasic
Post Reply