Transactions not working

Hello everybody,

The question is simple: Why the following code is inserting the record to the database?

 sc_begin_trans();
  
  $value = 1;
  
  $insert_st="INSERT INTO TABLE (COL1,COL2,COL3) VALUES (1,2,'TEXT')";
  sc_exec_sql($insert_st);
  
  if($value ==0) {
  
       sc_commit_trans();
  }
  else {
  
       sc_rollback_trans();
  
  }
 

My server is running on Centos 6. Scriptcase 9 was installed with auto installer and connection with MSSQLServer configured according to the documentation available in Scriptcase WebHelp.

Thanks in advance!

If I don’t use the macros for transactions, and I try the code below, it works as it should: the record is NOT inserted.

 sc_exec_sql("BEGIN TRANSACTION");
   
  $valor=1;
   
  $insert_st="INSERT INTO TABLE (COL1,COL2,COL3) VALUES (1,2,'TEXT')";
  sc_exec_sql($insert_st);
   
  if($valor==0) {
       sc_exec_sql("COMMIT TRANSACTION");
  }
  else {
   
       sc_exec_sql("ROLLBACK TRANSACTION");
   
  }
 

Hi, what event you are using that script?

Hi!

It’s a multiple record form. So, I’m beginning the transaction in OnBeforeUpdateAll event, and committing or rolling back in AfterUpdateAll event. According to the documentation, there’s no need to use transaction’s macros on these events, because they are already protected, but I realized that my checks to roll back the transaction were not working (records were still saved). I used transaction macros to specify that I want to protect everything in a single transaction, but it didn’t work either.

The strange thing is that using SQL seems to be ok! So, macros are not doing what they should.

I also tried the same code in a blank application, and I got the same results.

I don’t know if I can keep trusting those macros.

OMG! I think this is a serious bug, and it has not been solved!

I run the same code in an installation of Scriptcase 9 in Windows 7, and transaction macros work as expected. So, I think the problem is around the driver used for the connection with SQLServer, because they are different.

Any help please!