下面是API,我需要创建一个新的存储过程以返回它。 “ MemberCard”之前的上部具有可以输出的存储过程,“ MemberCard”的子详细信息也具有其自己的存储过程。如何以下面相同的格式合并2个存储过程的结果集?还是应该使用Java API来合并2个sp的结果集?
示例响应:
{
"Action":"MemberLogin3",
"CardNumber":"00000376",
"MemberMobilePhone":"94600240",
"SMSValidation":1,
"MemberToken":"",
"PWDFailRetryCount":10,
"CheckResult":"0",
"EmailValidation":1,
"ResponseCode":0,
"Type":"Manual",
"MemberCreatedOn":"2014-12-16 09:33:04",
"MemberID":49,
"MemberDefLanguage":"us",
"CountryCode":"00852",
"ReadReguFlag":0,
"MemberCard":[
{
"OctopusID":"12455678|0",
"BrandPicGFile":"",
"CardTypeName":"",
"CardExpiryDate":"2075-04-01",
"CardGradePicFile":"/tap/FileManagement/26/20120702_629Tvi.png",
"MinPointPreAdd":"",
"MinPointPreTransfer":"",
"TotalPoints":"1000",
"CardGrade":"1",
"BrandID":"1",
"MaxPointPreTransfer":"0",
"MemberSex":"2",
"HomeTelNum":"29504288",
"BrandPicSFile":"",
"MemberEngGivenName":"",
"CountryCode":"852",
"MaxAmountPreTransfer":"",
"LaserID":"",
"MaxAmountPreAdd":"1000.0000",
"CardNumber":"000100086",
"CardPointToAmountRate":"100.000000",
"GracePeriodValue":"",
"BrandPicMFile":"",
"MaxPointPreAdd":"",
"MinAmountPreAdd":"100.0000",
"MemberRegisterMobile":"85294906037",
"CardGradeNotes":"",
"MemberYearofBirth":"1985",
"GracePeriodUnit":"",
"MemberIdentityRef":"",
"MemberEngFamilyName":"",
"MemberIdentityType":"",
"MemberMonthofBirth":"6",
"CardGradeMaxPoint":"",
"CardTypeID":"",
"MemberDayofBirth":"1985-06-04",
"MemberChiFamilyName":"",
"MemberChiGivenName":"",
"MinAmountPreTransfer":"",
"CardStatus":"2",
"TotalAmount":"1000.00",
"CardAmountToPointRate":"1.000000",
"MemberMobilePhone":"94906037",
"CardAmountExpiryDate":"2013-10-17",
"CardPointExpiryDate":"2013-10-17",
"UpdatedOn":"2014-04-17 14:50:10",
"MemberQRCode":"Q7FM1110339d9b35928d4b8f09235b87a4cd1dd23cf404b"
}
]
}
答案 0 :(得分:0)
以下是将结果集组合到单个SP中的方法
查询存储过程的示例
SELECT
M.Action,
M.CardNumber,
M.MemberMobilePhone,
M.SMSValidation,
M.MemberToken
--Other fields from Member table
MC.OctopusID,
MC.BrandPicGFile,
MC.CardTypeName,
MC.CardExpiryDate
-- Other fields from MemberCard table
FROM Member M
LEFT OUTER JOIN MemberCard MC ON MC.MemberId = M.MemberId
--Your filter conditions etc
您没有提到合并为单个SP的目的,但是如果您希望减少数据库调用,则可以考虑上述方法。另外,如果结果集较大,则在SQL查询中应用分页。