Delphi Write Sql2000 extended Stored procedure Example

Source: Internet
Author: User
Tags stored procedure example

Library Project1;

Uses
Windows
Sysutils,
Msodsapi;
  
... {$R *.res}
Function Getparamstr (Psrvproc:srv_proc; Index:integer; Var param:string): integer;
Var
Ptype:byte;
Cbmaxlen, Paralen:dword;
Isnull:bool;
Begin
Result: = No_error;
Srv_paraminfo (Psrvproc, Index, @PType, @cbMaxLen, @ParaLen, NIL, @IsNULL);
  
If ptype in [Srvtext,srvvarchar,srvchar,srvntext,
Srvbigvarchar,srvbigchar,srvnvarchar,srvnchar] Then
Begin
Param: = ';
If Paralen>0 then BEGIN
SetLength (Param, Paralen);
Srv_paraminfo (Psrvproc, Index, @PType, @cbMaxLen, @ParaLen, @Param [1], @IsNULL);
End
End
ELSE begin
Result: =-1;
End
End
  
Function Eppackfile (Psrvproc:srv_proc): integer;cdecl;
Var
ls1,ls2,ls3:string;
N:integer;
Begin
  
Result: = 1;
N: = Srv_rpcparams (Psrvproc);
If n <> 3 then BEGIN
is not a 3 parameter
End
if (Getparamstr (PSRVPROC,1,LS1) <>no_error) THEN BEGIN
Not a string
End
if (Getparamstr (PSRVPROC,2,LS2) <>no_error) THEN BEGIN
Not a string
End
if (Getparamstr (PSRVPROC,3,LS3) <>no_error) THEN BEGIN
Not a string
End
N: = Length (LS1);
Srv_describe (Psrvproc, 1, ' Parameters ', Srv_nullterm, Srvbigvarchar,
N, Srvbigvarchar, N, NIL);
Srv_setcoldata (Psrvproc, 1, @ls1 [1]);
Srv_sendrow (PSRVPROC);
Srv_setcoldata (Psrvproc, 1, @ls2 [1]);
Srv_sendrow (PSRVPROC);
Srv_setcoldata (Psrvproc, 1, @ls3 [1]);
Srv_sendrow (PSRVPROC);
Srv_senddone (Psrvproc, (Srv_done_count or Srv_done_more), 0, 1);
End
  
Exports
Eppackfile Name ' Xp_eppackfile ';
Begin
End.

After compiling, put the Binn directory, add and test in SQL, the code is as follows:

Use Master;
IF object_id('xp_EpPackFile') IS NOT NULL EXEC sp_dropextendedproc 'xp_EpPackFile';
EXEC sp_addextendedproc 'xp_EpPackFile', 'project1.dll';
EXEC master..xp_EpPackFile 'aa','bb','cc';
EXEC sp_dropextendedproc 'xp_EpPackFile';
DBCC SPEncrypt(FREE);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.