Gryphyn
Joined: 20 Jan 2005 Posts: 431
|
Posted: Sat Aug 09, 2008 5:03 Post subject: SQLServer plugin |
|
|
SQLServer plugin
Well it's here... a SQLServer plugin for NWNX^2
There has been some major rework of the back-end hence the separate plugin, and not an extra option for the existing ODBC plugin.
I think the major 'usability' improvement, that you'll all love is the removal of all the SQL syntax string manipulation. It's still here, but you have an alternative where it's not required.
Introducing Parameters. Add a parameter indicator ('?') to your SQL Statement and this will be replaced by the value of a SQLBind...() function.
SQLPrepare("{call [stored_proc] (?)}");
// or SQLPrepare("select value from table where key=?");
SQLBindString("MyKey");
Note the new function SQLPrepare(), allows us to SQLBind...() variables, in sequence, before we SQLExecute(). If you are using parameters you must SQLPrepare() the SQL command first. Your SQL will be easier to write AND much easier to read.
Technically we've added 'usability' to Objects. Objects and other data types can now be returned in the same result set. No need for a separate query to get the Object data.
int i = SQLGetInt(1);
object o = SQLGetObject(2);
string s = SQLGetString(3);
will all work from the same result-set (*columns must be accessed in sequence)
NB: A special exception exists for SQLBindObject(). You can only bind one object per SQL statement and it MUST be the last parameter. Hint: adding Object data is best done via a stored procedure.
With the improvements to Object fetching, I no longer needed this - but I left it in, MARS - Multiple ACTIVE result sets. You can now have up to 4 active result sets. A new command SQLContext() enables you to switch between each 'context' to use the results of one as in 'input' for another, without destroying the original.
Getting into trouble? Full ODBC diagnostics are added into the log file, to assist with those queries that 'break' on you
You get all this and more...
(but only with SQLServer 2005 or better - defaulting to the EXPRESS editions *the free ones)
at the give-away price of - Oh yeah I'm giving it away!
Cheers
Gryphyn
PS. Compiled on VistaUltimate SP1 using VisualStudio2008.
I'll release the source once NWNX^2 goes semi-final for NWN1.69 |
|