powered by simpleCommunicator - 2.0.59     © 2025 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / PowerBuilder [игнор отключен] [закрыт для гостей] / data PipeLine
3 сообщений из 3, страница 1 из 1
data PipeLine
    #35174854
durban2
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Нижеприведенный сценарий прикреплён к командной кнопке.
Первый раз ПРАВИЛЬНО копирует таблицу
Из одной базы в другую.
При повторном запуске этого сценария
Приводит к зависанию приложения.
Код поставлен на компакт диске к книге PB5.0 от 1998 г.

Предыдущие мои вопросы о том, существует ли таблица,
Имеется ли подсоединение явились следствием
Устранить вышесказанное. Итак, ПОЧЕМУ ЗАВИСАЕТ?
Только многократное нажатие на значке закрытия окна (крестике)
Позволяют закрыть приложение и запустить вновь.

Код: plaintext
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.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.
181.
182.
183.
184.
185.
186.
187.
188.
189.
190.
191.
192.
193.
194.
195.
196.
//  Script Name:  Clicked fo cb_pipe_1
// taken from CH20.PBL PB5. 0  into dialog window 'w_pipe_1'
//  Use the pipeline object pipe_1 to pipe a table from
//  a source database to a destination database.
//  Local variables:
Integer     li_error    // pipeline error code
Pipeline    lpipe_1     // pipeline variable
String      ls_dbms     // database type
String      ls_error    // pipeline error message
String      ls_inifile  // PB.INI, or other ini file with connect params
String      ls_section  // section in ini file with connect params
Transaction ltrans1     // transaction object for source database
Transaction ltrans2     // transaction object for target database

//  Initialization

SetPointer(HourGlass!)
st_status.Text = "Initializing..."
ls_inifile = "PB.INI"

//  Connect to the source database

st_status.Text = "Connecting to source database..."
ltrans1 = CREATE Transaction

ls_section = "Profile Video Store (SQL Server)"
ls_dbms = ProfileString(ls_inifile,ls_section,"DBMS","")
IF ls_dbms = "" THEN GOTO ErrorSourceDBMS

ltrans1.DBMS       = ls_dbms
ltrans1.Database   = &
      ProfileString(ls_inifile,ls_section,"Database","")
ltrans1.ServerName = &
      ProfileString(ls_inifile,ls_section,"ServerName","")
ltrans1.UserId     = &
      ProfileString(ls_inifile,ls_section,"UserId","")
ltrans1.DBPass     = &
      ProfileString(ls_inifile,ls_section,"DatabasePassword","")
ltrans1.LogId      = &
      ProfileString(ls_inifile,ls_section,"LogId","")
ltrans1.LogPass    = &
      ProfileString(ls_inifile,ls_section,"LogPassword","")
ltrans1.Lock       = &
      ProfileString(ls_inifile,ls_section,"Lock","")
ltrans1.DBParm     = &
      ProfileString(ls_inifile,ls_section,"DbParm","")

ltrans1.AutoCommit = False

CONNECT Using ltrans1;

IF ltrans1.SqlCode <>  0  THEN GOTO ErrorSourceConnect

//  Connect to the destination database

st_status.Text = "Connecting to destination database..."
ltrans2 = CREATE Transaction

ls_section = "Profile Video Store DB"
ls_dbms = ProfileString(ls_inifile,ls_section,"DBMS","")
IF ls_dbms = "" THEN GOTO ErrorDestinationDBMS

ltrans2.DBMS       = ls_dbms
ltrans2.Database   = &
      ProfileString(ls_inifile,ls_section,"Database","")
ltrans2.ServerName = &
      ProfileString(ls_inifile,ls_section,"ServerName","")
ltrans2.UserId     = &
      ProfileString(ls_inifile,ls_section,"UserId","")
ltrans2.DBPass     = &
      ProfileString(ls_inifile,ls_section,"DatabasePassword","")
ltrans2.LogId      = &
      ProfileString(ls_inifile,ls_section,"LogId","")
ltrans2.LogPass    = &
      ProfileString(ls_inifile,ls_section,"LogPassword","")
ltrans2.Lock       = &
      ProfileString(ls_inifile,ls_section,"Lock","")
ltrans2.DBParm     = &
      ProfileString(ls_inifile,ls_section,"DbParm","")

ltrans2.AutoCommit = False

CONNECT Using ltrans2;

IF ltrans2.SqlCode <>  0  THEN GOTO ErrorDestinationConnect

//  Delete the target table

st_status.Text = "Dropping old destination table..."
EXECUTE IMMEDIATE "DROP TABLE new_customers" Using ltrans2;

