diff --git a/uppsrc/MSSQL/MSSQL.cpp b/uppsrc/MSSQL/MSSQL.cpp new file mode 100644 index 000000000..c525b61e7 --- /dev/null +++ b/uppsrc/MSSQL/MSSQL.cpp @@ -0,0 +1,12 @@ +#include "MSSQL.h" + +namespace Upp { + +String MsSqlTextType(int width) +{ + if(width <= 4000) + return NFormat("varchar(%d)", width); + return "text"; +} + +}; \ No newline at end of file diff --git a/uppsrc/MSSQL/MSSQL.h b/uppsrc/MSSQL/MSSQL.h new file mode 100644 index 000000000..ab95a06e8 --- /dev/null +++ b/uppsrc/MSSQL/MSSQL.h @@ -0,0 +1,12 @@ +#ifndef _MSSQL_MSSQL_h +#define _MSSQL_MSSQL_h + +#include "ODBC/ODBC.h" + +namespace Upp { + +String MsSqlTextType(int width); + +}; + +#endif diff --git a/uppsrc/MSSQL/MSSQL.upp b/uppsrc/MSSQL/MSSQL.upp new file mode 100644 index 000000000..b0ea8247a --- /dev/null +++ b/uppsrc/MSSQL/MSSQL.upp @@ -0,0 +1,5 @@ +file + MSSQL.h, + MSSQLSchema.h, + MSSQL.cpp; + diff --git a/uppsrc/MSSQL/MSSQLSchema.h b/uppsrc/MSSQL/MSSQLSchema.h new file mode 100644 index 000000000..bc697d6b6 --- /dev/null +++ b/uppsrc/MSSQL/MSSQLSchema.h @@ -0,0 +1,104 @@ +#define BIT(x) COLUMN("bit", int, x, 0, 0) +#define BIT_ARRAY(x, items) COLUMN_ARRAY("bit", int, x, 0, 0, items) +#define BIT_(x) COLUMN_("bit", int, x, 0, 0) +#define BIT_ARRAY_(x, items) COLUMN_ARRAY_("bit", int, x, 0, 0, items) + +#define BOOL(x) COLUMN("char(1)", bool, x, 0, 0) +#define BOOL_ARRAY(x, items) COLUMN_ARRAY("char(1)", bool, x, 0, 0, items) +#define BOOL_(x) COLUMN_("char(1)", bool, x, 0, 0) +#define BOOL_ARRAY_(x, items) COLUMN_ARRAY_("char(1)", bool, x, 0, 0, items) + +#define INT64(x) COLUMN("bigint", int64, x, 0, 0) +#define INT64_ARRAY(x, items) COLUMN_ARRAY("bigint", int64, x, 0, 0, items) +#define INT64_(x) COLUMN_("bigint", int64, x, 0, 0) +#define INT64_ARRAY_(x, items) COLUMN_ARRAY_("bigint", int64, x, 0, 0, items) + +#define INT(x) COLUMN("integer", int, x, 0, 0) +#define INT_ARRAY(x, items) COLUMN_ARRAY("integer", int, x, 0, 0, items) +#define INT_(x) COLUMN_("integer", int, x, 0, 0) +#define INT_ARRAY_(x, items) COLUMN_ARRAY_("integer", int, x, 0, 0, items) + +#define DOUBLE(x) COLUMN("double precision", double, x, 0, 0) +#define DOUBLE_ARRAY(x, items) COLUMN_ARRAY("double precision", double, x, 0, 0, items) +#define DOUBLE_(x) COLUMN_("double precision", double, x, 0, 0) +#define DOUBLE_ARRAY_(x, items) COLUMN_ARRAY_("double precision", double, x, 0, 0, items) + +#define DATE(x) COLUMN("datetime", Date, x, 0, 0) +#define DATE_ARRAY(x, items) COLUMN_ARRAY("datetime", Date, x, 0, 0, items) +#define DATE_(x) COLUMN_("datetime", Date, x, 0, 0) +#define DATE_ARRAY_(x, items) COLUMN_ARRAY_("datetime", Date, x, 0, 0, items) + +#define TIME(x) COLUMN("datetime", Time, x, 0, 0) +#define TIME_ARRAY(x, items) COLUMN_ARRAY("datetime", Time, x, 0, 0, items) +#define TIME_(x) COLUMN_("datetime", Time, x, 0, 0) +#define TIME_ARRAY_(x, items) COLUMN_ARRAY_("datetime", Time, x, 0, 0, items) + +#define STRING(x, n) COLUMN(MsSqlTextType(n), String, x, n, 0) +#define STRING_ARRAY(x, n, items) COLUMN_ARRAY(MsSqlTextType(n), String, x, n, 0, items) +#define STRING_(x, n) COLUMN_(MsSqlTextType(n), String, x, n, 0) +#define STRING_ARRAY_(x, n, items) COLUMN_ARRAY_(MsSqlTextType(n), String, x, n, 0, items) + +#define LONGRAW(x) COLUMN("varbinary(max)", String, x, 0, 0) +#define LONGRAW_(x) COLUMN_("varbinary(max)", String, x, 0, 0) + +#define PRIMARY_KEY INLINE_ATTRIBUTE("primary key")\ + ATTRIBUTE("alter table @t add constraint PK_@x primary key "\ + "(@c)",\ + "alter table @t drop constraint PK_@x;")\ + ATTRIBUTE("create index PKX_@x on @t(@c);", \ + "drop index PKX_@x;") +#define KEY INLINE_ATTRIBUTE("key") +#define NOT_NULL INLINE_ATTRIBUTE("not null") +#define IDENTITY INLINE_ATTRIBUTE("identity") +#define AUTO_INCREMENT INLINE_ATTRIBUTE("identity") + +#define INDEX ATTRIBUTE("create index IDX_@x on @t(@c);", \ + "drop index IDX_@x;") +#define UNIQUE ATTRIBUTE("create unique index UNQ_@x on @t(@c);", \ + "drop index UNQ_@x;") +#define REFERENCES(x) ATTRIBUTE("alter table @t add constraint FK_@x foreign key "\ + "(@c) references @s" #x ";",\ + "alter table @t drop constraint FK_@x;") + +#define TIMESTAMP(ts) SCHEMA("-- " ts "\n\n", NULL) + +#define COMMENT(txt) SCHEMA("-- " #txt "\n", NULL) + +#include + +#undef INT +#undef INT_ARRAY +#undef INT_ +#undef INT_ARRAY_ + +#undef DOUBLE +#undef DOUBLE_ARRAY +#undef DOUBLE_ +#undef DOUBLE_ARRAY_ + +#undef DATE +#undef DATE_ARRAY +#undef DATE_ +#undef DATE_ARRAY_ + +#undef DATETIME +#undef DATETIME_ARRAY +#undef DATETIME_ +#undef DATETIME_ARRAY_ + +#undef STRING +#undef STRING_ARRAY +#undef STRING_ +#undef STRING_ARRAY_ + +#undef PRIMARY_KEY +#undef KEY +#undef NOT_NULL +#undef IDENTITY + +#undef INDEX + +#undef UNIQUE + +#undef TIMESTAMP +#undef COMMENT diff --git a/uppsrc/MSSQL/init b/uppsrc/MSSQL/init new file mode 100644 index 000000000..705659356 --- /dev/null +++ b/uppsrc/MSSQL/init @@ -0,0 +1,3 @@ +#ifndef _MSSQL_icpp_init_stub +#define _MSSQL_icpp_init_stub +#endif diff --git a/uppsrc/ODBC/ODBC.cpp b/uppsrc/ODBC/ODBC.cpp index 2e2de1f84..6172fa782 100644 --- a/uppsrc/ODBC/ODBC.cpp +++ b/uppsrc/ODBC/ODBC.cpp @@ -38,11 +38,13 @@ private: int rowsprocessed; Vector< Vector > number; + Vector< Vector > num64; Vector< Vector > text; Vector< Vector