Here is the Sybase Stored Procedure:
CREATE PROCEDURE getAccountRefData
(
@application varchar(15),
@accountNumber char(9),
@accountSystem int
)
AS
BEGIN
/*
************************************************************************
Dynamic SQL for MDA
***********************************************************************
declare @execCmd varchar(250),@fixParam varchar(2000),@param1 varchar(8000)
select @fixParam = '[UniqueExecutionID ='+newid(1)+'][ServerUserID='+convert(varchar,suser_id())+'][HostName='+host_name()+']'
select @execCmd= ' exec getAccountRefData '
select @param1 = "@application="+case when @application is null then "NULL" else "'"+rtrim(@application)+"'" end +"," +
"@accountNumber="+case when @accountNumber is null then "NULL" else "'"+rtrim(@accountNumber)+"'" end +"," +
"@accountSystem="+case when @accountSystem is null then "NULL" else rtrim(convert(varchar,@accountSystem)) end
exec('--'+@fixParam+@execCmd+@param1)
/////////////////////////////////////////////////////////////////////
select DISTINCT TA.accountNumber, TA.accountSystemRN, TA.accountStatus, TA.accountCategoryRN,countryOfCitizenship, countryOfResidence,
TGA.fullname1, TGA.address1, TGA.city, TGA.stateCode, RN.refName, TGA.postalCode
from rdeTAPSAccount TA,
TAPSGeneralAddress TGA,
TAPSCustomerDesiStreetAccount TCDSA,
refName RN
where TA.accountNumber = TCDSA.accountNumber
and TA.accountSystemRN = TCDSA.accountSystemRN
and TCDSA.accountNumber = TGA.accountNumber
and TCDSA.accountSystemRN = TGA.accountSystemRN
and TGA.mainAddressInd = 'Y'
and TGA.countryCode = RN.refCode
and TA.accountNumber = @accountNumber
and TA.accountSystemRN = @accountSystem
end
**************************************
There are 4 params as follows:
0 - result - integer
1 - @application
2 - @accountNumber
3 - @accountSystem
-----------------------------------------------------------
Here is my Access VBA Code:
Private Sub Command9_Click()
Dim strApplication As String
Dim intAccountSystemRN As Integer
Dim strAccount As String
Dim rstQueryFS As ADODB.Recordset
Dim fld As ADODB.Field
Dim intCol As Integer
Dim intRow As Integer
Dim strSQL As String
Dim com As ADODB.Command
Dim strUserName As String
Dim strValue1 As String
Dim strValue2 As String
Dim strValue3 As String
Dim recNameAdress As ADODB.Recordset
Dim cmd As ADODB.Command
strApplication = "test"
strAccountNumber = "004P03732"
strAccountSystem = "1435"
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = CurrentProject.Connection
.CommandType = adCmdStoredProc
.CommandText = "getAccountRefData"
.Parameters.Append .CreateParameter("@application", adVarChar, adParamInput, 4, strApplication)
.Parameters.Append .CreateParameter("@accountNumber", adVarChar, adParamInput, 20, strAccountNumber)
.Parameters.Append .CreateParameter("@accountSystem", adVarChar, adParamInput, 4, strAccountSystem)
.Execute <------ COMPILER STOPS HERE and generates a Runtime error.
End With
|