//  Set up the pipeline variable

st_status.Text = "Setting up the pipeline..."
lpipe_1 = CREATE Pipeline      // instantiate the variable
lpipe_1.DataObject = "pipe_1"  // associate the variable with the
                               // pipeline pipe_1 created with the
                               // Pipeline Painter

//  Execute the pipeline

st_status.Text = "Executing the pipeline..."
li_error = lpipe_1.Start(ltrans1, ltrans2, dw_1)

IF li_error <>  1  THEN GOTO ErrorPipeStart

//  Successful completion

st_status.Text = "Pipeline finished successfully."
MessageBox("Success", &
   "Pipeline executed successfully."                + &
   "~nRowsRead="    + String(lpipe_1.RowsRead)      + &
   "~nRowsWritten=" + String(lpipe_1.RowsWritten)   + &
   "~nRowsInError=" + String(lpipe_1.RowsInError))

RETURN

//  Error Handling

ErrorSourceDBMS:
MessageBox("Error on Connect to Source Database",   &
   "Unable to read DBMS name from the "      + &
   ls_section + " section of the INI file "  + &
   ls_inifile,                                 &
   stopsign!)
GOTO ErrorExit

ErrorSourceConnect:
MessageBox("Error on Connect to Source Database",     &
   "Database Profile Name: " + ls_section           + &
	"~nDBMS: " + ls_dbms                             + &
   "~nError Code: " + String(ltrans1.SqlDbCode)     + &
   "~nError Message: " + ltrans1.SqlErrText,          &
   stopsign!)
GOTO ErrorExit

ErrorDestinationDBMS:
MessageBox("Error on Connect to Destination Database",   &
   "Unable to read DBMS name from the "                + &
   ls_section + " section of the INI file "            + &
   ls_inifile,                                           &
   stopsign!)
GOTO ErrorExit

ErrorDestinationConnect:
MessageBox("Error on Connect to Destination Database",   &
   "Database Profile Name: " + ls_section              + &
	"~nDBMS: " + ls_dbms                                + &
   "~nError Code: " + String(ltrans2.SqlDbCode)        + &
   "~nError Message: " + ltrans2.SqlErrText,             &
   stopsign!)
GOTO ErrorExit

ErrorPipeStart:
CHOOSE CASE li_error
   CASE - 1 
      ls_error = "Pipe open failed (error # -1)"
   CASE - 2 
      ls_error = "Too many columns (error # -2)"
   CASE - 3 
      ls_error = "Table already exists (error # -3)"
   CASE - 4 
      ls_error = "Table does not exist (error # -4)"
   CASE - 5 
      ls_error = "Missing connection (error # -5)"
   CASE - 6 
      ls_error = "Wrong arguments (error # -6)"
   CASE - 7 
      ls_error = "Column mismatch (error # -7)"
   CASE - 8 
      ls_error = "Fatal SQL error in source (error # -8)"
   CASE - 9 
      ls_error = "Fatal SQL error in destination (error # -9)"
   CASE - 10 
      ls_error = "Maximum number of errors exceeded (error # -10)"
   CASE - 12 
      ls_error = "Bad table syntax (error # -12)"
   CASE - 13 
      ls_error = "Key required but not supplied (error # -13)"
   CASE - 15 
      ls_error = "Pipe already in progress (error # -15)"
   CASE - 16 
      ls_error = "Error in source database (error # -16)"
   CASE - 17 
      ls_error = "Error in destination database (error # -17)"
   CASE - 18 
      ls_error = "Destination database is read-only (error # -18)"
   CASE ELSE
      ls_error = "Error #" + String(li_error)
END CHOOSE
MessageBox("Error on Starting the Pipeline", ls_error, stopsign!)
GOTO ErrorExit

ErrorExit:
st_status.Text = "An error occurred."
SetPointer(Arrow!)
RETURN
...
Рейтинг: 0 / 0
data PipeLine
    #35175114
1. пропиши DISCONNECT USING ...; для каждой транзакции.
2. покажи параметры коннектов
3. если не получается понять где зависает с помощью дебагера, попробуй включить TRACE для своих транзакций.
4. посмотри процессы со стороны БД. зависание может быть из-за блокировок на уровне БД.
...
Рейтинг: 0 / 0
data PipeLine
    #35181830
durban2
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
авторс новым годом
Guest
ИСКРЕННЕ БЛАГОДАРЮ
...
Рейтинг: 0 / 0
3 сообщений из 3, страница 1 из 1
Форумы / PowerBuilder [игнор отключен] [закрыт для гостей] / data PipeLine
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]