From 7d74507aacb63f77b763c940ef6fb6c82cb2445a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 16 Jan 2012 09:50:11 +0200 Subject: Add SQL Server support --- schema/custom/database.hxx | 9 +++++++-- schema/custom/driver.cxx | 12 +++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'schema/custom') diff --git a/schema/custom/database.hxx b/schema/custom/database.hxx index 6f56224..9bb411d 100644 --- a/schema/custom/database.hxx +++ b/schema/custom/database.hxx @@ -24,6 +24,8 @@ # include #elif defined(DATABASE_ORACLE) # include +#elif defined(DATABASE_MSSQL) +# include #endif inline std::auto_ptr @@ -45,6 +47,8 @@ create_database (int& argc, char* argv[]) odb::pgsql::database::print_usage (cerr); #elif defined(DATABASE_ORACLE) odb::oracle::database::print_usage (cerr); +#elif defined(DATABASE_MSSQL) + odb::mssql::database::print_usage (cerr); #endif exit (0); @@ -59,8 +63,9 @@ create_database (int& argc, char* argv[]) #elif defined(DATABASE_PGSQL) auto_ptr db (new odb::pgsql::database (argc, argv)); #elif defined(DATABASE_ORACLE) - auto_ptr db ( - new odb::oracle::database (argc, argv)); + auto_ptr db (new odb::oracle::database (argc, argv)); +#elif defined(DATABASE_MSSQL) + auto_ptr db (new odb::mssql::database (argc, argv)); #endif return db; diff --git a/schema/custom/driver.cxx b/schema/custom/driver.cxx index a140ee1..cc1f3ea 100644 --- a/schema/custom/driver.cxx +++ b/schema/custom/driver.cxx @@ -27,7 +27,9 @@ main (int argc, char* argv[]) // Create the database schema. // -#if defined(DATABASE_MYSQL) || defined(DATABASE_SQLITE) +#if defined(DATABASE_MYSQL) || \ + defined(DATABASE_SQLITE) || \ + defined(DATABASE_MSSQL) { // Due to bugs in SQLite foreign key support for DDL statements, @@ -46,9 +48,9 @@ main (int argc, char* argv[]) // try { - db->execute ("DROP TABLE Employer"); - db->execute ("DROP TABLE Employee"); db->execute ("DROP TABLE EmployeeDegree"); + db->execute ("DROP TABLE Employee"); + db->execute ("DROP TABLE Employer"); } catch (const odb::exception&) { @@ -60,14 +62,14 @@ main (int argc, char* argv[]) db->execute ( "CREATE TABLE Employee (" - "ssn INTEGER UNSIGNED NOT NULL PRIMARY KEY," + "ssn INTEGER NOT NULL PRIMARY KEY," "first_name VARCHAR (255) NOT NULL," "last_name VARCHAR (255) NOT NULL," "employer VARCHAR (255) NOT NULL REFERENCES Employer (name))"); db->execute ( "CREATE TABLE EmployeeDegree (" - "ssn INTEGER UNSIGNED NOT NULL REFERENCES Employee (ssn)," + "ssn INTEGER NOT NULL REFERENCES Employee (ssn)," "degree VARCHAR (255) NOT NULL)"); t.commit (); -- cgit v1.1