gb.db2 Order by

Post

Posted
Rating:
#26
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
you are correct … something has changed with the syntax of the gb.db to gb.db2
this line works with gb.db

Code (gambas)

  1.       $con.Exec(db.Subst("delete from [&1] where  '&2'  Like  &3 ", sFileName, sFileField, sFileIndex))

but gives a syntax error and crashes with gb.db2

Gambas verison 3.20.1
Online now: No Back to the top

Post

Posted
Rating:
#27
Banned
Perhaps DB.Subst IS supposed to work like Subst but it's a bug?

I cannot imagine why Benoit would call it Subst otherwise?

Maybe something for the bugtracker?
Online now: No Back to the top

Post

Posted
Rating:
#28
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
Nah, I think not a bug.
It does what it says it does. It 'correctly' quotes data values (oh and table/column names now) suitable for the underlying database.
As the wiki says, it is ""similar to" Subst$, which if you think about it does not mean "the same as".
and further down, "the argument is supposed to be a SQL value" noting that in SQL a "value" is a specific thing, not just any old string.
Why does the command have the same name? It doesn't, it's "DB.Subst".

Yet again, "read EVERY word of the wiki page until your eyes bleed". :mrgreen:
(I'm just trying to save M. Minisini the bother.)
b

Online now: No Back to the top

Post

Posted
Rating:
#29
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
BUT ... something has changed in gb.db2 ?
Online now: No Back to the top

Post

Posted
Rating:
#30
Guru
Poly is in the usergroup ‘Guru’
Poly is in the usergroup ‘GambOS Contributor’
Hello everyone

thatbruce said

 "read EVERY word of the wiki page until your eyes bleed". :mrgreen:
(I'm just trying to save M. Minisini the bother.)

I have referred to the corresponding Wiki page several times. And it is clearly stated there.

>  I strongly suggest to use these methods for security reasons, and never build your requests by simple string concatenation!

Then I use exact the Syntax which was specified there

Code

Print DB.Subst("SELECT ** FROM [&1] WHERE '&2' = &3 ORDER BY '&4'", "Table", "Column1", "a string", "Column2")

and get an Error only with gb.db2 and not with gb.db

and the same with my own Code which use the same syntax

Code (gambas)

  1. 1 [DataSource1.Table = DB.Subst("SELECT * From [&1] WHERE '&2' = &3 Order by '&4' DESC", "Namen", "Vorname", "Risa", "Nachname")

then I don't know what else to read so that my eyes bleed

I also don't know whether anyone here has really tried this exactly.
I can also post an example tonight if that's what you want.
I would say that something has changed and Benoît had specifically asked to report problems with the new component.

best regards
Poly
Online now: No Back to the top

Post

Posted
Rating:
#31
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
I just updated to the latest fedora 41 kernel   Gnome
Gambas 3.20.2 … fresh install
still no joy  :(

<IMG src="/home/mhc/Pictures/Screenshots/Screenshot%20From%202025-03-19%2007-40-56.png"> </IMG>

Image

(Click to enlarge)

Online now: No Back to the top

Post

Posted
Rating:
#32
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
 There is a bug in the new gb.db2   the line below produces the results shown

Print DB.Subst("delete from [&1] where  '&2'  =  &3 ", sFileName, sFileField, sFileIndex)

delete from ['bkaccts'] where  ''accname''  =  'newAcc88'
and produces a error

while gb.db outputs this

delete from "bkaccts" where  "accname"  =  'newAcc88'
and works as expected
Online now: No Back to the top

Post

Posted
Rating:
#33
Guru
Poly is in the usergroup ‘Guru’
Poly is in the usergroup ‘GambOS Contributor’
Hi Grayghost4

grayghost4 said

There is a bug in the new gb.db2   the line below produces the results shown

Thank you very much for the confirmation and all your efforts.  :)
I don't have a Bug Tracker-Account yet, but would make one if no one else can or wants to do it.

Greetings Poly
Online now: No Back to the top

Post

Posted
Rating:
#34
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
I have no clue how to find or use the bugtracker   :(
Online now: No Back to the top

Post

Posted
Rating:
#35
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
gbWilly leads the usergroup ‘GambOS Contributor’
gbWilly is in the usergroup ‘Blogger’

grayghost4 said

I have no clue how to find or use the bugtracker   :(

Connexion

I didn't test but it might well be a bug.

And be aware:
- Subst is part of core gb
- db.subst is part of gb.db and now gb.db2 componet and is a different ballgame meant for substitution specifically aimed at sql based databases.

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: Yes Back to the top

Post

Posted
Rating:
#36
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
I attempted several time to register at the bug tracker …. unsuccessful …. seems there is a bug there also  ;)

maybe I will get several email by the weekend
Online now: No Back to the top

Post

Posted
Rating:
#37
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
 Well, you both are correct. I can now confirm the bug (or maybe even more bugs) in DB2. I was having difficulty convincing myself they were here as the symptoms didn't happen with a postgres database.  Hence my grumpy comments about "it does what it says it does". Sorry.
Now, as regards the bug tracker. (greyghost, did you get my PMs?) and for everyone else … gmail is blocking the registration confirmation email from the Gambas bugtracker server, if you register with a gmail account you'll never get it. Today, I registered again with another mail account from another free mail provider and got the confirmation in seconds.
 regards
b

Online now: No Back to the top

Post

Posted
Rating:
#38
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
yes, I did use a gmail.com account and never received a reply .
But if you file a report I don't need a error tracker account   :D  :lol:
Online now: No Back to the top

Post

Posted
Rating:
#39
Guru
Poly is in the usergroup ‘Guru’
Poly is in the usergroup ‘GambOS Contributor’
Hi thatbruce

thatbruce said

Hence my grumpy comments about "it does what it says it does". Sorry.

That is a beautiful character. Thank you.  :)
You didn't actually say anything bad, but as I'm not an IT specialist and am currently familiarising myself with Gambas, I was a bit confused.
I'm all the more pleased that you can now confirm the error and have apologised for your grumpy comments.

Great community, many thanks to you all.  :D
Online now: No Back to the top

Post

Posted
Rating:
#40
Guru
Poly is in the usergroup ‘Guru’
Poly is in the usergroup ‘GambOS Contributor’
Hi Grayghost4

grayghost4 said

But if you file a report I don't need a error tracker account   :D  :lol:

I have just written my first bug report. I hope it is understandable.  ;)
Online now: No Back to the top

Post

Posted
Rating:
#41
Guru
Poly is in the usergroup ‘Guru’
Poly is in the usergroup ‘GambOS Contributor’
Have a look here, it has already been fixed.

[Gambas-bugtracker] Bug #3002: DB.Subst (gb.db2)

That was quick. I am impressed.  :D
Online now: No Back to the top

Post

Posted
Rating:
#42
Banned

Poly said

Have a look here, it has already been fixed.

[Gambas-bugtracker] Bug #3002: DB.Subst (gb.db2)

That was quick. I am impressed.  :D

Welcome to the cutting edge of gambas where any problems you find get fixed quickly :)

Thanks to Benoit for fixing and thanks to you for reporting, Gambas is now a little bit better :)
 8-)
Online now: No Back to the top

Post

Posted
Rating:
#43
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
Do I have to reinstall Gambas to get it ... or just wait for the next release ?
Online now: No Back to the top

Post

Posted
Rating:
#44
Banned
 it is fixed in master (development branch) right now.

then bug fixes will add to stable in the next release.
Online now: No Back to the top

Post

Posted
Rating:
#45
Guru
Poly is in the usergroup ‘Guru’
Poly is in the usergroup ‘GambOS Contributor’

BruceSteers said


Thanks to Benoit for fixing and thanks to you for reporting, Gambas is now a little bit better :)
 8-)

Thank you for your kind words.  :D

I can't thank Benoit and the community enough when I see how quickly the bug was fixed.
Now I'm waiting impatiently for the new release.
But thanks to Grayghost4 I now know how I can do the whole thing alternatively by using Quote.  :)
Online now: No Back to the top

Post

Posted
Rating:
#46
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’

BruceSteers said

it is fixed in master (development branch) right now.

I installed the development and can verify that it works properly with sqlite database  :D
Online now: No Back to the top

Post

Posted
Rating:
#47
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
gbWilly leads the usergroup ‘GambOS Contributor’
gbWilly is in the usergroup ‘Blogger’

Poly said

Now I'm waiting impatiently for the new release.
But thanks to Grayghost4 I now know how I can do the whole thing alternatively by using Quote.  :)

There is no need to wait for gb.db2 Subst to be in a new release.
You can use gb Subst as well. I been working like that for over 10 years and it never failed me.

Simple function as example using Subst (not the db2 Subst).

Code (gambas)

  1. Public Function RemoveBasedOnDate(hConn As Connection, sTableName As String, iDaysBack As Integer, bUseDateTime As Boolean) As Boolean
  2.  
  3.   Dim rResult As Result
  4.   Dim sQuery As String
  5.   Dim sDateBackShort, sDateBackLong As String
  6.  
  7.   sDateBackShort = Format(Date(Now - iDaysBack), "yyyy-mm-dd")
  8.   sDateBackLong = Subst("&1 00:00:00", sDateBackShort)
  9.  
  10.   If bUseDateTime Then
  11.     sQuery = Subst("DELETE FROM `&1` WHERE Date < '&2'", sTableName, sDateBackLong)
  12.   Else
  13.     sQuery = Subst("DELETE FROM `&1` WHERE Date < '&2'", sTableName, sDateBackShort)
  14.   Debug sQuery
  15.  
  16.   '--make it a transaction that can be rolled back--
  17.   hConn.Begin
  18.   rResult = hConn.Exec(sQuery)
  19.   hConn.Commit
  20.  
  21.  
  22.     Debug Subst("&1 (&2): &3", Error.Where, Error.Code, Error.Text)
  23.     hConn.Rollback
  24.     Error.Clear
  25.    
I threw in the

Code (gambas)

  1. Debug sQuery
so you can see the actual query that will be executed.
Exampe on how to use:

