This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Three issues: decimal places, rename, saving query

Tags: None
(comma "," separated)
wmae
Registered Member
Posts
32
Karma
0
I have 3 issues that are currently bothering me. Neither of them are critical and I have been able to work around them, for the most part.

1. How does one set the decimal places in reports? I can do so in tables but they don't carry over into reports. Currency values just don't look right with only one decimal place.
2. How does one change the name of a database so that even Kexi recognizes it. Currently, I'm able to change names but only KDE recognizes it(outside of Kexi). Within Kexi, it reverts back to the old name.
3. I am not able to save a query if I create it in SQL mode. I have to partially create it in Design mode, save it, then go into SQL mode to complete it.
If I try to create the query in SQL mode, when I try to save it, I'm able to enter a name (say, testquery). Then when I press the ENTER key, I get the following error: "Saving object's definition failed. Unspecified error encountered SQL statement: SELECT o_id, o_type, o_name, o_caption, o_desc FROM kexi__objects WHERE o_type=2 AND o_name='testquery' LIMIT 1 Server result: 0 (SQLITE_OK)

Thanks,
wmae
Kexi 2.6.2
User avatar
jstaniek
Moderator
Posts
1027
Karma
2
OS
Hi wmae,

I'll answer 2 questions now.

wmae wrote:2. How does one change the name of a database so that even Kexi recognizes it. Currently, I'm able to change names but only KDE recognizes it(outside of Kexi). Within Kexi, it reverts back to the old name.


I propose to file a wish on bug.kde.org: "Allow editing database properties" so name and description can be viewed/edited.

Until that feature is implemented, a workaround involves using external tool, sqlite3 editor or Sqliteman GUI editor for SQLite files (in your database if file-based), or appropriate tool for MySQL or PostgreSQL. In kexi__db "system" table just change value in db_value column where db_property is "project_caption": http://wstaw.org/m/2013/12/10/plasma-desktopLj2706.png

A query working for any database format would be: update kexi__db set db_value = 'NEW NAME HERE' where db_property = 'project_caption';

wmae wrote:3. I am not able to save a query if I create it in SQL mode. I have to partially create it in Design mode, save it, then go into SQL mode to complete it.
If I try to create the query in SQL mode, when I try to save it, I'm able to enter a name (say, testquery). Then when I press the ENTER key, I get the following error: "Saving object's definition failed. Unspecified error encountered SQL statement: SELECT o_id, o_type, o_name, o_caption, o_desc FROM kexi__objects WHERE o_type=2 AND o_name='testquery' LIMIT 1 Server result: 0 (SQLITE_OK)

In 2.6.4 (checked specifically for you) and 2.8.0 Beta (SQLite and PostgreSQL) I am able open new query design, switch to the SQL view, so the empty query contains only "SELECT" clause. Then after some editing, I am able to save it. I can even save it if it's invalid, in that case Kexi asks "Do you want to save invalid query?" and saves properly. Subsequent designs of this query have to be performed in the SQL view.

What database driver do you use? Could you try to test the same in a fresh new database?


Best regards,
Jarosław Staniek
• Qt Certified Specialist
KEXI - Open Source Visual DB Apps Builder
• Request a feature or fix for KEXI here
May I help you? Please mention your app's version and OS when asking for help
wmae
Registered Member
Posts
32
Karma
0
Thank you for the renaming workaround. It works fine.
Concerning saving a query from SQL mode, I am able to save from Design mode. The problem arises when I create a query from within SQL mode only and then try to save it. I am not able to save unless I exit SQL mode and enter Design mode. Once saved while in Design mode, then I'm able to move back to SQL mode to complete the query and save it.
This is how I currently create a query: Enter Design mode. Create a simple incomplete query such as "Select ID". I then save it. Then I move to SQL mode and complete the full query. I'm able to save it from SQL mode now since I originally saved it while in Design mode. I would like to create the query from within SQL mode and not have to go into Design mode at all. Is this possible?

wmae
Kexi 2.62
piggz
Moderator
Posts
13
Karma
0
OS
To resolve issue one you can use javascript.

That may sound complicated, but its very powerful and quite easy. In place of any field can be a javascript expression, so, to format a float to 2 decimal places change the data-source to:
=field.value("<field>").toFixed(2)

replacing <field> with your field name.

You could even put in some maths such as:
=(field.value("<field>") / 1000).toFixed(2)

Hope that helps

Adam
wmae
Registered Member
Posts
32
Karma
0
Unfortunately, =field.value("<field>").toFixed(2) does not seem to work on floating point numbers.
I get an error message: TypeError: Result of expression 'field.value("<field>")' [undefined] is not an object.
It does work on integers.

wmae
wmae
Registered Member
Posts
32
Karma
0
I finally got =field.value("<field>").toFixed(2) to work. Some of the values in the field in question were undefined. Once I changed them all to numbers, it worked.

wmae


Bookmarks



Who is online

Registered users: bancha, Bing [Bot], Evergrowing, Google [Bot], lockheed, mesutakcan, sandyvee, Sogou [Bot]