mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
OLEDB: GetInsertedId
git-svn-id: svn://ultimatepp.org/upp/trunk@558 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
08cfc0bf20
commit
be5574d065
2 changed files with 14 additions and 4 deletions
|
|
@ -1,5 +1,7 @@
|
|||
#include "OleDB.h"
|
||||
|
||||
#define LLOG(x)
|
||||
|
||||
#if defined(PLATFORM_WIN32) && defined(COMPILER_MSC)
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
|
@ -381,6 +383,7 @@ public:
|
|||
virtual SqlSession& GetSession() const { ASSERT(session); return *session; }
|
||||
virtual String GetUser() const { ASSERT(session); return session->user; }
|
||||
virtual String ToString() const;
|
||||
virtual Value GetInsertedId() const;
|
||||
|
||||
void Execute(IRef<IRowset> rowset);
|
||||
|
||||
|
|
@ -446,6 +449,12 @@ OleDBConnection::~OleDBConnection()
|
|||
Unlink();
|
||||
}
|
||||
|
||||
Value OleDBConnection::GetInsertedId() const
|
||||
{
|
||||
Sql sql(GetSession());
|
||||
return sql % Select(SqlId("@@IDENTITY")).Get();
|
||||
}
|
||||
|
||||
void OleDBConnection::Clear()
|
||||
{
|
||||
Cancel();
|
||||
|
|
@ -557,7 +566,7 @@ bool OleDBConnection::TryExecute()
|
|||
*t << statement << "\n";
|
||||
int args = 0;
|
||||
if(!session) {
|
||||
RLOG("OleDB Execute: invalid cursor (zombie state)");
|
||||
LLOG("OleDB Execute: invalid cursor (zombie state)");
|
||||
return false; // zombie state or closed session
|
||||
}
|
||||
if(!session->dbsession)
|
||||
|
|
@ -957,7 +966,7 @@ Array<OleDBSession::Provider> OleDBSession::EnumProviders()
|
|||
}
|
||||
}
|
||||
catch(Exc e) {
|
||||
RLOG("OleDB::GetProviders->" << e);
|
||||
LLOG("OleDB::GetProviders->" << e);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
|
@ -1038,7 +1047,7 @@ bool OleDBSession::OpenProp(String propset)
|
|||
void OleDBSession::Close()
|
||||
{
|
||||
if(!!dbsession && level > 0) {
|
||||
RLOG("OleDBSession::Close->transaction level = " << level);
|
||||
LLOG("OleDBSession::Close->transaction level = " << level);
|
||||
}
|
||||
while(!clink.IsEmpty()) {
|
||||
clink.GetNext()->Clear();
|
||||
|
|
@ -1048,7 +1057,7 @@ void OleDBSession::Close()
|
|||
transaction.Clear();
|
||||
dbsession.Clear();
|
||||
if(!!dbinit && FAILED(dbinit->Uninitialize())) {
|
||||
RLOG("OleDBSession::Close error, watch out for leaks!");
|
||||
LLOG("OleDBSession::Close error, watch out for leaks!");
|
||||
}
|
||||
dbinit.Clear();
|
||||
level = -1;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#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;")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue