Android Question SQL Builder - is a Library needed?

Col

Member
Licensed User
I sometimes build long complex SQL statements from code, and it takes a lot of effort to code and test, so figured why not build a class to do it for me?

Here's a very simple class (the example is in B4J) to build SQL statements from code. It consists of a very basic screen (only needed for the example) and a small SQL builder class.
The parameters for the class are hard-coded for the example, but you can easily change it to (for example) allow the user to select fields from a list boxes, etc.

This basic version returns a SELECT statement with the ability to JOIN a second table and to ORDER the results.

The idea is that you could build the SQL from within your code, and then execute the result to produce screens, reports, etc.

Some ideas for extending it could be:
  • Where clause
  • Allow any number of tables
  • Aliases
  • COUNT, AVG, SUM
  • Wildcards
  • etc.

My questions are
  1. Would it be worth building it out to a library that includes more complex statements to be built from code (i.e. would people actually use it)?
  2. What features should be included?
(I see this as a potential B4xlib library, so other people would be able to extend it over time)
 

Attachments

  • Project.zip
    5.4 KB · Views: 191
Last edited:

klaus

Expert
Licensed User
Longtime User
How did you zip your project.
It seems that it is a B4XPages project and you did not zip it as a B4XPages project.
You should zip with this line in the IDE:
1638965622563.png

Press Ctrl when hovering above the link.
 
Upvote 0

Col

Member
Licensed User
How did you zip your project.
It seems that it is a B4XPages project and you did not zip it as a B4XPages project.
You should zip with this line in the IDE:
View attachment 122777
Press Ctrl when hovering above the link.

Thanks Klaus, you're right - I left a file out of the zip. My apologies, it should be fixed now.
I actually used B4J for my example (figured it would be easier for people to look at it that way)
 
Upvote 0
Top