English 中文(简体)
利用遥感数据更新当地数据库
原标题:Update local database using remote database data

我只想一谈一个与甲骨质问有关的问题。

create or replace
PROCEDURE       "LOAD_USERNAME" 
IS
   cursor usu is
      select userid
      from local_user;

BEGIN
   for usu_rec in usu
   loop
      update loc_user set username =(
         select cod_user 
            from (
               select cod_user, row_number() over (order by date_createad desc) r
               from user_table@DBLINK where cod_person=usu_rec.userid
            )
            where r = 1
         ) 
      where externaluserid=usu_rec.userid;

   end loop;
END;

基本上,试图从其他数据库获得用户代码(最后一种创建),并更新当地表格。 这似乎行之有效,但我需要太多时间。 我只能通过发展信息网对偏远数据库进行检查。

请说一下,我会帮助找到更好的办法。

I thank your help in advance.

最佳回答

正如Sodved所说的那样,加入你的治疗机构更好。 你们可以尝试这样的事情:

create or replace
PROCEDURE       "LOAD_USERNAME" 
IS
   cursor usu is
select distinct local_user.userid,your_dblink_table.cod_user
      from local_user, user_table@bdlink your_dblink_table
where local_user.userid=your_dblink_table.codperson
and local_user.externaluserid=local_user.userid;
BEGIN
   for usu_rec in usu
   loop
      update loc_user set username =usu_rec.cod_user
where externauserid=usu_rec.userid;
 end loop;
commit;
END;

如果你必须提供大量更新,你可以尝试收集/采用治疗方法。

问题回答

你们想要把网络上的时间减少到最低限度。 因此,你应该加入到你驾驶治疗师的边远桌上,把用户名带回这里。 这一点将更好,因为只有一次完成询问(索引/设计将决定其效果)。 但是,你们的更新只能与当地的数据合作。

Edit: Removed my PL/SQL as @Aitor s





相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

How to make a one to one left outer join?

I was wondering, is there a way to make a kind of one to one left outer join: I need a join that matches say table A with table B, for each record on table A it must search for its pair on table B, ...

Insert if not exists Oracle

I need to be able to run an Oracle query which goes to insert a number of rows, but it also checks to see if a primary key exists and if it does, then it skips that insert. Something like: INSERT ALL ...

How can I store NULLs in NOT NULL field?

I just came across NULL values in NOT-NULL fields in our test database. How could they get there? I know that NOT-NULL constraints can be altered with NOVALIDATE clause, but that would change table s ...

Type reference scope

I m studying databases and am currently working on a object-relational DB project and I ve encountered a small problem with the number of possible constraints in an object table. I m using "Database ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

热门标签