B4J Question [BANano] [SOLVED] Extending Event Driven BANanoSQL with own CallBacks?

Discussion in 'B4J Questions' started by Mashiane, Jan 26, 2019.

  1. Mashiane

    Mashiane Expert Licensed User

    Hi there

    This is just a thought...

    The current implementation of the event driven BANanoSQL has a callback method for .Execute being

    Sub SQL_SQLExecuteResult(Tag As String, Result As List)
    If perhaps one could have an extra call e.g.
    , this being an extra method that one can specify the callback method to run. Currently with .Execute, one is using a Tag variable to determine the last execute.

    The callback could be

    Sub DoThis(Result As List)
    End Sub

    Sub DoSomethingElse(Result As List)

    ENd Sub
    The advantage with this is less complexity as one could loose track with the tagging where a lot of queries are concerned.

    Is something like this possible?
    joulongleu likes this.
  2. alwaysbusy

    alwaysbusy Expert Licensed User

    Something like this may be added in the future:

    Sub SQL_SQLOpened()
    SQL.ExecuteCallback("CREATE TABLE IF NOT EXISTS flights (flightNo INT, fromCity STRING, toCity STRING, isInTheAir BOOL)"Null, Me, "mycreate")
    End Sub

    ' MUST be this definition.  No params can be added or removed!
    Sub MyCreate(success As Boolean, Result As List, Reason As String'ignore
       Log("Creation: " & success)
    SQL.Execute("SELECT COUNT(*) AS myCount FROM flights;"Null"COUNT")
    End Sub
    joulongleu and Mashiane like this.
  3. Harris

    Harris Well-Known Member Licensed User

    "fromCity STRING"

    I don't see in any SQL dialect where this is valid.. TEXT, Varcar(100, etc..) is.

    When copying from one table structure output (MySql, SQLite - for example) - to create a new table - the above would have to be modified to accommodate the import statement .

    SQLite: for example... (TEXT for STRING)

    CREATE TABLE [divmast] (
      [name] TEXT,
      [country_id] INTEGER,
      [region_id] INTEGER,
      [city_id] INTEGER,
      [spare1] TEXT,
      [spare2] TEXT,
      [spare3] TEXT);
    To use this sample in MySQL, I must remove the ( [] ) from each line to work...
    Now, one would have to replace STRING with TEXT to work from your example...

    Just a thought and observation...
    (can't we all just get along - with the same syntax)...
    Last edited: Jan 27, 2019
    joulongleu likes this.
  4. alwaysbusy

    alwaysbusy Expert Licensed User

    You are correct. However, alaSQL (the javascript lib BAnanoSQL wraps) does allow it:
    • Column Types
      • JavaScript data types
        • String
        • Number
        • Boolean
        • Date and ISODate
        • Emun
      • ANSI SQL types
      • SQLite, Oracle, MySQL, SQL Server, Postgres data types mapping
    I guess they allow it to bridge both Javascript and SQL better for everyone. Normally, javascript (not using node.js) can't make such SQL queries. Most libraries in JS which allow a direct connection to e.g. a MySQL use a very different syntax (which I personally am not very fond of). I'm more of a fan of normal SQL commands and alaSQL seems to be able to do them.
    joulongleu likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice