![]() |
||
| Home | SwiftForth Archive | SwiftX Archive | |

Attached is a prototype of accessing Gupta's SQLBase vial the API DLL :
( sorry about the long winded reply ... )
John Ulyate
{ ====================================================================
INSERT.f
TCP Comms Test 01
Insert data via bind variables
Test SYSDATETIME
==================================================================== }
EMPTY
library SQLWNTM.dll
3 IMPORT: sqlcnc \ ConNnect Cursor
1 IMPORT: sqldis \ DISconnect from cursor
3 IMPORT: sqlcom \ COMpile a SQL command/procedure
2 IMPORT: sqlnbv \ Number of Bind Variables
6 IMPORT: sqlbnn \ BiNd data by Number
1 IMPORT: sqlexe \ EXEcute a SQL command/procedure
1 IMPORT: sqlcmt \ CoMmit
\ --- PROGRAM DATA TYPES ( from sql.h) -------------------------------
1 CONSTANT SQLPBUF \ buffer
2 CONSTANT SQLPSTR \ string (zero terminated)
3 CONSTANT SQLPUCH \ unsigned char
4 CONSTANT SQLPSCH \ char
5 CONSTANT SQLPUIN \ unsigned int
6 CONSTANT SQLPSIN \ int
7 CONSTANT SQLPULO \ unsigned long
8 CONSTANT SQLPSLO \ long
9 CONSTANT SQLPFLT \ float
10 CONSTANT SQLPDOU \ double
11 CONSTANT SQLPNUM \ SQLBASE internal numeric format
12 CONSTANT SQLPDAT \ SQLBASE internal datetime format
13 CONSTANT SQLPUPD \ unsigned packed decimal
14 CONSTANT SQLPSPD \ signed packed decimal
15 CONSTANT SQLPDTE \ date only format
16 CONSTANT SQLPTIM \ time only format
17 CONSTANT SQLPUSH \ unsigned short
18 CONSTANT SQLPSSH \ short
19 CONSTANT SQLPNST \ numeric string
20 CONSTANT SQLPNBU \ numeric buffer
21 CONSTANT SQLPEBC \ EBCDIC buffer format
22 CONSTANT SQLPLON \ long text string
23 CONSTANT SQLPLBI \ long binary buffer
24 CONSTANT SQLPLVR \ char\long varchar > 254
25 CONSTANT SQLPULL \ unsigned long long
26 CONSTANT SQLPSLL \ long long
26 CONSTANT SQLPDTM \ data type maximum
VARIABLE CUR \ Cursor Number
VARIABLE NBV \ Number of Bind Variables
CREATE AAA 6 ALLOT
CREATE BBB 6 ALLOT
CREATE CCC 6 ALLOT
VARIABLE DDD
CREATE EEE 12 ALLOT
: Connect ( -- f )
CUR \ Pointer to variable that will
hold cursor number
Z" TCPIP/SYSADM/SYSADM" \ Compile a 0 terminated string
0 sqlcnc ; \ Call connect function - 0 return
=> success
: Disconnect ( cur -- f )
CUR @ \ Get cursor number
sqldis ; \ Call disconnect function - 0
return => success
: Compile ( -- f )
CUR @ \ Get cursor number
Z" INSERT INTO AAA(A, B, C, D, E) VALUES (:1, :2, :3, :4, SYSDATETIME)"
0 sqlcom ; \ Call compile function - 0 return
=> success
: SetBindVar ( -- f )
CUR @
NBV sqlnbv ;
: BindData ( -- f f f f )
CUR @ 1 AAA 0 0 SQLPSTR sqlbnn
CUR @ 2 BBB 0 0 SQLPSTR sqlbnn
CUR @ 3 CCC 0 0 SQLPSTR sqlbnn
CUR @ 4 DDD 8 0 SQLPSLO sqlbnn ;
: Execute ( -- f )
CUR @ sqlexe ;
: Commit ( -- f )
CUR @ sqlcmt ;
: MakeData ( -- )
Z" AAA01" AAA 6 MOVE
Z" BBB01" BBB 6 MOVE
Z" CCC01" CCC 6 MOVE
123 DDD ! ;
: Test ( -- ... ) CR
Connect . CR
Compile . CR
SetBindVar . SPACE NBV @ . CR
MakeData
BindData . . . . CR
Execute . CR
Commit . CR
Disconnect . CR ;
-----Original Message-----
From: sftalk-bounce_at_forth.com [mailto:sftalk-bounce_at_forth.com]On Behalf Of
Tony Mc
Sent: Monday, October 08, 2007 11:18 PM
To: sftalk_at_forth.com
Subject: [sftalk] Re: SQLite and SwiftForth
On Mon, 08 Oct 2007 19:07:45 +0100, you wrote:
> LIBRARY sqlite3.dll
> 2 IMPORT: sqlite3_open
Dear all,
sorry to respond to my own message, but I've now realised that the
import should be CIMPORT: and I think this gets me started. At least I
don't get an ACCESS VIOLATION immediately.
Best,
Tony
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and
bug reports, please send email to support_at_forth.com
----------------------------------------------------------------------
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and
bug reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Mon Oct 08 2007 - 20:13:15 PDT
This archive was generated by hypermail 2.2.0 : Tue Dec 02 2008 - 03:04:43 PST