|
Custom SQL query & .NET
|
|||
---|---|---|---|
#18+
Всем привет! Помогите пожалуйста, как решить проблему. I have an issue with the custom query in my .NET application. I have 4 parameters in the custom query- three Strings and one Integer. The query works fine when I passed only string parameters. When I added another parameter as an integer to select top max records, no records returned from the database in my vb.net application. It works correct and tested without issues in WinSQL or from Cache System Management Portal. See my code here: GetTVRefNosForLicenceName(): Query GetTVRefNosForLicenceName( SearchMax As %Integer , SearchFirstName As %String, SearchSurname As %String, SearchAddress As %String) As %SQLQuery (ROWSPEC = "TVRefNo:%String, LicenceFirstName:%String, LicenceSurname:%String, LicenceAddress1:%String, LicenceAddress2:%String, LicenceAddress3:%String, LicenceAddress4:%String, LicenceIssueDate:%Date, LicenceExpiryDate:%Date, LicencePrintDate:%Date") [ SqlProc ] { } GetTVRefNosForLicenceNameExecute(): /// Execute method for GetTVRefNosForLicenceName custom query ClassMethod GetTVRefNosForLicenceNameExecute(ByRef qHandle As %Binary, SearchMax As %Integer, SearchFirstName As %String, SearchSurname As %String, SearchAddress As %String) As %Status { // initialise the return status set ReturnStatus = $$$OK // main code block try { // build the query set sql = "select top ?" set sql = sql _ " tvrefno, licencefirstname, licencesurname, licenceaddress1, licenceaddress2, licenceaddress3, licenceaddress4, licenceissuedate, licenceexpirydate, licenceprintdate" set sql = sql _ " from epay.v_licencehistorylatest" set sql = sql _ " where (licencefirstname LIKE ?)" set sql = sql _ " and (licencesurname LIKE ?)" set sql = sql _ " and (DisplayAddressSingleLine LIKE ?)" // create, prepare and execute the resultset set rsTVRefNoSearch = ##class(%ResultSet).%New() set PrepareStatus = rsTVRefNoSearch.Prepare(sql) if $$$ISERR(PrepareStatus) throw ##class(%Exception.StatusException).CreateFromStatus(PrepareStatus) set ExecuteStatus = rsTVRefNoSearch.Execute(SearchMax, SearchFirstName, SearchSurname, SearchAddress) if $$$ISERR(ExecuteStatus) throw ##class(%Exception.StatusException).CreateFromStatus(ExecuteStatus) // store the resultset in the handle set qHandle = rsTVRefNoSearch } // main error handler catch e { // set the return status set ReturnStatus = $$$ERROR($$$GeneralError, "Error in " _ ..%ClassName(1) _ ".GetTVRefNosForLicenceNameExecute[#]SearchMax=" _ SearchMax _ "[~]SearchFirstName=" _ SearchFirstName _ "[~]SearchSurname=" _ SearchSurname _ "SearchAddress=" _ SearchAddress _ "[#]"_ e.DisplayString()) } // quit the return status QUIT ReturnStatus } GetTVRefNosForLicenceNameFetch(): /// Fetch method for GetTVRefNosForLicenceName custom query ClassMethod GetTVRefNosForLicenceNameFetch(ByRef qHandle As %Binary, ByRef Row As %List, ByRef AtEnd As %Integer = 0) As %Status [ PlaceAfter = GetTVRefNosForLicenceNameExecute ] { // initialise the return status set ReturnStatus = $$$OK // main code block try { // retrieve the resultset from the handle set rsTVRefNoSearch = qHandle // check for next record in the resultset if rsTVRefNoSearch.Next() { // retrieve the field values from the current row in the resultset set TVRefNo = rsTVRefNoSearch.Get("TVRefNo") set LicenceFirstName = rsTVRefNoSearch.Get("LicenceFirstName") set LicenceSurname = rsTVRefNoSearch.Get("LicenceSurname") set LicenceAddress1 = rsTVRefNoSearch.Get("LicenceAddress1") set LicenceAddress2 = rsTVRefNoSearch.Get("LicenceAddress2") set LicenceAddress3 = rsTVRefNoSearch.Get("LicenceAddress3") set LicenceAddress4 = rsTVRefNoSearch.Get("LicenceAddress4") set LicenceIssueDate = rsTVRefNoSearch.Get("LicenceIssueDate") set LicenceExpiryDate = rsTVRefNoSearch.Get("LicenceExpiryDate") set LicencePrintDate = rsTVRefNoSearch.Get("LicencePrintDate") // build the row according to the row specification set Row = $lb(TVRefNo, LicenceFirstName, LicenceSurname, LicenceAddress1, LicenceAddress2, LicenceAddress3, LicenceAddress4, LicenceIssueDate, LicenceExpiryDate, LicencePrintDate) } // there are no more records left to fetch else { // tell the query processor to stop by setting these variables set Row = "" set AtEnd = 1 } } // main error handler catch e { // set the return status set ReturnStatus = $$$ERROR($$$GeneralError, "Error in " _ ..%ClassName(1) _ ".GetTVRefNosForLicenceNameFetch[#][#]"_ e.DisplayString()) } // quit the return status QUIT ReturnStatus } GetTVRefNosForLicenceNameClose(): /// Close method for GetTVRefNosForLicenceName custom query ClassMethod GetTVRefNosForLicenceNameClose(ByRef qHandle As %Binary) As %Status [ PlaceAfter = GetTVRefNosForLicenceNameExecute ] { // initialise the return status set ReturnStatus = $$$OK // main code block try { set rsEmolumentsSummary = qHandle do rsEmolumentsSummary.%Close() } // main error handler catch e { // set the return status set ReturnStatus = $$$ERROR($$$GeneralError, "Error in " _ ..%ClassName(1) _ ".GetTVRefNosForLicenceNameClose[#][#]"_ e.DisplayString()) } // quit the return status QUIT ReturnStatus } Код: plaintext 1.
Спасибо. ... |
|||
:
Нравится:
Не нравится:
|
|||
22.10.2013, 14:56 |
|
Custom SQL query & .NET
|
|||
---|---|---|---|
#18+
А ошибки кроме того что пустой вывод еще есть ? может просто неверно доходит значение до Cache ? и рекомендую переделать с использования %Library.ResultSet на более современные и более быстрые %ResultSet.SQL или %SQL.Statement а в вашем коде вообще скорее всего можно обойтись Embeded SQL ... |
|||
:
Нравится:
Не нравится:
|
|||
22.10.2013, 15:32 |
|
Custom SQL query & .NET
|
|||
---|---|---|---|
#18+
DAiMorА ошибки кроме того что пустой вывод еще есть ? Ошибок никаких не выдает. DAiMorможет просто неверно доходит значение до Cache ? У меня тоже такое подозрение, что неверно доходит значение до Cache. Не знаю как проверить, из .NET выходит все правильно ... DAiMorа в вашем коде вообще скорее всего можно обойтись Embeded SQL Наверное так и сделаю... ... |
|||
:
Нравится:
Не нравится:
|
|||
22.10.2013, 15:59 |
|
Custom SQL query & .NET
|
|||
---|---|---|---|
#18+
vichkaDAiMorможет просто неверно доходит значение до Cache ? У меня тоже такое подозрение, что неверно доходит значение до Cache. Не знаю как проверить, из .NET выходит все правильно ... ну это проверить то как раз достаточно просто, залогируйте в глобал те значения которые приходят в Query метод Execute. ... |
|||
:
Нравится:
Не нравится:
|
|||
22.10.2013, 16:14 |
|
|
start [/forum/topic.php?fid=39&msg=38437328&tid=1557040]: |
0ms |
get settings: |
8ms |
get forum list: |
15ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
168ms |
get topic data: |
10ms |
get forum data: |
2ms |
get page messages: |
47ms |
get tp. blocked users: |
2ms |
others: | 12ms |
total: | 272ms |
0 / 0 |