Calling stored procedure from TQuery object
Posted: Thu 16 Dec 2004 14:59
We are migrating our application from BDE to SDAC, and it works overall very well. Where there are differences between BDE and SDAC in the behaviour we can at some points consider them ok, but we have some issues that we want to have some feedback on if it is possible.
Issue#1
when we execute this code, the parameter :Param will always be 0. If we change the SQL a little (adding a space for example) for each loop, it works.
Issue#2
When using CreateParam in the parameter class together with a stored procedure object, it will not work.
Issue#3
Under some conditions (have not found any pattern yet) string parameters get truncated on the way down to the database. we resolve it through always setting the size after assigning the string:
Issue #4
When using a dataset with FetchAll=false and the fast forward cursor, RecordCount only reflects the number of records currently read into the dataset. Is it possible that this will be changed in the future, so it reflects the number of records that can be fetched ?
Issue #5
When using TMSMetadata in order to get Primary keys, it sometimes does not return it correctly. Some of our tables that have more than one primary key still only returns the first one. The strange thing is that other tables that some have more than one primary key works. When removing and adding the PK:s a few times, it suddenly starts to work. We changed and started to read indexes instead, and checked which where primary keys. Any ideas what this can be ?
Issue #6
The SDAC stored procedure class behaves differently from BDE when re-assigning a StoredProcName. BDE did a Param check even when the New name was the same as the old. SDAC does not. If the user does
the stored procedure will fail. Therefore setting the storedprocname to something differently, so we force a param check.
We are using Borland C++Builder 5.0 Update 1
Microsoft SQL Server 2000
SDAC 3.00.2.9
Microsoft SQL Server: 08.00.0760
Microsoft OLE DB Provider for SQL Server: 08.50.1022
thanks in advance
Roger MÃ¥nsson
Issue#1
Code: Select all
// Query : TMSQuery
Query->Close();
Query->SQL->Text = "exec spStroredProc :Param";
for(int i = 0; iParamByName("Param")->AsString = i;
Query->ExecSQL();
}
Issue#2
When using CreateParam in the parameter class together with a stored procedure object, it will not work.
Code: Select all
//StoredProc : TMSStoredProc
StoredProc->StoredProcName = "spStoredProc"
StoredProc->Params->Clear();
StoredProc->Params->CreateParam(ftInteger, "@Param", ptInput);
StoredProc->Params->ParamByName("@Param")->AsInteger = 1;
StoredProc->ExecProc(); //If the param is required, an error will be thrown.
Under some conditions (have not found any pattern yet) string parameters get truncated on the way down to the database. we resolve it through always setting the size after assigning the string:
Code: Select all
//SDACParam : TMSParam
SDACParam->AsString = newValue;
SDACParam->Size = newValue.Length();
When using a dataset with FetchAll=false and the fast forward cursor, RecordCount only reflects the number of records currently read into the dataset. Is it possible that this will be changed in the future, so it reflects the number of records that can be fetched ?
Issue #5
When using TMSMetadata in order to get Primary keys, it sometimes does not return it correctly. Some of our tables that have more than one primary key still only returns the first one. The strange thing is that other tables that some have more than one primary key works. When removing and adding the PK:s a few times, it suddenly starts to work. We changed and started to read indexes instead, and checked which where primary keys. Any ideas what this can be ?
Issue #6
The SDAC stored procedure class behaves differently from BDE when re-assigning a StoredProcName. BDE did a Param check even when the New name was the same as the old. SDAC does not. If the user does
Code: Select all
sp->StoredProcName = "AStoredProcedureName"
sp->Params->Clear()
sp->StoredProcName = "AStoredProcedureName";
Code: Select all
if(NewName == SDACStoredProc->StoredProcName)
SDACStoredProc->StoredProcName = "DUMMYSTOREDPROCNAME";
SDACStoredProc->StoredProcName = NewName;
Microsoft SQL Server 2000
SDAC 3.00.2.9
Microsoft SQL Server: 08.00.0760
Microsoft OLE DB Provider for SQL Server: 08.50.1022
thanks in advance
Roger MÃ¥nsson