Home > database >  Pb invokes the stored procedures problem. Please help take a look.
Pb invokes the stored procedures problem. Please help take a look.

Time:10-05

-- -- -- -- -- -- -- -- -- -- - the process is as follows -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
The ALTER proc proc_restoredata
@ bkfilepath varchar (200), @ database_name varchar (100), @ ls_err varchar (200) the output
As
The begin
Declare @ data_lname varchar (100)
Declare @ log_lname varchar (100)
Declare @ data_path varchar (500)
Declare @ log_path varchar (500)
The create table # t (logicalname nvarchar (200),
Physicalname nvarchar (200),
Type varchar (10),
Filegroupname varchar (20),
The size bigint,
Maxsize bigint)
Insert into # t exec (' RESTORE FILELISTONLY FROM DISK=N ' ' '+ @ bkfilepath +' ' ' ')

If @ @ error<> 0 or (@ @ rowcount & lt;=0)

The begin
The set @ ls_err=@ bkfilepath + 'is not a valid database backup file! '
The return - 1
End

Select @ data_lname=logicalname from # t where type='D'
Select @ log_lname=logicalname from # t where type='L'

Select @ data_path=rtrim (reverse (filename)) from sysdatabases where name=@ database_name
If (@ data_path is null)
The begin
Set @ ls_err='database without called' + @ database_name + 'database'
The return - 1
End
Select @ data_path=reverse (substring (@ data_path, charindex (' \ '@ data_path), 200))
Commit;
The set @ log_path=@ @ log_lname data_path + + 'LDF'
The set @ data_path=@ @ data_lname data_path + + 'MDF'

Declare @ sqlstring varchar (2000)
The set @ sqlstring='RESTORE DATABASE' + @ database_name +
'the FROM DISK="' + @ bkfilepath + "'
WITH MOVE ' '+ @ data_lname +'
TO "' + @ data_path + ' ' ', a MOVE ' '+ @ log_lname +'
TO "' + @ log_path + '"'



The exec (@ sqlstring)

If @ @ error<> 0 or (@ @ rowcount & lt;=0)

The begin
The set @ ls_err='restore the database failed! '
The return - 1
End

The set @ ls_err='

Return 1



End
-- -- -- -- -- -- -- -- -- -- - the following -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
DECLARE restore_proc PROCEDURE FOR proc_restoredata
@ bkfilepath=: bkfilepath,
@ database_name=: _DbName,
@ sqlstring=: ls_err output
Using the sqlca.
The execute restore_proc;
The fetch restore_proc into: ls_err;
The close restore_proc;


Perform to the execute restore_proc; This step when
Sqlerrtext content is: @ sqlstring proc_restoredata not process parameters,

Perform to the execute restore_proc; This step when
Sqlerrtext content is: the Cursor is not open

Finally is: the Procedure from the had been executed or has no results

Please help to look at,

CodePudding user response:

Add that performs successfully in query analyzer,

CodePudding user response:

Under this kind of treatment you see:

1, create a new standard of the class, and the select standard class type, select the transaction, then opens a statement function window
2, in the above window option at the bottom of the Declare the instance variables page, in the variable type drop-down box to choose the Local External Functions provides
3, right-click in the blanks about aste - & gt; SQL - & gt; Remote stored procedure, back to the choice of the stored procedure window, select the function can generate
Such as: CREATE PROCEDURE sp_test (@ pinput varchar (10))
AS
The return of 1000
GO
When choosing sp_test generate the following function declaration
The function long sp_test (string pinput) RPCFUNC ALIAS FOR "dbo. Sp_test
"4, save your object is: uo_tran
5, double-click to open the application, choose additional properties - & gt; Variable types, modified with respect to the transaction in the SQLCA uo_tran can
6, and then in the program you can you like using the function call stored procedures, such as:
The integer li_return

Li_return=Sqlca. Sp_test (' 111 ')

CodePudding user response:

As if it's not that simple, ha ha.
  • Related