mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-25 22:03:45 -06:00
MSSQL: MsSqlSequence
git-svn-id: svn://ultimatepp.org/upp/trunk@7772 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
24af0e755c
commit
edfb15fcfd
2 changed files with 35 additions and 0 deletions
|
|
@ -20,4 +20,18 @@ 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];
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -19,6 +19,27 @@ bool MSSQLPerformScript(const String& text, StatementExecutor& executor,
|
|||
void IdentityInsert(Sql& sql, const SqlInsert& ins);
|
||||
void IdentityInsert(const SqlInsert& ins);
|
||||
|
||||
class MsSqlSequence : public ValueGen {
|
||||
SqlId seq;
|
||||
SqlSession *session;
|
||||
|
||||
public:
|
||||
virtual Value Get();
|
||||
|
||||
Value operator++() { return Get(); }
|
||||
|
||||
void Set(SqlId id, SqlSession& s) { seq = id; session = &s; }
|
||||
|
||||
#ifndef NOAPPSQL
|
||||
void Set(SqlId id) { seq = id; session = NULL; }
|
||||
|
||||
MsSqlSequence(SqlId seq) { Set(seq); }
|
||||
#endif
|
||||
MsSqlSequence(SqlId seq, SqlSession& s) { Set(seq, s); }
|
||||
|
||||
MsSqlSequence() { session = NULL; }
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue