我有一个MS-SQL Server SP
ALTER PROCEDURE [dbo].[SP_OFFER_Existing_BFL_Result] ( @Name varchar(200),
@mobile varchar(50), @city varchar(200), @partner_ref_no varchar(200),
@partner_id varchar(50), @line_type varchar(50) )
AS
BEGIN
INSERT INTO [NSB].[dbo].[Request] (Name,Mobile,City,Partner_Ref_No,
Partner_ID, Line_Type, Enquiry_Request_Date)
VALUES(@Name, @mobile, @city, @partner_ref_no, @partner_id, @line_type,
GETDATE())
IF exists (SELECT 1 FROM [ [NSB].[dbo].[NSB_CT_API_TEST] WHERE
[Mobileno]=@mobile AND [PRODUCT_OFFERING_TYPE__C]=@line_type)
BEGIN
INSERT INTO [NSB].[dbo].[Response] ([Customer_Name], [Offer],
[Offer_Amount], [Offer_Expiry_Date], [Offer_Type], [Mobile_No],
[Response_Date_Time] )
SELECT [Customer_NAME], [Offer_status], [AMOUNT_Offer],
[Offer_Expiry_date], [PRODUCT_OFFERING_TYPE__C], [Mobileno], getdate() FROM
[ [NSB].[dbo].[NSB_CT_API_TEST] WHERE Mobileno=@mobile AND
[PRODUCT_OFFERING_TYPE__C]=@line_type
BEGIN
SELECT [Customer_NAME], [Offer_status], [AMOUNT_Offer],
[Offer_Expiry_date], [PRODUCT_OFFERING_TYPE__C], [Mobileno] FROM [ [NSB].
[dbo].[NSB_CT_API_TEST] WHERE [Mobileno]=@mobile AND
PRODUCT_OFFERING_TYPE__C=@line_type
END
END
ELSE
SELECT 'Customer does not exists' AS ERROR
END
当我通过SQL Server Management Studio执行它时,它会向我显示一行数据。但是当我通过我的代码调用此proc时,我没有得到任何回复。
理想情况下,最后一个选择
BEGIN
SELECT [Customer_NAME], [Offer_status], [AMOUNT_Offer],
[Offer_Expiry_date], [PRODUCT_OFFERING_TYPE__C], [Mobileno] FROM [ [NSB].
[dbo].[NSB_CT_API_TEST] WHERE [Mobileno]=@mobile AND
PRODUCT_OFFERING_TYPE__C=@line_type
END
这一定是我的输出。
Java代码:
logger.info("calling SP : SP_OFFER_Existing_BFL_Result ");
statement = conn.prepareCall("{call
SP_OFFER_Existing_BFL_Result(?,?,?,?,?,?)}");
statement.setString(1, request.getName());
statement.setString(2, request.getMobile());
statement.setString(3, request.getCity());
statement.setString(4, request.getRequestId());
statement.setString(5, request.getPartnerid());
statement.setString(6, request.getLinetype());
logger.info("Stored Procedure called");
logger.info("Stored Procedure called : " + statement);
boolean isReturned = statement.execute();
int updateCount = statement.getUpdateCount();
logger.info("isReturned : " + isReturned);
logger.info("update count : " + updateCount);
boolean hasResults = false;
hasResults = statement.getMoreResults();
logger.info("Has Results : " + hasResults);
if (hasResults) {
logger.info("SP Returned Data");
resultSet = statement.getResultSet();
} else {
logger.info("SP Returned No Data");
}
在这里提到一个类似的SP,如果我调用此SP,我也会从代码中获取数据。
ALTER PROCEDURE [dbo].[SP_OFFER_TABLE](@INPUT_CUSTOMER_MOBILE VARCHAR(30))
AS
IF exists (SELECT 1 FROM NSB.[dbo].[NSB_CT_API_TEST] WHERE
Mobileno=@INPUT_CUSTOMER_MOBILE)
BEGIN
INSERT INTO [dbo].[Response] (Customer_name ,Offer ,Offer_Amount
,Offer_Expiry_Date ,Offer_Type ,Mobile_No ,Created_Date )
SELECT Customer_Name, Offer_status, AMOUNT_Offer, Offer_Expiry_date,
PRODUCT_OFFERING_TYPE__C, Mobileno, GETDATE() AS Created_Date FROM NSB.
[dbo].[NSB_CT_API_TEST] WHERE Mobileno=@INPUT_CUSTOMER_MOBILE
SELECT Customer_Name, Offer_status, AMOUNT_Offer, Offer_Expiry_date,
PRODUCT_OFFERING_TYPE__C, Mobileno FROM NSB.[dbo].[NSB_CT_API_TEST] WHERE
Mobileno=@INPUT_CUSTOMER_MOBILE
END
ELSE
SELECT 'Customer does not exists' AS ERROR
请有人帮忙吗。