Code (gambas)

  1. If RemoveBasedOnDate(MyConn, "LogTable", 2, True) Then
  2.  Message.Info(" Removed records older than 2 days from LogTable")
  3.   Message.Error("Something went wrong!!")
Note that the table needs a field named Date and the date content in a certain format
Either yyyy-mm-dd
OR yyyy-mm-dd hh:nn:ss
Screenshot below is from a mariadb table taken in phpMyAdmin to show a longdate example:
Image

(Click to enlarge)

This is the table structure for the Date field:
Image

(Click to enlarge)

Code is a simplified routine I use in logging tables that have one of both date formats in a field named 'Date'. Wrote it right here without testing, so might be typo's in it.

Enjoy…

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: Yes Back to the top

Post

Posted
Rating:
#48
Guru
Poly is in the usergroup ‘Guru’
Poly is in the usergroup ‘GambOS Contributor’

gbWilly said


There is no need to wait for gb.db2 Subst to be in a new release.
You can use gb Subst as well. I been working like that for over 10 years and it never failed me.


Many thanks for the tip and your code examples.
I am really still a beginner without a project or a specific intention. I've just been playing with databases a bit.
But I think Gambas is great and I'm happy if I can perhaps help some beginners to try Gambas more by discovering errors or ambiguities and eliminating them.
My first introduction to Gambas was quickly ended by the fact that an array was read only. Because I thought I was too stupid, but that was a bug in the version at the time.

I will try to understand your examples and I am really pleased that you have added them here.
I like to learn   :D


gbWilly said


Enjoy…


I have a lot of fun with gambas. I just need more time.  :lol:
Online now: No Back to the top

Post

Posted
Rating:
#49
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
gbWilly leads the usergroup ‘GambOS Contributor’
gbWilly is in the usergroup ‘Blogger’

Poly said

Many thanks for the tip and your code examples.
I am really still a beginner without a project or a specific intention. I've just been playing with databases a bit.
Many moons ago I wrote a small thing aimed at people completely new to Gambas3 and programming in general. It never really got finished (personal circumstances) but it is still valid and more important usable introduction to GUI programming in Gambas3 and best of all downloadable as a pdf. Mail address in there is no longer valid and maybe some here on the forum contributed to grammar corrections and more. Check it out and discover…

In those days, I had big plans on a whole series (this was part 2, part 1 was on installing and compiling gambas and no longer valid as we moved from subversion to git). I like writing training manuals as I have worked as IT trainer for a good 5 to 6 years back in the 90ies (also developing training materials now and then).

Poly said

But I think Gambas is great and I'm happy if I can perhaps help some beginners to try Gambas more by discovering errors or ambiguities and eliminating them.
My first introduction to Gambas was quickly ended by the fact that an array was read only. Because I thought I was too stupid, but that was a bug in the version at the time.
I learned a lot a long time ago on a Gambas forum before this one (White Islands software) and learned just by trying to solve the problems people reported on the forum. Try to replicate them in a vm and see what was causing it. Kind of what I see Bruce doing on this forum, getting smarter by the day, while helping others ;)

I discovered a lot in those days merely by doing that (and reading the wiki over and over again many, many, many, many times… ;) ) I had some open source projects in those day on the old forum all about supporting Gambas somehow or discovering it's possibilities.

Then, in 2013,  I started migrating (read code it all completely new) the software (databases and front ends) I wrote 10 yeras before, in a Windows XP and Windows 2003 server environment for the corporation I worked for to gambas3 front ends (and eventually way more), mysql (later mariadb backend) on debian servers. Never going back, the servers never had problems, software (read gambas and all underlying) stable as one wished for without having to figure out work arounds. Complete migration took me about 4 years at about 20 hours a week, running a dual environment for that period (windows/Linux). Migration period was not just that, but also improvements and new additions as Gambas offered way more freedom of doing. And developed a set of management tools in Gambas3 as well, including daemons running on the servers reporting back to me.

Gambas is great for so many things, I really love programming in Gambas and have several private projects (for my own use).

Poly said

I will try to understand your examples and I am really pleased that you have added them here.
I like to learn   :D
Well, enjoy it some more…

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: Yes Back to the top

Post

Posted
Rating:
#50
Guru
Poly is in the usergroup ‘Guru’
Poly is in the usergroup ‘GambOS Contributor’

gbWilly said

Many moons ago I wrote a small thing aimed at people completely new to Gambas3 and programming in general.

This is from you?  :o
I've already worked through it completely. It was what got me started with Gambas3 in the first place.  :)
I think I know pretty much all the Gambas docs and I'm in the process of reading the wiki over and over again.
I can also highly recommend the Greek Gambas book https://github.com/demosthenesk/the_gambas3_book
I have translated it completely into German and think that your ‘How to Gambas’, the ‘Gambas from Zip’ and this book give you enough tools to get a good understanding of Gambas.
At least enough so that people are able to read the wiki better and dare to ask questions in a forum like this.  ;)

I feel really honoured to be in contact with such important people from Gambas.
Thank you very much for this great "How to…."
For the work you have put into the creation and thus for the support for Gambas.  :)

It's good to know that such cracks are reading along here.

With the very best regards
Poly
Online now: No Back to the top
1 guest and 0 members have just viewed this.