扩展存储过程的问题,谢谢
描述:通过输入两个参数,得到输出参数:例如param1是 "你好 ",param2是 "谢谢 ",我想得到输出参数为 "param1=你好¶m2=谢谢 ",以下是我的程序,但我在sql server中执行不了,请高手指点,谢谢:
#include <stdafx.h>
#include "srv.h "
#define XP_NOERROR 0
#define XP_ERROR 1
#define MAXCOLNAME25
#define MAXNAME25
#define MAXTEXT255
#ifdef __cplusplus
extern "C " {
#endif
RETCODE __declspec(dllexport) xp_tongcardpos(SRV_PROC *srvproc);
#ifdef __cplusplus
}
#endif
RETCODE __declspec(dllexport) xp_tongcardpos(SRV_PROC *srvproc)
{
DBCHAR colname[MAXCOLNAME];
DBCHAR spName[MAXNAME];
DBCHAR spText[MAXTEXT];
DBCHAR spMerid[MAXTEXT];
BOOL bNull; // 记录入参是否为空(NULL)
PBYTE bType; // 入参的类型
ULONG uMaxLen = 20; // 入参的最大长度,令为20字节
ULONG uLen; // 入参的实际长度
//Send a text message
// Check that there are the correct number of parameters.
if ( srv_rpcparams(srvproc) != 1 )
{
// If there is not exactly one parameter, send an error to the client.
_snprintf(spText, MAXTEXT, "ERROR. You need to pass one parameter. ");
srv_sendmsg( srvproc, SRV_MSG_INFO, 0,(DBTINYINT)0,
(DBTINYINT)0,NULL,0,0,spText,SRV_NULLTERM);
// Signal the client that we are finished.
srv_senddone(srvproc, SRV_DONE_ERROR, (DBUSMALLINT)0, (DBINT)0);
return XP_ERROR;
}
// Get the info about the parameter.
// Note pass NULL for the pbData parameter to get
// information rather than the parameter itself.
srv_paraminfo(srvproc, 1, bType, &uMaxLen, &uLen, NULL, &bNull);
// Create some memory to get the parameter in to.
BYTE* Data = new BYTE[uLen];
memset(Data, '\0 ', uLen);
// Get the parameter
srv_paraminfo(srvproc, 1, bType, &uMaxLen, &uLen, Data, &bNull);
// Define column 1
_snprintf(colname, MAXCOLNAME, "ID ");
srv_describe(srvproc, 1, colname, SRV_NULLTERM, SRVINT4,
sizeof(DBSMALLINT), SRVINT2, sizeof(DBSMALLINT), 0);
// Define column 2
_snprintf(colname, MAXCOLNAME, "Hello World ");
srv_describe(srvproc, 2, colname, SRV_NULLTERM,
SRVCHAR, MAXTEXT, SRVCHAR, 0, NULL);
// Generate "numRows " output rows.
for ( long i = 1; i <= 5; i++ )
{
// Set the first column to be the count.
srv_setcoldata(srvproc, 1, &i);
// Set the second column to be a text string
int ColLength = _snprintf(spText, MAXTEXT,
"Hello from the extended stored procedure. %d ", i);
srv_setcoldata(srvproc, 2, spText);
srv_setcollen(srvproc, 2, ColLength);
// Send the row back to the client
srv_sendrow(srvproc);
}
// Tell the client we 're done and return the number of rows returned.
srv_senddone(srvproc, SRV_DONE_MORE | SRV_DONE_COUNT, (DBUSMALLINT)0, (DBINT)i);
return XP_NOERROR ;
}
[解决办法]
向楼主强烈学习:怎样写SQL SERVER2000的扩展存储过程,
请问楼主先生:您好!
有没有相关资料(怎样写SQL SERVER2000的扩展存储过程)提供下.
[解决办法]
if ( srv_rpcparams(srvproc) != 1 )
这一句的意思是只有一个输入参数。