dev/powerbuilder

다른 DataBase(Transacntion) 연결 및 사용

두억시니 2008. 1. 4. 20:25
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Transaction itr_temp

//기본 연결
itr_temp = CREATE transaction
itr_temp.DBMS = "MSS Microsoft SQL Server"
itr_temp.Database = "sample_database"
itr_temp.LogPass = "abcd1234"
itr_temp.ServerName = "192.168.1.100"
itr_temp.LogId = "sa"
itr_temp.AutoCommit = False
itr_temp.DBParm = ""

CONNECT USING itr_temp;

//Connection Check
IF itr_temp.SQLCode <> 0 THEN
    MessageBox( "itr_temp 연결 실패!", &
                "itr_temp 를 연결할 수 없습니다. ~r" + itr_temp.SQLErrText)
    RETURN
END IF

// SQL 문 사용시
SELECT ISNULL(MAX(SEQ), 0) + 1 INTO :nSEQ 
  FROM [TableName]
 USING itr_temp;
 
// 기본 Commit 과 RollBack
IF This.Update() = 1 THEN
    COMMIT USING itr_temp;
ELSE  
    ROLLBACK USING itr_temp; 
END IF

RETURN TRUE
cs