恢复数据库的一个问题 ......回贴有分

dtzcx 2004-01-08 03:44:21
代码:
disconnect using SQLCA;

Transaction SQLCA_MASTER
SQLCA_MASTER = CREATE Transaction
SQLCA_MASTER.DBMS = "MSS Microsoft SQL Server 6.x"
SQLCA_MASTER.DataBase = "master"
SQLCA_MASTER.LogId = "sa"
SQLCA_MASTER.AutoCommit = TRUE
SQLCA_MASTER.DBParm = ""
CONNECT USING SQLCA_MASTER ;


DECLARE renew PROCEDURE FOR up_restoredb ;
@bkfile = "c:\temp\xt.bak, //定义要恢复的备份文件名
@dbname ="xt"; //定义恢复后的数据库名

execute renew;


DISCONNECT USING SQLCA_MASTER ;
CONNECT USING SQLCA ;


运行结果返回:0
但所恢复数据库并不存在


我想可能是执行存储过是否应该加所在的事物,

请各位指点:

那有问题

或应如何执行存储过时加上事物;





回贴有分



...全文
51 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
TianChong 2004-01-27
  • 打赏
  • 举报
回复
可以在PB里进行备份恢复的,我是做成独立模块的,功能完整,一个字:好用!
每一次盘点数据审核时我要先对数据库进行备份,备份成功才能审核...这样很安全啊.
下面这小段是恢复代码...测试过的没有问题.
Transaction i_restore
i_restore=Create Transaction;
i_restore.AutoCommit =true
i_restore.DBMS=sqlca.DBMS
i_restore.lock=sqlca.lock
i_restore.Database=sqlca.database
i_restore.LogID=sqlca.logID
i_restore.LogPass=sqlca.logpass
i_restore.ServerName=sqlca.ServerName

string ls_use,DBName
DBName='YourDB'
ls_use = "RESTORE DATABASE "+DBName+" FROM Huang_Data WITH RECOVERY,REPLACE"
EXECUTE IMMEDIATE : ls_use USING i_restore;
if i_restore.sqlcode=-1 then
.....
end if
tongcheng 2004-01-18
  • 打赏
  • 举报
回复
可以
Transaction SQLCA_yy
SQLCA_MASTER = CREATE Transaction
SQLCA_MASTER.DBMS = "MSS Microsoft SQL Server 6.x"
SQLCA_MASTER.DataBase = "master"
SQLCA_MASTER.LogId = "sa"
SQLCA_MASTER.AutoCommit = TRUE
SQLCA_MASTER.DBParm = ""
CONNECT USING SQLCA_yy ;

restore_sql = "RESTORE DATABASE "+database_name_t+" FROM DISK = '" +pathname+"'"&
+" with move '"+database_name_temp+"' to '"+database_name_t+".mdf',move "&
+"'"+database_name_temp+"_log' to '"+database_name_t+".ldf'"
execute immediate:restore_sql using SQLCA_yy;

没问题的,呵呵!
workhand 2004-01-17
  • 打赏
  • 举报
回复
建议不要用pb程序来恢复数据库。好像不好时
flyerlxg 2004-01-17
  • 打赏
  • 举报
回复
干嘛要在PB中恢复数据库呢,本来PB所写的程序是处理数据库中的数据,既然数据库需要恢复,何不利用数据库本身的功能来达到目的呢?虽然可以做到,但好象是拿PB的短处与SQL数据库的长处比呀,大家说说到底有没有这个必要。我是认为没有这个必要的。
sinkiangscorpio 2004-01-17
  • 打赏
  • 举报
回复
DECLARE nh PROCEDURE FOR BBBBBB()
using sqlca ;
ld2099 2004-01-17
  • 打赏
  • 举报
回复
不会吧?
edisonwong 2004-01-14
  • 打赏
  • 举报
回复
怎么连 servername 都没有,难道是本机?
wangbangc 2004-01-13
  • 打赏
  • 举报
回复
先看看你的存储过程吧,没问题后在单步跟踪运行程序。
liliang800207 2004-01-13
  • 打赏
  • 举报
回复
0表示执行成功
你能确保你的c:\temp\xt.bak有什么样的数据吗??
dtzcx 2004-01-13
  • 打赏
  • 举报
回复
高手呢
dtzcx 2004-01-10
  • 打赏
  • 举报
回复
没人回答?
qiyousyc 2004-01-09
  • 打赏
  • 举报
回复
还是别在pb里恢复了。好象不行的
dtzcx 2004-01-09
  • 打赏
  • 举报
回复
没人回答?
mittee 2004-01-08
  • 打赏
  • 举报
回复
运行结果返回:0,执行成功了.

752

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