Mem,
I'm not really sure to understand your strategy:
a) SELECT AddGeometryColumn(...)
is the Spatial-aware equivalent of
ALTER TABLE ... CREATE COLUMN ...
so you can successfully execute
AddGeometryColumn() only once in
the table life-cycle (at creation time).
b) determining if any given Geometry column
can / cannot accept NULL values is completely
under your responsibility.
Please, see the latest (optional) arg
you can pass to AddGeometryColumn():
default is = accept NULLs, but you can
explicitly select the opposite behaviours:
SELECT AddGeometryColumn('Acquisitions', 'FOOTPRINT', 4326,
'LINESTRING', 'XY', 1);
c) there is any need at all to get a BLOB
object from the DBMS (actually, this will
simply cause a system crash, because
querying an empty geometry will return
a NULL pointer, i.e. an invalid reference).
Creating the BLOB (i.e. nothing more than a
trivial byte array, from the language own
perspective) falls under your direct
responsibility. And initializing the
array with appropriate bytes is under
your responsibility as well.
Conclusion: I see no need at all to implement
such a complex two-steps mechanism, because
you can directly bind any required parameter
(this including geometry) and then duly
INSERT a row into the DBMS table.
Test the following simple example
(pseudo-code, fantasy language):
// creating a test table
STRING sql = "CREATE TABLE test (";
sql += "id INTEGER NOT NULL,";
sql += "name TEXT NOT NULL)";
Execute(sql);
// creating a geometry column
sql = "SELECT AddGeometryColumn(";
sql += "'test', 'geom', 4326, ";
sql += "'LINESTRING', 'XY')";
Execute(sql);
// creating the SQL INSERT stmt
sql = "INSERT INTO test (id, name, geom) ";
sql += "VALUES (?, ?, ";
sql += "GeomFromText(?, 4326))";
STATEMENT stmt = CreateStatement(sql);
// inserting a row
INT id = 1;
STRING name = "alpha";
STRING line = "LINESTRING(1.1 2.2, ";
line += "3.3 4.4, 5.5 6.6, 7.7 8.8)";
stmt->BindIntValue(1, id);
stmt->BindStringValue(2, name);
stmt->BindStringValue(3, pt);
stmt->Execute();
bye
Sandro