Home > database >  PB cursors use problem
PB cursors use problem

Time:10-08

Objective: after the data processing of a data inventory updates to another database, the cursor within another open a transaction gtr_fox select less than this value, also is unable to insert the data; Use only one transaction is also unable to query and inserted, commit to replace a few position also useless, please advise thank you!!!!!!!!!!
Declare the PC Cursor definition For//the Cursor
The Select ParentCategoryCode, CategoryCode, CategoryName, CreateDate From ProductCategory Where isNull (StatusFlags, ' ')='1' Order BY CategoryFlags Using gtr_eon;
Open the PC;//open the cursor
The Do While gtr_eon. Sqlcode=0//the cursor passes into an array of data within a
Fetch the PC Into: ls_ParentCategoryCode, : ls_CategoryCode, ls_CategoryName, : ldt_GetDate;//insert cursor data
IF ls_ParentCategoryCode="ALL" Then
Insert Into Swgl_3.. CPLB (UNI, ParentKey LBCODE LBNAME, CreateDate)
VALUES (' _ '+ right (Cast (Newid () AS Char (36)), 9), : ls_ParentCategoryCode, : ls_CategoryCode, : ls_CategoryName, : ldt_GetDate);

The ELSE
String ls_PCUNI
Select parentkey into: ls_PCUNI From SWGL_3.. CPLB Where LBCODE=: ls_ParentCategoryCode;
Insert Into SWGL_3.. CPLB (UNI, ParentKey LBCODE LBNAME, CreateDate)
VALUES (' _ '+ right (Cast (Newid () AS Char (36)), 9), : ls_PCUNI, : ls_CategoryCode, : ls_CategoryName, : ldt_GetDate);
End the IF
//the Fetch PC into: ls_ParentCategoryCode, ls_CategoryCode, : ls_CategoryName, : ldt_GetDate;
Loop;//cycle
IF gtr_fox. Sqlcode=0 Then
Commit the Using gtr_eon;
Lb_1. Additem (gnv_fun. Of_Setmessagelogfile (gs_operator, 1, "synchronous data", "new category", "category successfully saved"))
Lb_1. Setstate (lb_1. Totalitems (), True)
Lb_1. Setstate (lb_1. Totalitems (), False)
The ELSE
The rollback Using gtr_eon;
Lb_1. Additem (gnv_fun. Of_Setmessagelogfile (gs_operator, 1, "synchronous data", "new category", gtr_fox. Sqlerrtext))
Lb_1. Setstate (lb_1. Totalitems (), True)
Lb_1. Setstate (lb_1. Totalitems (), False)
End the IF
Close the PC;//close the cursor

CodePudding user response:

To switch to the DataStore.

CodePudding user response:

reference 1st floor WellSoft response:
convert DataStore.

Used to send a case to have a look

CodePudding user response:

PB original concept used in the datastore to replace cursor
https://blog.csdn.net/wosind/article/details/83785666

CodePudding user response:

A data processing after the update data inventory to another database

The cursor is in the database transaction
One of objects cannot be used across database
You have to give up the cursor method

CodePudding user response:

The Fetch PC Into: ls_ParentCategoryCode, ls_CategoryCode, : ls_CategoryName,
It is missing the using gtr_eon;

CodePudding user response:

Try not to use the cursor, use the datastore
Or encapsulates a u_datastore inherited from the datastore, build a method

CodePudding user response:

Try not to use the cursor, use the datastore
Or encapsulates a u_datastore inherited from the datastore, build a method Boolean of_retrieve (string as_sql)
The return value is true success, or false on failure

CodePudding user response:

PB inside it is best to use less cursor, especially vernier nested, there is a BUG,,,

CodePudding user response:

Yes, have to use the datastore, or what are you doing with pb

CodePudding user response:

Replace cursor to take data with datastore, recycling processing
  • Related