KODevelopers 438 #1 Oluşturuldu: Temmuz 28, 2017 Merhaba.. Sql 2014 Procedure den çeviremedim. ancak yapamadım. LOAD_PREMIUM_SERVICE_USER bool CDBAgent::LoadPremiumServiceUser(string & strAccountID, CUser *pUser) { if (pUser == nullptr) return false; unique_ptr dbCommand(m_AccountDB->CreateCommand()); if (dbCommand.get() == nullptr) return false; dbCommand->AddParameter(SQL_PARAM_INPUT, strAccountID.c_str(), strAccountID.length()); if (!dbCommand->Execute(_T("{CALL LOAD_PREMIUM_SERVICE_USER(?)}"))) { ReportSQLError(m_AccountDB->GetError()); return false; } if (!dbCommand->hasData()) return false; char strPremium[30]; memset(strPremium, 0, sizeof(strPremium)); uint8 bPremiumCount = 0; dbCommand->FetchByte(1, pUser->m_bPremiumInUse); dbCommand->FetchByte(2, bPremiumCount); dbCommand->FetchBinary(3, strPremium, sizeof(strPremium)); for (int i = 0, index = 0; i < bPremiumCount; i++, index += 5) { uint8 bPremiumType = *(uint8*)(strPremium + index); uint32 iPremiumTime = *(uint32*)(strPremium + index + 1); if (iPremiumTime < UNIXTIME) continue; _PREMIUM_DATA *pPremium = new _PREMIUM_DATA; pPremium->bPremiumType = bPremiumType; pPremium->iPremiumTime = iPremiumTime; if (!pUser->m_PremiumMap.PutData(bPremiumType, pPremium)) delete pPremium; } if (pUser->m_PremiumMap.GetSize() == 0) { _PREMIUM_DATA *pPremium = new _PREMIUM_DATA; pPremium->bPremiumType = PremiumTypes::Dummy_Premium; pPremium->iPremiumTime = uint32(UNIXTIME) + 24 * 60 * 60 * 2; if (!pUser->m_PremiumMap.PutData(pPremium->bPremiumType, pPremium)) delete pPremium; else pUser->m_bPremiumInUse = PremiumTypes::Dummy_Premium; } else { if (pUser->m_PremiumMap.GetData(pUser->m_bPremiumInUse) == nullptr) { pUser->m_bPremiumInUse = NO_PREMIUM; foreach_stlmap(itr, pUser->m_PremiumMap) { _PREMIUM_DATA * uPrem = itr->second; if (uPrem == nullptr || uPrem->iPremiumTime == 0) continue; pUser->m_bPremiumInUse = uPrem->bPremiumType; break; } } } // this is hardcoded because we don't really care about the other mode if (pUser->m_bPremiumInUse != NO_PREMIUM) pUser->m_bAccountStatus = 1; // normal premium with expiry time else pUser->m_bAccountStatus = 0; return true; } SAVE_PREMIUM_SERVICE_USER bool CDBAgent::SavePremiumServiceUser(CUser *pUser) { if (pUser == nullptr) return false; unique_ptr dbCommand(m_AccountDB->CreateCommand()); if (dbCommand.get() == nullptr) return false; int8 bRet = -2; // generic error char strPremium[30]; int index = 0; memset(strPremium, 0, sizeof(strPremium)); int counter = 0; uint32 time = 0; foreach_stlmap(itr, pUser->m_PremiumMap) { if (itr->second == nullptr || itr->second->iPremiumTime < UNIXTIME || itr->second->bPremiumType == PremiumTypes::Dummy_Premium) continue; if (time < itr->second->iPremiumTime) time = itr->second->iPremiumTime; *(uint8 *)(strPremium + index) = itr->first; *(uint32 *)(strPremium + 1 + index) = itr->second->iPremiumTime; index += 5; counter++; } if (time > uint32(UNIXTIME)) time = uint32(time - UNIXTIME); // total premium seconds left dbCommand->AddParameter(SQL_PARAM_OUTPUT, &bRet); dbCommand->AddParameter(SQL_PARAM_INPUT, pUser->GetAccountName().c_str(), pUser->GetAccountName().length()); dbCommand->AddParameter(SQL_PARAM_INPUT, (char *)strPremium, sizeof(strPremium), SQL_BINARY); if (!dbCommand->Execute(string_format(_T("{? = CALL SAVE_PREMIUM_SERVICE_USER(?, ?, %d, %d, %d)}"), counter, pUser->m_bPremiumInUse == PremiumTypes::Dummy_Premium ? 0 : pUser->m_bPremiumInUse, time))) ReportSQLError(m_AccountDB->GetError()); return true; } Alıntı Yardımcı olmicaksa sorun yok Mesajı raporla İletiyi paylaş Link to post Sitelerde Paylaş
EveryBodyFool 198 #2 Temmuz 28, 2017 tarihinde gönderildi Tam olarak neyi yapamadığını anlamadım? Mesajı raporla İletiyi paylaş Link to post Sitelerde Paylaş
KODevelopers 438 #3 Konu Sahibi Temmuz 28, 2017 tarihinde gönderildi ALTER PROCEDURE den yapıyordum ancak uyumuyor.ALTER PROCEDURE [dbo].[LOAD_PREMIUM_SERVICE_USER]@strAccountID char(20),@strPremium int,@bTypes tinyint OUTPUTASDECLARE @bPremiumInUse tinyint-- Get the current premium expire time and current premium type.SELECT @bPremiumInUse = bPremiumType FROM TB_USER WHERE strAccountID = @strAccountIDSET @bTypes = @bPremiumInUse-- Check if the last premium expire date is null/empty or-- the hours between now and the last premium expire date is below or equal to 0BEGIN SET @bTypes = 0ENDALTER PROCEDURE [dbo].[SAVE_PREMIUM_SERVICE_USER]@strAccountID char(20),@strCharID char(20),@bType tinyint,@sTime smallintASDECLARE @dtExpiry datetimeSET @dtExpiry = DATEADD(HH, @sTime, GETDATE())UPDATE TB_USER SET bPremiumType = @bType, dtPremiumTime = @dtExpiry, sHours = @sTime WHERE strAccountID = @strAccountIDbenim yaptıkları yanlış mı acaba.Log hatası veriyor da[ ODBC Error - 29.7.2017 1:28:16 ] ] Source: {CALL LOAD_PREMIUM_SERVICE_USER(?)} Error: [Microsoft][SQL Server Native Client 11.0][SQL Server]Procedure or function 'LOAD_PREMIUM_SERVICE_USER' expects parameter '@bType', which was not supplied. Description: Failed to execute statement.[ ODBC Error - 29.7.2017 1:28:19 ] ] Source: {? = CALL SAVE_PREMIUM_SERVICE_USER(?, ?, 0, 205, 0)} Error: [Microsoft][SQL Server Native Client 11.0][SQL Server]Procedure or function SAVE_PREMIUM_SERVICE_USER has too many arguments specified. Description: Failed to execute statement.@ EveryBodyFool Mesajı raporla İletiyi paylaş Link to post Sitelerde Paylaş
Dawn 40 Admin #4 Temmuz 28, 2017 tarihinde gönderildi Prosedür ve src içindeki tanımlamalar birbiriyle uyuşmuyor. Mesajı raporla İletiyi paylaş Link to post Sitelerde Paylaş
KODevelopers 438 #5 Konu Sahibi Temmuz 28, 2017 tarihinde gönderildi @ Dawn evet sql verdigimi yanlış mı ? ALTER PROCEDURE [dbo].[LOAD_PREMIUM_SERVICE_USER] @strAccountID char(20), @strPremium int, @bType tinyint OUTPUT AS DECLARE @bPremiumInUse tinyint -- Get the current premium expire time and current premium type. SELECT @bPremiumInUse = bPremiumType FROM TB_USER WHERE strAccountID = @strAccountID SET @bType = @bPremiumInUse -- Check if the last premium expire date is null/empty or -- the hours between now and the last premium expire date is below or equal to 0 BEGIN SET @bType = 0 END ALTER PROCEDURE [dbo].[SAVE_PREMIUM_SERVICE_USER] @strAccountID char(20), @strCharID char(20), @bTypes tinyint, @sInUse smallint AS DECLARE @dtExpiry datetime SET @dtExpiry = DATEADD(HH, @sInUse, GETDATE()) UPDATE TB_USER SET bPremiumType = @bTypes, dtPremiumTime = @dtExpiry, sHours = @sInUse WHERE strAccountID = @strAccountID Mesajı raporla İletiyi paylaş Link to post Sitelerde Paylaş
EveryBodyFool 198 #6 Temmuz 28, 2017 tarihinde gönderildi Alıntı Prosedür ve src içindeki tanımlamalar birbiriyle uyuşmuyor. Aynen mertin de dediği gibi prosedür parametreleri eksik onları düzelt ama presedürler ile dosya tarafında yapılan işlemler arasında hiçbir bağlantı yok. İkiside çok ayrı kodlar bir yerden bulup aldıysan çalışmaz. Silip yeniden presedürlerine göre yazman gerekiyor. Yada dosyalarına göre prosedürleri düzenlemen gerekiyor. Mesajı raporla İletiyi paylaş Link to post Sitelerde Paylaş