无法在ADODB.COMMAND中执行“提交”

时间:2014-08-22 11:15:39

标签: excel vba oracle11g adodb

我正在运行连接到Oracle DB和ADODB的Excel VBA代码。 我可以使用以下连接字符串连接到Oracle服务器: dbConnectStr = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST='Host')(PORT='Port'))(CONNECT_DATA=(SERVICE_NAME='service')));Data Source='Source'; User Id='User';Password='Password"

With dbConnection
    .ConnectionString = dbConnectStr
    .Properties("Prompt") = adPromptNever
    .Open ConnectionString
End With

我可以执行选择命令。

但是当我尝试执行以下SQL Update命令后面跟着" COMMIT"时,我收到Oracle错误:ORA-0091:无效字符。

在省略Commit时,错误消失。

   sSQL = "UPDATE EMPLOYEE SET DOJ ='31-DEC-9999' WHERE EMP_ID =55555; COMMIT;"

    With dbCommand
        .ActiveConnection = dbConnection
        .CommandText = sSQL
        .CommandType = adCmdUnknown
        .CommandTimeout = 600
    End With

    Set dbRecordset = dbCommand.Execute

有" COMMIT"在SQL中是我不可或缺的要求,我不能忽视或替换其他东西。

请帮忙。提前致谢 Sachin D

2 个答案:

答案 0 :(得分:0)

您的更新和提交是2个命令。您不能在同一个execute中执行这两个命令。你需要做2次执行。通常,您应该使用Split(sSQL, ";")之类的内容拆分脚本。这将为您提供一个字符串数组,可以使用for循环轻松遍历。

您还必须处于事务模式,以便在命令execute中接受提交。您可以使用dbConnection.BeginTransdbConnection.CommitTrans围绕您的循环来完成此操作。

如果您不处于事务模式,则每个执行都将立即提交。

答案 1 :(得分:-2)

    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    AFHTTPRequestSerializer * requestSerializer = [AFHTTPRequestSerializer serializer];
    AFHTTPResponseSerializer *responseSerializer = [AFHTTPResponseSerializer serializer];

    NSString *ua = @"Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25";

    [requestSerializer setValue:ua forHTTPHeaderField:@"User-Agent"];
    responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/xml", nil];
    manager.responseSerializer = responseSerializer;
    manager.requestSerializer = requestSerializer;

    NSString *url =[NSString stringWithFormat:@"http://unicodesystems.co.in:9090/plugins/userService/userservice?type=add&secret=abc&username=%@&password=%@&groups=unicode",chatNameText.text,passText.text];
    NSLog(@"url %@",url);
    [manager POST:[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
       parameters:nil
          success:^(AFHTTPRequestOperation *operation, id responseObject) {

              NSData * data = (NSData *)responseObject;
              NSDictionary *xmlDoc = [NSDictionary dictionaryWithXMLString:[NSString stringWithCString:[data bytes] encoding:NSISOLatin1StringEncoding]];
              NSLog(@"xml %@",xmlDoc);
//              DBManager * db = [[DBManager alloc] init];
              [DBManager getSharedInstance];
              NSLog(@"AGE:%@  %@    %@    %@",aText.text,chatNameText.text,gText.text,passText.text);
//              NSArray *fields = [[NSArray alloc] initWithObjects:@"chat_name", @"age", @"gender", @"password", nil];
//              NSArray *values = [[NSArray alloc] initWithObjects:chatNameText.text,aText.text,gText.text,passText.text, nil];
//              
//              [db saveData:fields value:values table:@"Login_user_data"];
              [[NSUserDefaults standardUserDefaults] setObject:@"login" forKey:@"initial_step"];
              loginViewController = [[LoginViewController alloc] init];
              [self presentViewController:loginViewController animated:YES completion:nil];

          }
          failure:^(AFHTTPRequestOperation *operation, NSError *error) {
              NSLog(@"Error: %@", error);
          }];