Exemple #1
0
void pgSequence::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
{
	UpdateValues();
	if (properties)
	{
		CreateListColumns(properties);

		properties->AppendItem(_("Name"), GetName());
		properties->AppendItem(_("OID"), GetOid());
		properties->AppendItem(_("Owner"), GetOwner());
		properties->AppendItem(_("ACL"), GetAcl());
		properties->AppendItem(_("Current value"), GetLastValue());
		properties->AppendItem(_("Next value"), GetNextValue());
		properties->AppendItem(_("Minimum"), GetMinValue());
		properties->AppendItem(_("Maximum"), GetMaxValue());
		properties->AppendItem(_("Increment"), GetIncrement());
		properties->AppendItem(_("Cache"), GetCacheValue());
		properties->AppendYesNoItem(_("Cycled?"), GetCycled());
		properties->AppendYesNoItem(_("Called?"), GetCalled());
		properties->AppendYesNoItem(_("System sequence?"), GetSystemObject());
		properties->AppendItem(_("Comment"), firstLineOnly(GetComment()));

		if (!GetLabels().IsEmpty())
		{
			wxArrayString seclabels = GetProviderLabelArray();
			if (seclabels.GetCount() > 0)
			{
				for (unsigned int index = 0 ; index < seclabels.GetCount() - 1 ; index += 2)
				{
					properties->AppendItem(seclabels.Item(index), seclabels.Item(index + 1));
				}
			}
		}
	}
}
Exemple #2
0
wxString pgSequence::GetSql(ctlTree *browser)
{
	if (sql.IsNull())
	{
		UpdateValues();
		sql = wxT("-- Sequence: ") + GetQuotedFullIdentifier() + wxT("\n\n")
		      + wxT("-- DROP SEQUENCE ") + GetQuotedFullIdentifier() + wxT(";")
		      + wxT("\n\nCREATE SEQUENCE ") + GetQuotedFullIdentifier()
		      + wxT("\n  INCREMENT ") + GetIncrement().ToString()
		      + wxT("\n  MINVALUE ") + GetMinValue().ToString()
		      + wxT("\n  MAXVALUE ") + GetMaxValue().ToString()
		      + wxT("\n  START ") + GetLastValue().ToString()
		      + wxT("\n  CACHE ") + GetCacheValue().ToString();
		if (GetCycled())
			sql += wxT("\n  CYCLE");
		sql += wxT(";\n")
		       + GetOwnerSql(7, 3, wxT("TABLE ") + GetQuotedFullIdentifier());

		if (!GetConnection()->BackendMinimumVersion(8, 2))
			sql += GetGrant(wxT("arwdRxt"), wxT("TABLE ") + GetQuotedFullIdentifier());
		else
			sql += GetGrant(wxT("rwU"), wxT("TABLE ") + GetQuotedFullIdentifier());

		sql += GetCommentSql();

		if (GetConnection()->BackendMinimumVersion(9, 1))
			sql += GetSeqLabelsSql();
	}

	return sql;
}
void pgSequence::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
{
    UpdateValues();
    if (properties)
    {
        CreateListColumns(properties);

        properties->AppendItem(_("Name"), GetName());
        properties->AppendItem(_("OID"), GetOid());
        properties->AppendItem(_("Owner"), GetOwner());
        properties->AppendItem(_("ACL"), GetAcl());
        properties->AppendItem(_("Current value"), GetLastValue());
        properties->AppendItem(_("Minimum"), GetMinValue());
        properties->AppendItem(_("Maximum"), GetMaxValue());
        properties->AppendItem(_("Increment"), GetIncrement());
        properties->AppendItem(_("Cache"), GetCacheValue());
        properties->AppendItem(_("Cycled?"), GetCycled());
        properties->AppendItem(_("Called?"), GetCalled());
        properties->AppendItem(_("System sequence?"), GetSystemObject());
        properties->AppendItem(_("Comment"), firstLineOnly(GetComment()));
    }
}
Exemple #4
0
// Default implementation for RFX functions
void CDaoFieldExchange::Default(LPCTSTR lpszName, void* pv,
	DWORD dwColumnType, DWORD dwBindOptions)
{
	switch (m_nOperation)
	{
	case AddToParameterList:
		if (m_nParam != 1)
			m_prs->m_strSQL += ",";
		m_prs->m_strSQL += lpszName;
		AppendParamType(m_prs->m_strSQL, dwColumnType);
		return;

	case AddToSelectList:
		if (m_nField != 1)
			m_prs->m_strSQL += ",";
		m_prs->m_strSQL += lpszName;
		return;

	case BindField:
		{
			// Query parser needs "[" & "]", GetRows can't tolerate them.
			LPTSTR lpszNoBracketName = new TCHAR[lstrlen(lpszName) + 1];
			m_prs->StripBrackets(lpszName, lpszNoBracketName);

			// Finish setting up column binding info struct
			LPDAOCOLUMNBINDING pcb =
				&m_prs->m_prgDaoColBindInfo[m_nField-1];
			pcb->cbInfoOffset =
				(DWORD)&m_prs->m_pulColumnLengths[m_nField-1];
#ifndef _UNICODE
			pcb->columnID.dwKind = DAOCOLKIND_STR;
			pcb->columnID.lpstr = lpszNoBracketName;
#else
			pcb->columnID.dwKind = DAOCOLKIND_WSTR;
			pcb->columnID.lpwstr = lpszNoBracketName;
#endif

			// Setup the field index map (and store value as void ptr)
			m_prs->m_pMapFieldIndex->SetAt(pv, (void*)m_nField);
		}
		return;

	case BindParam:
		{
			COleVariant* pvar = NULL;

			TRY
			{
				// NULL params not supported, use IS NULL in SQL
				// (i.e. - m_strFilter = _T("Foo IS NULL");
				FillVariant(pv, dwColumnType, &pvar);
				m_prs->m_pQueryDef->SetParamValue(lpszName, *pvar);
			}
			CATCH_ALL(e)
			{
				if (pvar != NULL)
					pvar->Clear();
				delete pvar;
				pvar = NULL;
				THROW_LAST();
			}
			END_CATCH_ALL

			pvar->Clear();
			delete pvar;
			pvar = NULL;
		}
		return;

	case Fixup:
		if (m_prs->GetFieldLength(m_nField-1) == DAO_NULL)
		{
			// Set the value to PSEUDO NULL and mark the status NULL
			SetNullValue(pv, dwColumnType);
			m_prs->SetNullFieldStatus(m_nField-1);
		}
		return;

	case AllocCache:
		if (dwBindOptions & AFX_DAO_ENABLE_FIELD_CACHE)
		{
			CDaoFieldCache* pCache;

			// Allocate new storage and add to map
			AllocCacheValue(pCache, dwColumnType);
			m_prs->m_pMapFieldCache->SetAt(pv, pCache);
		}
		return;

	case StoreField:
		if (dwBindOptions & AFX_DAO_ENABLE_FIELD_CACHE)
		{
			CDaoFieldCache* pCache = GetCacheValue(m_prs, pv);

			// Copy the data to the cache
			if (dwBindOptions & AFX_DAO_CACHE_BY_VALUE)
				CopyValue(pv, (void*)&pCache->m_pvData, dwColumnType);
			else
				CopyValue(pv, pCache->m_pvData, dwColumnType);

			// Cache the NULL status
			if (m_prs->IsFieldStatusNull(m_nField-1))
				pCache->m_nStatus |= AFX_DAO_FIELD_FLAG_NULL;
			else
				pCache->m_nStatus &= ~AFX_DAO_FIELD_FLAG_NULL;
		}
		return;

	case LoadField:
		if (dwBindOptions & AFX_DAO_ENABLE_FIELD_CACHE)
		{
			CDaoFieldCache* pCache = GetCacheValue(m_prs, pv);

			// Copy the data from the cache
			if (dwBindOptions & AFX_DAO_CACHE_BY_VALUE)
				CopyValue((void*)&pCache->m_pvData, pv, dwColumnType);
			else
				CopyValue(pCache->m_pvData, pv, dwColumnType);

			// Set the NULL status from the cache
			if (pCache->m_nStatus & AFX_DAO_FIELD_FLAG_NULL)
				m_prs->SetNullFieldStatus(m_nField-1);
			else
				m_prs->ClearNullFieldStatus(m_nField-1);
		}
		return;

	case SetFieldNull:
		// Setting field NOT NULL doesn't require field exchange
		if ((m_pvField == NULL && m_nFieldType == outputColumn)
			|| m_pvField == pv)
		{
			SetNullValue(pv, dwColumnType);

			// Also set the status array if not a parameter
			if (m_nFieldType == outputColumn)
				m_prs->SetNullFieldStatus(m_nField-1);

#ifdef _DEBUG
			m_nFieldFound = m_nField;
#endif
		}
		return;

	case MarkForAddNew:
		if (dwBindOptions & AFX_DAO_ENABLE_FIELD_CACHE)
		{
			// Don't need to do anything if field marked dirty
			if (!m_prs->IsFieldStatusDirty(m_nField-1))
			{
				// Mark dirty & not NULL if not set to pseudo NULL value
				if (!IsNullValue(pv, dwColumnType))
				{
					m_prs->SetDirtyFieldStatus(m_nField-1);
					m_prs->ClearNullFieldStatus(m_nField-1);
				}
			}
		}
		return;

	case MarkForEdit:
		if (dwBindOptions & AFX_DAO_ENABLE_FIELD_CACHE)
		{
			// If value not pseudo NULL value, clear NULL status
			if (!IsNullValue(pv, dwColumnType))
				m_prs->ClearNullFieldStatus(m_nField-1);

			// If field already marked dirty, don't need to check cache
			if (!m_prs->IsFieldStatusDirty(m_nField-1))
			{
				CDaoFieldCache* pCache = GetCacheValue(m_prs, pv);

				BOOL bNullField = m_prs->IsFieldStatusNull(m_nField-1);
				BOOL bNullCache = pCache->m_nStatus & AFX_DAO_FIELD_FLAG_NULL;

				void* pvData;
				if (dwBindOptions & AFX_DAO_CACHE_BY_VALUE)
					pvData = &pCache->m_pvData;
				else
					pvData = pCache->m_pvData;

				// Mark dirty if NULL status differs or value differs
				if ( (bNullCache && !bNullField) ||
					(!bNullCache && bNullField) ||
					CompareValue(pv, pvData, dwColumnType))
				{
					m_prs->SetDirtyFieldStatus(m_nField-1);
				}
			}
		}
		return;

	case SetDirtyField:
		if (m_prs->IsFieldStatusDirty(m_nField-1))
		{
			COleVariant* pvar = NULL;

			TRY
			{
				// If field is NULL don't set the value
				if (!m_prs->IsFieldStatusNull(m_nField-1))
					FillVariant(pv, dwColumnType, &pvar);
				else
				{
					pvar = new COleVariant;
					pvar->vt = VT_NULL;
				}

				// SetFieldValue (put_Collect) doesn't like brackets
				// Assumes no brackets if first char not a bracket
				LPTSTR lpszModifiedName = NULL;
				if (*lpszName == '[')
				{
					lpszModifiedName = new TCHAR[_tcslen(lpszName) + 1];

					// Copy the name with no brackets, and reset lpszName
					m_prs->StripBrackets(lpszName, lpszModifiedName);
					lpszName = lpszModifiedName;
				}

				m_prs->SetFieldValue(lpszName, *pvar);
				delete lpszModifiedName;
			}
			CATCH_ALL(e)
			{
				if (pvar != NULL)
					pvar->Clear();
				delete pvar;
				pvar = NULL;
				THROW_LAST();
			}
			END_CATCH_ALL

			pvar->Clear();
			delete pvar;
			pvar = NULL;
		}
		return;

	default:
		ASSERT(FALSE);
		return;
	}