ultimatepp/uppsrc/MSSQL/MSSQL.cpp
cxl c11d899cb9 MSSQL: MsSqlSequence
git-svn-id: svn://ultimatepp.org/upp/trunk@7772 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2014-10-13 07:07:56 +00:00

37 lines
697 B
C++

#include "MSSQL.h"
namespace Upp {
String MsSqlTextType(int width)
{
if(width <= 4000)
return NFormat("varchar(%d)", width);
return "text";
}
void IdentityInsert(Sql& sql, const SqlInsert& ins)
{
sql.Execute("SET IDENTITY_INSERT " + ins.GetTable().ToString() + " ON;" +
((SqlStatement)ins).Get(MSSQL));
}
void IdentityInsert(const SqlInsert& ins)
{
IdentityInsert(SQL, ins);
}
Value MsSqlSequence::Get()
{
#ifndef NOAPPSQL
Sql sql(session ? *session : SQL.GetSession());
#else
ASSERT(session);
Sql sql(*session);
#endif
if(!sql.Execute("select next value for " + ~seq) || !sql.Fetch())
return ErrorValue();
return sql[0];
}
};