|
From: <cre...@us...> - 2007-09-07 19:09:06
|
Revision: 1727
http://frontierkernel.svn.sourceforge.net/frontierkernel/?rev=1727&view=rev
Author: creecode
Date: 2007-09-07 12:09:05 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
added sqlite.setColumnBlob and sqlite.getLastInsertRowId verbs added
sqlitegetrowverb function now returns BLOBs as binary values and SQLITE_NULL type as nil value
in sqlitegetcolumntextverb function added column_text NULL value check, scriptError on error
Modified Paths:
--------------
Frontier/trunk/Common/headers/langsqlite.h
Frontier/trunk/Common/resources/Mac/kernelverbs.r
Frontier/trunk/Common/resources/Win32/kernelverbs.rc
Frontier/trunk/Common/source/langsqlite.c
Modified: Frontier/trunk/Common/headers/langsqlite.h
===================================================================
--- Frontier/trunk/Common/headers/langsqlite.h 2007-08-02 17:15:12 UTC (rev 1726)
+++ Frontier/trunk/Common/headers/langsqlite.h 2007-09-07 19:09:05 UTC (rev 1727)
@@ -1,69 +1,75 @@
-
-/* $Id: langsqlite.h,v 1.1.2.1 2006/03/24 01:31:35 davidgewirtz Exp $ */
-
-/******************************************************************************
-
- UserLand Frontier(tm) -- High performance Web content management,
- object database, system-level and Internet scripting environment,
- including source code editing and debugging.
-
- Copyright (C) 1992-2004 UserLand Software, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-******************************************************************************/
-
-/* prototypes */
-
-extern boolean sqliteopenverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-03-15 gewirtz */
-
-extern boolean sqlitecloseverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-03-17 gewirtz */
-
-extern boolean sqlitecompilequeryverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-04-18 gewirtz */
-
-extern boolean sqliteclearqueryverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-04-18 gewirtz */
-
-extern boolean sqliteresetqueryverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-08-31 gewirtz */
-
-extern boolean sqlitestepqueryverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-08-31 gewirtz */
-
-extern boolean sqlitegetcolumncountverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-04-18 gewirtz */
-
-extern boolean sqlitegetcolumntypeverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-04-18 gewirtz */
-
-extern boolean sqlitegetcolumnintverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-04-18 gewirtz */
-
-extern boolean sqlitegetcolumndoubleverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-04-18 gewirtz */
-
-extern boolean sqlitegetcolumntextverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-04-18 gewirtz */
-
-extern boolean sqlitegetcolumnnameverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-04-18 gewirtz */
-
-extern boolean sqlitegetcolumnverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-04-20 gewirtz */
-
-extern boolean sqlitegetrowverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-08-31 gewirtz */
-
-extern boolean sqlitegeterrormessageverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-04-20 gewirtz */
-
-extern boolean sqliteinitverbs (void); /* 2006-03-15 gewirtz */
-
-/* boolean hmacmd5 (unsigned char *, int, unsigned char *, int, unsigned char *);*/ /* 2006-03-05 creedon */
-
-/* boolean hmacsha1 (unsigned char *, int, unsigned char *, int, unsigned char *);*/ /* 2006-03-12 creedon */
-
-/* SQLITE MESSAGES */
-#define SQLITE_COLUMN_ERROR_0 "\xe9""SQLite column error. Frontier uses a base-1 index. Columns must be specified with 1 indicating the first column. This is different from the SQLite API, which requires that columns must be specified with 0 indicating the first column."
-#define SQLITE_COLUMN_ERROR_MAX "\x50""SQLite column error. An attempt was made to access a column that does not exist."
-#define SQLITE_COLUMN_ERROR_UNDEFINED "\x29""SQLite returned an undefined column type."
\ No newline at end of file
+
+/* $Id: langsqlite.h,v 1.1.2.1 2006/03/24 01:31:35 davidgewirtz Exp $ */
+
+/******************************************************************************
+
+ UserLand Frontier(tm) -- High performance Web content management,
+ object database, system-level and Internet scripting environment,
+ including source code editing and debugging.
+
+ Copyright (C) 1992-2004 UserLand Software, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+******************************************************************************/
+
+
+// prototypes
+
+extern boolean sqliteopenverb (hdltreenode, tyvaluerecord *, bigstring); // 2006-03-15 gewirtz
+
+extern boolean sqlitecloseverb (hdltreenode, tyvaluerecord *, bigstring); // 2006-03-17 gewirtz
+
+extern boolean sqlitecompilequeryverb (hdltreenode, tyvaluerecord *, bigstring); // 2006-04-18 gewirtz
+
+extern boolean sqliteclearqueryverb (hdltreenode, tyvaluerecord *, bigstring); // 2006-04-18 gewirtz
+
+extern boolean sqliteresetqueryverb (hdltreenode, tyvaluerecord *, bigstring); // 2006-08-31 gewirtz
+
+extern boolean sqlitestepqueryverb (hdltreenode, tyvaluerecord *, bigstring); // 2006-08-31 gewirtz
+
+extern boolean sqlitegetcolumncountverb (hdltreenode, tyvaluerecord *, bigstring); // 2006-04-18 gewirtz
+
+extern boolean sqlitegetcolumntypeverb (hdltreenode, tyvaluerecord *, bigstring); // 2006-04-18 gewirtz
+
+extern boolean sqlitegetcolumnintverb (hdltreenode, tyvaluerecord *, bigstring); // 2006-04-18 gewirtz
+
+extern boolean sqlitegetcolumndoubleverb (hdltreenode, tyvaluerecord *, bigstring); // 2006-04-18 gewirtz
+
+extern boolean sqlitegetcolumntextverb (hdltreenode, tyvaluerecord *, bigstring); // 2006-04-18 gewirtz
+
+extern boolean sqlitegetcolumnnameverb (hdltreenode, tyvaluerecord *, bigstring); // 2006-04-18 gewirtz
+
+extern boolean sqlitegetcolumnverb (hdltreenode, tyvaluerecord *, bigstring); // 2006-04-20 gewirtz
+
+extern boolean sqlitegetrowverb (hdltreenode, tyvaluerecord *, bigstring); // 2006-08-31 gewirtz
+
+extern boolean sqlitegeterrormessageverb (hdltreenode, tyvaluerecord *, bigstring); // 2006-04-20 gewirtz
+
+extern boolean sqliteinitverbs (void); // 2006-03-15 gewirtz
+
+extern boolean sqlitesetcolumnblobverb ( hdltreenode, tyvaluerecord *, bigstring ); // 2007-08-25 creedon
+
+extern boolean getlastinsertrowidverb ( hdltreenode, tyvaluerecord *, bigstring ); // 2007-08-28 creedon
+
+
+// SQLITE MESSAGES
+
+#define SQLITE_COLUMN_ERROR_0 "\xe9""SQLite column error. Frontier uses a base-1 index. Columns must be specified with 1 indicating the first column. This is different from the SQLite API, which requires that columns must be specified with 0 indicating the first column."
+#define SQLITE_COLUMN_ERROR_MAX "\x50""SQLite column error. An attempt was made to access a column that does not exist."
+#define SQLITE_COLUMN_ERROR_UNDEFINED "\x29""SQLite returned an undefined column type."
+#define SQLITE_COLUMN_ERROR_ROW_OR_COLUMN "\x31" "SQLite invalid row or column number out of range." // 2007-08-25 creedon
+#define SQLITE_PARAMETER_ERROR_COUNT "\x1b" "SQLite parameter error. An attempt was made to access a parameter that does not exist." // 2007-08-26 creedon
+
Modified: Frontier/trunk/Common/resources/Mac/kernelverbs.r
===================================================================
--- Frontier/trunk/Common/resources/Mac/kernelverbs.r 2007-08-02 17:15:12 UTC (rev 1726)
+++ Frontier/trunk/Common/resources/Mac/kernelverbs.r 2007-09-07 19:09:05 UTC (rev 1727)
@@ -1132,41 +1132,45 @@
}
};
-resource 'EFP#' (idcryptverbs, "crypt") { /* 2006-03-07 creedon: crypt verbs */
+resource 'EFP#' (idcryptverbs, "crypt") { // 2006-03-07 creedon: crypt verbs
{
- "crypt", false, {
-
- "whirlpool",
- "hmacMD5",
- "MD5",
- "SHA1",
- "hmacSHA1",
+ "crypt", false, {
+
+ "whirlpool",
+ "hmacMD5",
+ "MD5",
+ "SHA1",
+ "hmacSHA1"
+
+ }
}
- }
-};
+ };
-resource 'EFP#' (idsqliteverbs, "sqlite") { /* 2006-08-31 gewirtz sqlite verbs */
- {
- "sqlite", false, {
-
- "open",
- "compileQuery",
- "clearQuery",
- "resetQuery",
- "stepQuery",
- "getColumnCount",
- "getColumnType",
- "getColumnInt",
- "getColumnDouble",
- "getColumnText",
- "getColumnName",
- "getColumn",
- "getRow",
- "getErrorMessage",
- "close" // 2006-09-07 - kw - renamed from getClose
- }
- }
-};
+resource 'EFP#' (idsqliteverbs, "sqlite") { // 2006-08-31 gewirtz sqlite verbs
+ {
+ "sqlite", false, {
+
+ "open",
+ "compileQuery",
+ "clearQuery",
+ "resetQuery",
+ "stepQuery",
+ "getColumnCount",
+ "getColumnType",
+ "getColumnInt",
+ "getColumnDouble",
+ "getColumnText",
+ "getColumnName",
+ "getColumn",
+ "getRow",
+ "getErrorMessage",
+ "close", // 2006-09-07 - kw - renamed from getClose
+ "setColumnBlob", // 2007-08-25 creedon
+ "getLastInsertRowId" // 2007-08-28 creedon
+
+ }
+ }
+ };
resource 'EFP#' (idmysqlverbs, "mysql") { /* 2007-04-09 gewirtz mysql verbs */
{
Modified: Frontier/trunk/Common/resources/Win32/kernelverbs.rc
===================================================================
--- Frontier/trunk/Common/resources/Win32/kernelverbs.rc 2007-08-02 17:15:12 UTC (rev 1726)
+++ Frontier/trunk/Common/resources/Win32/kernelverbs.rc 2007-09-07 19:09:05 UTC (rev 1727)
@@ -1066,11 +1066,11 @@
"sqrt\0"
END
-1025 /* cryptverbs */ EFP DISCARDABLE
+1025 /* cryptverbs */ EFP DISCARDABLE // 2006-03-07 creedon: crypt verbs
BEGIN
1, // Number of "blocks" in this resource
- "crypt\0", // Function Processor name
- false, // Window required
+ "crypt\0", // Function Processor name
+ false, // Window required
5, // Count of verbs
"whirlpool\0",
"hmacMD5\0",
@@ -1084,22 +1084,24 @@
1, // Number of "blocks" in this resource
"sqlite\0", // Function Processor name
false, // Window required
- 15, // Count of verbs
- "open\0",
- "compileQuery\0",
- "clearQuery\0",
- "resetQuery\0",
- "stepQuery\0",
- "getColumnCount\0",
- "getColumnType\0",
- "getColumnInt\0",
- "getColumnDouble\0",
- "getColumnText\0",
- "getColumnName\0",
- "getColumn\0",
- "getRow\0",
- "getErrorMessage\0",
- "close\0"
+ 17, // Count of verbs
+ "open\0",
+ "compileQuery\0",
+ "clearQuery\0",
+ "resetQuery\0",
+ "stepQuery\0",
+ "getColumnCount\0",
+ "getColumnType\0",
+ "getColumnInt\0",
+ "getColumnDouble\0",
+ "getColumnText\0",
+ "getColumnName\0",
+ "getColumn\0",
+ "getRow\0",
+ "getErrorMessage\0",
+ "close\0",
+ "setColumnBlob\0", // 2007-08-25 creedon
+ "getLastInsertRowId\0" // 2007-08-28 creedon
END
1027 /* mysqlverbs */ EFP DISCARDABLE
Modified: Frontier/trunk/Common/source/langsqlite.c
===================================================================
--- Frontier/trunk/Common/source/langsqlite.c 2007-08-02 17:15:12 UTC (rev 1726)
+++ Frontier/trunk/Common/source/langsqlite.c 2007-09-07 19:09:05 UTC (rev 1727)
@@ -101,16 +101,24 @@
getrowfunc,
geterrormessagefunc,
closefunc,
+ setcolumnblobfunc,
+ getlastinsertrowidfunc,
ctsqliteverbs
} tysqliteverbtoken;
-static boolean sqlitefunctionvalue (short token, hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+static boolean sqlitefunctionvalue ( short token, hdltreenode hparam1,
+ tyvaluerecord *vreturned, bigstring bserror ) {
+
+ //
+ // 2007-08-28 creedon: added setcolumnblobfunc case
+ //
+ // added getlastinsertrowidfunc case
+ //
+ // 2006-03-15 gewirtz: created, cribbed from langcrypt, itself cribbed from
+ // htmlfunctionvalue
+ //
- /*
- 2006-03-15 gewirtz: created, cribbed from langcrypt, itself cribbed from htmlfunctionvalue
- */
-
hdltreenode hp1 = hparam1;
tyvaluerecord *v = vreturned;
@@ -192,13 +200,24 @@
return (sqlitecloseverb (hp1, v, bserror));
} /* closefunc */
-
+
+ case setcolumnblobfunc:
+
+ return ( sqlitesetcolumnblobverb ( hp1, v, bserror ) );
+
+ case getlastinsertrowidfunc:
+
+ return ( getlastinsertrowidverb ( hp1, v, bserror ) );
+
default:
+
getstringlist (langerrorlist, unimplementedverberror, bserror);
return (false);
- } /* switch */
- } /* sqlitefunctionvalue */
+
+ } // switch
+
+ } // sqlitefunctionvalue
boolean sqliteinitverbs (void) {
@@ -642,6 +661,7 @@
return setlongvalue (returnCode, vreturned);
+
} /* sqlitegetcolumncountverb */
@@ -738,56 +758,70 @@
boolean sqlitegetcolumntextverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+
+ //
+ // 2007-09-07 creedon: added column_text NULL check
+ //
+
+ //
+ // sqlite.getColumnText(queryid, columnNumber)
+ //
+ // Action: Retrieve the value of the specified text-type column
+ // Params: a query id and the number of the column (1 base)
+ // Returns: an SQLite result code
+ // Notes: do not pass the opened database ID across threads.
+ //
+ // SQLite docs: http://www.sqlite.org/capi3ref.html#sqlite3_column_text.
+ //
+
long columnNumber;
sqlite3_stmt *queryid;
Handle returnH;
const unsigned char *column_text;
int columnCount;
-
- /*
- sqlite.getColumnText(queryid, columnNumber)
-
- Action: Retrieve the value of the specified text-type column
- Params: a query id and the number of the column (1 base)
- Returns: an SQLite result code
- Notes: do not pass the opened database ID across threads.
-
- SQLite docs: http://www.sqlite.org/capi3ref.html#sqlite3_column_text.
- */
-
+
if (!getlongvalue (hparam1, 1, (long *) &queryid)) /* Get the long value, which becomes the pline pointer */
return (false);
-
+
flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
-
+
/* Enter the verb, convert the param to null-terminated string */
if (!getlongvalue (hparam1, 2, &columnNumber))
return (false);
-
+
/* Validate the column number */
if (columnNumber < 1) {
langerrormessage (SQLITE_COLUMN_ERROR_0);
return (false);
- }
+ }
+
columnCount = sqlite3_column_count(queryid);
if (columnNumber > columnCount) {
langerrormessage (SQLITE_COLUMN_ERROR_MAX);
return (false);
- }
-
+ }
+
/* Process the SQLite sequence */
--columnNumber; /* Frontier uses base 1, but SQLite uses a base of 0 for its column numbering */
column_text = sqlite3_column_text(queryid, (int) columnNumber);
-
+
+ if ( column_text == NULL ) {
+
+ langerrormessage ( SQLITE_COLUMN_ERROR_ROW_OR_COLUMN );
+
+ return ( false );
+
+ }
+
/* Exit the verb, converting column_name back to Frontier handle */
if (!newfilledhandle ((ptrvoid) column_text, strlen (column_text), &returnH))
return false; /* Allocation failed */
-
+
return (setheapvalue (returnH, stringvaluetype, vreturned));
+
+ } // sqlitegetcolumntextverb
-} /* sqlitegetcolumntextverb */
-
boolean sqlitegetcolumnverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
long columnNumber; /* column number */
sqlite3_stmt *queryid; /* query id */
@@ -881,6 +915,22 @@
boolean sqlitegetrowverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+
+ //
+ // 2007-09-07 creedon: SQLITE_BLOB case now returns a binary value
+ //
+ // SQLITE_NULL case now returns nil value instead of 0
+ //
+
+ //
+ // sqlite.getRow(queryid)
+ //
+ // Action: Retrieve a row as a list
+ // Params: a query id
+ // Returns: an SQLite result code
+ // Notes: do not pass the opened database ID across threads.
+ //
+
long columnNumber; /* column number */
int columnCount; /* number of columns */
sqlite3_stmt *queryid; /* query id */
@@ -890,93 +940,132 @@
const unsigned char *column_text;
hdllistrecord hlist;
tyvaluerecord val;
-
- /*
- sqlite.getRow(queryid)
-
- Action: Retrieve a row as a list
- Params: a query id
- Returns: an SQLite result code
- Notes: do not pass the opened database ID across threads.
- this implementation does not support blobs. If a blob column is requested, 0 is returned.
- */
-
+
flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
-
+
if (!getlongvalue (hparam1, 1, (long *) &queryid)) /* Get the long value, which becomes the queryid pointer */
return (false);
-
+
/* Process the SQLite sequence */
columnCount = sqlite3_column_count(queryid); /* first, figure out how many columns we've got */
-
+
if (columnCount == 0) {
- langerrormessage ("\x2F""SQLite.getRow requires a minimum of one column.");
+
+ langerrormessage ("\x2F""SQLite.getRow requires a minimum of one column.");
+
return (false);
- }
+ }
if (!opnewlist (&hlist, false)) /* fail out if we can't create the list */
return (false);
-
+
for (columnNumber = 0 ; columnNumber < columnCount ; ++columnNumber) {
-
+
returnCode = sqlite3_column_type(queryid, (int) columnNumber);
-
+
switch(returnCode) {
-
+
case SQLITE_INTEGER: {
+
returnCode = sqlite3_column_int(queryid, (int) columnNumber);
+
if (!langpushlistlong (hlist, (long) returnCode))
goto error;
+
break;
- }
+
+ }
+
case SQLITE_FLOAT: {
+
returnDouble = sqlite3_column_double(queryid, (int) columnNumber);
+
if (!setdoublevalue (returnDouble, &val))
goto error;
+
if (!langpushlistval (hlist, nil, &val))
goto error;
+
break;
- }
+
+ }
+
case SQLITE_TEXT: {
+
column_text = sqlite3_column_text(queryid, (int) columnNumber);
/* Exit the verb, converting column_name back to Frontier handle */
if (!newfilledhandle ((ptrvoid) column_text, strlen (column_text), &returnH))
return false; /* Allocation failed */
+
if (!setheapvalue (returnH, stringvaluetype, &val)) /* convert handle to value */
goto error;
+
if (!langpushlistval (hlist, nil, &val))
goto error;
+
break;
- }
+
+ }
+
case SQLITE_BLOB: {
- if (!langpushlistlong (hlist, (long) 0))
+
+ Handle h;
+ OSType type;
+
+ if ( ! newfilledhandle ( ( ptrvoid ) sqlite3_column_blob (
+ queryid, columnNumber ), sqlite3_column_bytes (
+ queryid, columnNumber ), &h ) )
+ return ( false );
+
+ pullfromhandle ( h, 0L, sizeof ( type ), &type );
+
+ setbinaryvalue ( h, type, &val );
+
+ if ( ! langpushlistval ( hlist, NULL, &val ) )
goto error;
+
break;
- }
+
+ }
+
case SQLITE_NULL: {
- if (!langpushlistlong (hlist, (long) 0))
+
+ initvalue ( &val, novaluetype );
+
+ if ( ! langpushlistval ( hlist, NULL, &val ) )
goto error;
+
break;
- }
+
+ }
+
default: {
+
/* SQLite spec says sqlite3_column_type only returns the above 5 types. But,
just in case it lied, this time we return a 0, so the rest of the fields
can be read properly. */
+
if (!langpushlistlong (hlist, (long) 0))
goto error;
- }
- } /* switch */
- } /* for */
-
+
+ }
+
+ } // switch
+
+ } // for
+
return (setheapvalue ((Handle) hlist, listvaluetype, vreturned));
-
+
error: {
+
opdisposelist (hlist);
+
return (false);
- }
+
+ }
-} /* sqlitegetrow */
+ } // sqlitegetrow
boolean sqlitegeterrormessageverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
@@ -1011,3 +1100,94 @@
} /* sqlitegeterrormessageverb */
+
+boolean sqlitesetcolumnblobverb ( hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror ) {
+
+ //
+ // 2007-08-25 creedon: created, cribbed from sqlitegetcolumntextverb
+ //
+
+ //
+ // sqlite.setColumnBlob ( queryId, parameterIndex, binaryAddress )
+ //
+ // Action: Set the value of the specified blob-type column
+ // Params: a query id and the number of the column (1 base)
+ // Returns: an SQLite result code
+ // Notes: do not pass the opened database ID across threads.
+ //
+ // SQLite docs: < http://www.sqlite.org/capi3ref.html#sqlite3_bind_blob >
+ //
+
+ Handle h;
+ int parameterCount, returnCode;
+ long parameterIndex;
+ sqlite3_stmt *queryid;
+
+ if ( ! getlongvalue ( hparam1, 1, ( long * ) &queryid ) ) // Get the long value, which becomes the pline pointer
+ return ( false );
+
+ if ( ! getlongvalue ( hparam1, 2, ¶meterIndex ) )
+ return ( false );
+
+ if ( parameterIndex < 1 ) { // validate the parameter index
+
+ langerrormessage ( SQLITE_PARAMETER_ERROR_COUNT );
+
+ return ( false );
+
+ }
+
+ parameterCount = sqlite3_bind_parameter_count ( queryid );
+
+ if ( parameterCount > parameterIndex ) {
+
+ langerrormessage ( SQLITE_PARAMETER_ERROR_COUNT );
+
+ return ( false );
+
+ }
+
+ flnextparamislast = true;
+
+ if ( ! getbinaryvalue ( hparam1, 3, true, &h ) )
+ return ( false );
+
+ returnCode = sqlite3_bind_blob ( queryid, parameterIndex, *h,
+ gethandlesize ( h ), SQLITE_STATIC );
+
+ return ( setlongvalue ( returnCode, vreturned ) );
+
+ } // sqlitegetcolumntextverb
+
+
+boolean getlastinsertrowidverb ( hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror ) {
+
+ //
+ // 2007-08-28 creedon: created, cribbed from sqlitegetcolumntextverb
+ //
+
+ //
+ // sqlite.getLastInsertRowId ( queryId )
+ //
+ // Action: Get row id for the most recent insert operation
+ // Params: a query id
+ // Returns: a row id number
+ // Notes: do not pass the opened database ID across threads.
+ //
+ // SQLite docs: < http://www.sqlite.org/capi3ref.html#sqlite3_last_insert_rowid >
+ //
+
+ sqlite3 *db; // the SQLite database handle
+ sqlite_int64 rowid;
+
+ flnextparamislast = true;
+
+ if ( ! getlongvalue ( hparam1, 1, ( long * ) &db ) ) // Get the long value, which becomes the db pointer
+ return ( false );
+
+ rowid = sqlite3_last_insert_rowid ( db );
+
+ return ( setlongvalue ( rowid, vreturned ) );
+
+ } // getlastinsertrowidverb
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|