oracle提交数据按键,Oracle PLSQL - 仅提交数据库链接(Oracle PLSQL - Commit only database link)...
Oracle PLSQL - 僅提交數(shù)據(jù)庫鏈接(Oracle PLSQL - Commit only database link)
有沒有辦法只通過數(shù)據(jù)庫鏈接而不是當(dāng)前會(huì)話的數(shù)據(jù)提交在表上插入/更新的數(shù)據(jù)? 或者他們被認(rèn)為是同一個(gè)?
例如:
INSERT INTO main_database.main_table(value1, value2)
VALUES (1 , 2)
INSERT INTO database.table@database_link(value3, value4)
VALUES (3 , 4)
并僅為數(shù)據(jù)庫鏈接表提交?
關(guān)于我為什么要這樣做的背景:主數(shù)據(jù)庫用于(多個(gè))記錄,而數(shù)據(jù)庫鏈接用于(貨幣)事務(wù)(在單獨(dú)的服務(wù)器上處理)。 我想首先更新記錄以檢查是否有任何約束失敗,但是在事務(wù)完成之前不提交數(shù)據(jù)。 如果事務(wù)失敗,我想回滾記錄以省去刪除/撤消插入/更新的工作,這可能會(huì)變得混亂。
我假設(shè)沒有,但我希望有辦法。 提前致謝。
Is there a way to commit only the data inserted/updated on a table through a database link and not the data of the current session? Or are they considered one and the same?
For example:
INSERT INTO main_database.main_table(value1, value2)
VALUES (1 , 2)
INSERT INTO database.table@database_link(value3, value4)
VALUES (3 , 4)
And do a commit for only the database link table?
Background on why I would want to do this: The main database is for (multiple) records while the database link is for (monetary) transactions (processed on a separate server). I want to update the records first to check to see if any of the constraints fail, but not commit the data until the transaction is complete. If the transaction fails, I want to rollback the records to save me the effort of deleting/undoing inserts/updates which could get messy.
I am assuming there is not but I am hoping that there is a way. Thanks in advance.
原文:https://stackoverflow.com/questions/36560057
更新時(shí)間:2019-12-06 06:51
最滿意答案
create or replace procedure proc_1 ( i IN number )
as
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
INSERT INTO test_table@remote_sid (id, description)
VALUES (i, 'Description for ' || i);
COMMIT;
END;
/
create or replace procedure proc_base ( i IN number )
as
begin
insert into local_tab (id) values (i);
proc_1( i );
rollback;
end;
/
create or replace procedure proc_1 ( i IN number )
as
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
INSERT INTO test_table@remote_sid (id, description)
VALUES (i, 'Description for ' || i);
COMMIT;
END;
/
create or replace procedure proc_base ( i IN number )
as
begin
insert into local_tab (id) values (i);
proc_1( i );
rollback;
end;
/
2016-04-11
相關(guān)問答
oracle安裝客戶端工具pl/sql的目的是方便數(shù)據(jù)庫的管理。 mysql也是一樣的道理。安裝phpMyAdmin或者Navicat,也是方便數(shù)據(jù)庫的管理。
PLSQL developer是編寫SQL的工具 ORACLE是數(shù)據(jù)庫軟件
1、在Oracle的安裝目錄下找到tnsnames.ora。 2、在這個(gè)文件中填寫連接數(shù)據(jù)庫的配置信息。 DEMO = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.11.110)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SID = DEMO) ) )
左外連接用left join,右外連接用right join語句。 比如 Oracle: select * from a, b where a.id=b.id(+) SQL: select * from a left join b on a.id=b.id 反過來a.id(+)=b.id 就是right join
create or replace procedure proc_1 ( i IN number )
as
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
INSERT INTO test_table@remote_sid (id, description)
VALUES (i, 'Description for ' || i);
COMMIT;
END;
/
create or replace procedure proc_base ( i I
...
你沒錯(cuò),因?yàn)榇嬖赬ML標(biāo)題而出錯(cuò)。 解決方法是使用XMLParse(document ...)來解析XML: select xmlparse(document UTL_HTTP.REQUEST(URL => 'http://xkcd.com/rss.xml'))
into v_xml
from dual;
示例SQLFiddle與xkcd.com的結(jié)果。 請(qǐng)注意,根據(jù)文檔, HTTP_UTIL.Request函數(shù)僅返回服務(wù)器響應(yīng)的前2000個(gè)字節(jié),因此您可以使用此類請(qǐng)求獲取不完整的XML。
...
我一直與甲骨文一起工作了20年,從未見過使用令人滿意的代碼管理系統(tǒng)。 然而,在過去的一年里,我一直致力于Ruby on Rails應(yīng)用程序,分布式版本控制系統(tǒng)“git”通過gitflow進(jìn)行了擴(kuò)展,以幫助形式化代碼分支(主,開發(fā),特性,修補(bǔ)程序等)和部署數(shù)據(jù)庫PostgreSQL)使用rake進(jìn)行遷移。 我真的希望我有機(jī)會(huì)將它們與Oracle代碼一起使用,因?yàn)樗_實(shí)能夠剔除我需要的每個(gè)框。 I've been working with Oracle for something like 20 ye
...
數(shù)據(jù)庫獨(dú)立性是使用JDBC的好理由。 假設(shè)您的Web應(yīng)用程序需要為無法支付Oracle費(fèi)用的客戶運(yùn)行,您需要做多少工作才能移植到開源數(shù)據(jù)庫? Database independence is good reason for using JDBC. Let's say that your web application needs to run for a customer that cannot pay for Oracle, how much work will you need to do t
...
雖然我理解您解決了語法問題,但我認(rèn)為我可能會(huì)提出兩種方法來推進(jìn)最佳實(shí)踐: 顯示加入 在連接查詢中的表時(shí)使用當(dāng)前的ANSI語法。 現(xiàn)在,您的SQL使用舊的,不推薦使用的隱式連接( WHERE子句中使用的鍵)與使用顯式連接的當(dāng)前ANSI標(biāo)準(zhǔn)( INNER JOIN...ON使用的鍵)。 雖然這在性能方面對(duì)查詢優(yōu)化器沒有任何影響(參見SO帖子 ),但使用INNER JOIN往往更具可讀性和可維護(hù)性,特別是如果您有各種WHERE條件需要管理。 下面是嘗試使用INNER JOIN子句轉(zhuǎn)換您的查詢。 請(qǐng)?jiān)谑褂?/p>
...
SQL - 結(jié)構(gòu)化查詢語言 - 是查詢關(guān)系數(shù)據(jù)庫的“標(biāo)準(zhǔn)”語言。 大多數(shù)(如果不是全部)RDBMS供應(yīng)商都支持SQL,或者確切地說是他們自己的SQL 版本 。 即使從80年代開始按ANSI標(biāo)準(zhǔn)化,也很少達(dá)到100%的合規(guī)性。 許多RDBMS接受特定于供應(yīng)商的SQL擴(kuò)展。 換句話說,Oracle的SQL和SQLite的實(shí)現(xiàn)并不完全相同。 但核心語言是一樣的。 這就是為什么你經(jīng)常/有時(shí)為這兩種產(chǎn)品編寫相同的查詢。 另一方面, PL / SQL是Oracle 專有的程序語言。 它由Oracle Corp
...
總結(jié)
以上是生活随笔為你收集整理的oracle提交数据按键,Oracle PLSQL - 仅提交数据库链接(Oracle PLSQL - Commit only database link)...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Window 窗口层次关系
- 下一篇: mysql 组合查询_MySQL组合查询