Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > microsoft.public.scripting.vbscript > #11425

Re: SQLite with VBScript UDF?

Newsgroups microsoft.public.scripting.vbscript
Date 2016-11-22 15:22 -0800
References (8 earlier) <o12039$aqs$1@dont-email.me> <4a3f1682-ca42-4769-bf4c-51ff8cf9e00d@googlegroups.com> <o129ov$gvk$1@dont-email.me> <0525a034-a6ac-4103-8731-26054b8cdf7d@googlegroups.com> <o12h8b$dkr$1@dont-email.me>
Message-ID <9fa57da5-d983-4fdc-85a4-e1de4c8a6dfc@googlegroups.com> (permalink)
Subject Re: SQLite with VBScript UDF?
From bart.smissaert@gmail.com

Show all headers | View raw


Let me try to explain.
In it's most simplest form you have a UDF (for now I am doing this in Excel VBA, but it would be just as simple in VB6, except most users won't have access to that) like this:

Sub AddOne(ByVal lPtr_ObjContext As Long, _
           ByVal lArgCount As Long, _
           ByVal lPtr_ObjSQLite3_Value As Long)

    Dim lPtrValue As Long

    lPtrValue = MemLong(lPtr_ObjSQLite3_Value)

    sqlite3_result_int ByVal lPtr_ObjContext, ByVal sqlite3_value_int(lPtrValue) + 1

End Sub

All it does is take a value (either a supplied literal or a value from a SQLite table) and add one.
So now in SQL you can do for example this:

select AddOne(1) as OnePlusOne
and the result will be 2

or if we take a value from a SQLite table:

select AddOne(field1) from table1

Before the UDF can be used by SQLite it needs to be registered with SQLite
with this SQLite function:

sqlite3_create_function_v2(lDBHandle As Long,
                           lPtrFunctionName As Long,
                           lArgs As Long,
                           lTextRep As Long,
                           lPtrApp As Long,
                           lPtrXFunc As Long,
                           lPtrXStep As Long,
                           lPtrXFinal As Long,
                           lPtrDestroy As Long) As Long

All this will be done in VB6, so in that ActiveX dll and this is all fairly simple and VBScript doesn't come into this.

The problem is to get lPtrXFunc, which is the address pointer to the UDF. In VB6 this is simply done with AddressOf.

Then also for the UDF to work VBScript will then need to be able to handle SQLite functions as in the above UDF sqlite3_result_int and sqlite3_value_int.

That is about it. All very neat and useful as it can add very powerful options
to your SQL.

Hope this clarifies.


RBS








>    I'm not at all familiar with SQLite/UDF, so I
> really don't know what you're trying to do.

Back to microsoft.public.scripting.vbscript | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-21 02:04 -0800
  Re: SQLite with VBScript UDF? JJ <jj4public@vfemail.net> - 2016-11-21 23:17 +0700
    Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-21 09:14 -0800
  Re: SQLite with VBScript UDF? GS <gs@v.invalid> - 2016-11-21 15:21 -0500
    Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-21 13:03 -0800
      Re: SQLite with VBScript UDF? GS <gs@v.invalid> - 2016-11-21 16:11 -0500
        Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-21 13:19 -0800
          Re: SQLite with VBScript UDF? GS <gs@v.invalid> - 2016-11-21 16:31 -0500
            Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-21 13:40 -0800
              Re: SQLite with VBScript UDF? GS <gs@v.invalid> - 2016-11-22 12:30 -0500
                Re: SQLite with VBScript UDF? GS <gs@v.invalid> - 2016-11-22 12:43 -0500
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-22 11:02 -0800
                Re: SQLite with VBScript UDF? GS <gs@v.invalid> - 2016-11-22 14:19 -0500
                Re: SQLite with VBScript UDF? "Mayayana" <mayayana@invalid.nospam> - 2016-11-22 15:27 -0500
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-22 14:12 -0800
                Re: SQLite with VBScript UDF? "Mayayana" <mayayana@invalid.nospam> - 2016-11-22 17:34 -0500
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-22 15:22 -0800
                Re: SQLite with VBScript UDF? "Mayayana" <mayayana@invalid.nospam> - 2016-11-22 20:06 -0500
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-22 17:42 -0800
                Re: SQLite with VBScript UDF? Schmidt <ng@vbRichClient.com> - 2016-11-26 15:23 +0100
                Re: SQLite with VBScript UDF? GS <gs@v.invalid> - 2016-11-26 15:21 -0500
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-27 08:11 -0800
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-27 12:59 -0800
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-28 07:39 -0800
                Re: SQLite with VBScript UDF? Schmidt <ng@vbRichClient.com> - 2016-11-28 18:28 +0100
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-29 05:59 -0800
                Re: SQLite with VBScript UDF? Schmidt <ng@vbRichClient.com> - 2016-11-29 22:01 +0100
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-29 13:35 -0800
                Re: SQLite with VBScript UDF? Schmidt <ng@vbRichClient.com> - 2016-11-30 06:31 +0100
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-29 13:01 -0800
                Re: SQLite with VBScript UDF? Schmidt <ng@vbRichClient.com> - 2016-11-30 06:51 +0100
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-30 00:17 -0800
                Re: SQLite with VBScript UDF? Schmidt <ng@vbRichClient.com> - 2016-11-30 10:50 +0100
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-30 02:45 -0800
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-12-01 02:40 -0800

csiph-web