• PB中实现备份数据库/还原数据库


    ============备份数据库
    //备份数据库
    
    SQLCA.AutoCommit = TRUE
    
    //将数据库备份到文件
    ls_style = "USE " + as_databasename
    EXECUTE IMMEDIATE : ls_style;
    
    ls_style = "BACKUP DATABASE " + as_databasename + " TO disk = '" + as_path + "' WITH FORMAT, NAME = 'Full Backup'" 
    EXECUTE IMMEDIATE : ls_style;
    
    SQLCA.AutoCommit = false

    ============还原数据库

    //还原数据库
    
    //首先连接到MASTER数据库
    string ls_ServerName,ls_LogId,ls_LogPass
    Transaction SQLMASTER
    
    ls_ServerName = SQLCA.ServerName
    ls_LogId = SQLCA.LogId
    ls_LogPass = SQLCA.LogPass
    
    disconnect using sqlca;
    
    SQLMASTER = CREATE Transaction
    SQLMASTER.DBMS = "MSS Microsoft SQL Server 6.x"
    SQLMASTER.Database = "master"
    SQLMASTER.ServerName = ls_ServerName
    SQLMASTER.LogId = ls_LogId
    SQLMASTER.LogPass = ls_LogPass
    SQLMASTER.AutoCommit = true
    
    connect using SQLMASTER;
    
    //通过master数据库用指定还原文件还原指定数据库
    ls_style = "USE master" 
    EXECUTE IMMEDIATE : ls_style using SQLMASTER;
    ls_style = "RESTORE DATABASE " + as_databasename + " FROM disk = '" + as_path + "'"
       EXECUTE IMMEDIATE : ls_style using SQLMASTER;
    
    IF sqlca.SQLCODE = 0 THEN
    ls_funreturn = '2'
    else
    ls_funreturn = SQLMASTER.sqlerrtext
    END IF
    
    //断开连接,还原原来的SQLCA连接
    disconnect using SQLMASTER;
    connect using sqlca;
  • 相关阅读:
    不用轮子自己写滑动块
    let能否完全替代IIFE
    css3@media实现原理
    SQL 分组后获取每组中最大值
    如何在 JavaScript 中使用 C 程序
    响应式编程(Reactive Programming)(Rx)介绍
    图表(Chart & Graph)你真的用对了吗?
    JavaScript编码指南
    游戏心理学
    WannaCry结束了? 安专家注册域名掐断病毒传播
  • 原文地址:https://www.cnblogs.com/djd66/p/16205474.html
Copyright © 2020-2023  润新知