Transferred from:
Http://www.cnblogs.com/zhaoDotNet/archive/2010/09/17/1829509.html
Author: zhaodotnet
Thanks to zhaodotnet for sharing his experience.
Recently, I met the founder of hubbledotnet on the Internet. At his request, I wrote a blog in cnblog for the first time and pasted what I learned yesterday, hope to help more people who use hubbledotnet;
With the help of the Founder yesterday, I completed data synchronization between Hubble and Oracle.ArticleThe main reason is that the founder of hubbledotnet did not write an article on real-time Oracle Database Synchronization;
First, create a table corresponding to Oracle in Hubble,
Next, click Next.
Click Next.
Here, it is explained that Id field must be the primary key with a unique identifier and must be an integer (number type in Oracle). I define bufferid, because Oracle does not have the auto-increment function, you can ask your friends to write a trigger or use other methods to enable auto-increment. Another point is that my primary key ype must be set to int, analyzer must be untokenized. At this point, the Hubble table creation process has been completed. If you want to synchronize data, go to the next step;
in order to synchronize data in the database with Hubble data, we first create an auxiliary trigger table in Oracle. The main function is to record which fields in the t_goods table have changed, record the changed fields in the secondary trigger table. The Code is as follows:
-- Create Table
Create Table hbtrigger_view_6
(
Serial number (10) Not null,
ID number (10) Not null,
OPR varchar2 (20 ),
Fields varchar2 (4000)
)
Tablespace users
Pctfree 10
Initrans 1
Maxtrans 255
Storage
(
Initial 64 K
Minextents 1
Maxextents Unlimited
);
-- Create/recreate primary, unique and foreign key constraints
Alter table hbtrigger_view_6
Add constraint pk_serial primary key (Serial)
Using Index
Tablespace users
Pctfree 10
Initrans 2
Maxtrans 255
Storage
(
Initial 64 K
Minextents 1
Maxextents Unlimited
);
Note: serial in the table is the primary key and must be an auto-increment integer field. ID cannot be defined as another name (experience );
For how to record changed content Fields, I wrote a trigger with the following code:
Create or replace trigger hbtrigger_t_6_update
After update on for each row
Declare
Updatefields varchar2 (4000): = '';
Begin
If: New. goods_name! =: Old. goods_name then
Updatefields: = 'goods _ name ,';
End if;
If: New. goods_brand! =: Old. goods_brand then
Updatefields: = updatefields | 'ds DS _ brand ,';
End if;
.
. // Add the required fields.
.
If updatefields is not null then
Insert into hbtrigger_view_6 (ID, opr, fields) values (: New. bufferid, 'update', updatefields );
End if;
End hbtrigger_t_6_update;
After the field in t_goods is modified, the following changes occur in the secondary trigger table:
After the work is completed, we go to Hubble,
Right-click the t_goods table we just created, select table info, open the attributes option box, change tablesynchronization to true, set triggertablename to the name of the auxiliary trigger table we just created, and click set;
Now let's perform the synchronization operation. Right-click the t_goods table just created, select synchronize table, and click Start. The result is as follows,
Now you can query your Hubble record. Is it the same as the record in the Oracle table? Of course, we can alsoProgramComplete. For more information, see the blog of the founder of Hubble http://www.cnblogs.com/eaglet/archive/2010/08/25/1808143.html.
If you have read this article and find it difficult to write a trigger, there are also simple operations specially prepared for the lazy, which only takes two steps:
1. Right-click the t_goods table just created and select truncate table;
2. Right-click the t_goods table just created, select synchronize table, and click Start;
This operation only takes a few minutes, but for the lazy, the least cherished is the time;
If you have problems with some intermediate operations, leave a message. You can also download the latest Hubble version and update it at any time;
NOTE: If reprinted, indicate the source (except for eaglet)
Return to hubble.net technical details