473,513 Members | 3,569 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to make cross-database reference in Postgres

4 New Member
Hello,
We have two postgres databases running in the same server. Now we have to write a trigger in one database to access a table in another database for live data updation in both databases. How can we perform that?
Can we use contrib/dblink? If we yes how to do that? Our postgres version is 7.4.7. And the function dblink does not exist.How to do that?
Or is there a better way of doing this cross reference.

-Krithika.
Dec 28 '06 #1
3 16150
michaelb
534 Recognized Expert Contributor
For installation look at contrib/dblink/README.dblink
If you don't have a source code you can download it from http://www.postgresql.org

I don't know if this would work for you, often things you can do from inside a trigger, or a function have certain limitations.
Dec 29 '06 #2
krithikas
4 New Member
I installed the postgresql-contrib package as it was available with my debian sarge 3.1 .
Then i just did
psql dbname < /usr/share/postgres/contrib/dblink.sql

I did some select operations using dblink and they worked perfectly.
When i tried to write a trigger in pl/pgsql like this ,

CREATE TRIGGER triggername BEFORE INSERT OR UPDATE ON testtable
FOR EACH ROW EXECUTE PROCEDURE test();

CREATE OR REPLACE FUNCTION test() RETURNS TRIGGER AS '
BEGIN
SELECT dblink_exec(''dbname=sample'',''insert into testtable values (NEW.x,NEW.y)'');
END;
' LANGUAGE plpgsql;

It threw an error like this,
ERROR: sql error
DETAIL: ERROR: NEW used in query that is not in a rule

Actually i want to insert the records that are getting inserted into testtable in my current db , also into a table testtable in another db 'sample' simultaneously. Is this the right way of doing this using dblink ?
Jan 3 '07 #3
anvesh
2 New Member
DbLink extension of PostgreSQL which is used to connect one database to another database.
I have prepared full demonstration on this. Also provide full script with example.
You must visit this post:
Aug 22 '15 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

28
7044
by: jonjon | last post by:
Hi, I want to be able to define the right property of my absolute positionned elements... for example if a button is 50px left and 150px right, it will resize when the page is resized. This is working fine in Mozilla but it isn't working in Internet Explorer :( Is this a known bug ? do you have any suggestion without using tables or OnResize...
3
3073
by: rollasoc | last post by:
Hi, Doing a bit of system testing on a Windows 98 laptop. (.Net 1.1 app). Did a bit of testing. Loaded a previously saved file. A gray box appeared with the text and buttons all white rectangles with a big red cross in it. Pressed a button (the one I thought might be ok). My file appeared to load. Then when I clicked on any...
23
6481
by: Jeff Rodriguez | last post by:
Here's what I want do: Have a main daemon which starts up several threads in a Boss-Queue structure. From those threads, I want them all to sit and watch a queue. Once an entry goes into the queue, grab it and run a system command. Now I want to make sure that system command doesn't hang forever, so I need some way to kill the command...
6
1953
by: Sergey Poberezovskiy | last post by:
Hi, What do I need to type in the advanced options of the New Question dialog of this newsgroup to cross-post, say to VB.Net General Discussion. I have attempted a few different options, but none succedded. They ask to "use full USENET designation" - but I cannot figure out what it is.
19
2411
by: zzw8206262001 | last post by:
Hi,I find a way to make javescript more like c++ or pyhon There is the sample code: function Father(self) //every contructor may have "self" argument { self=self?self:this; //every class may have this statement self.hello = function() {
48
3236
by: Nathan Sokalski | last post by:
Ever since I found out that they didn't give us a way to install both IE6 and IE7 on the same machine, I have been more frustrated and annoyed with Microsoft than I ever have been with any company (and for someone who has loved Microsoft as much as me, that takes something pretty bad!). I am a web developer, and only have access to one...
2
2732
by: JDeats | last post by:
>From my development envrionment (i.e. a single WinXP notebook PC) I have a basic AJAX application that is making the call to a Windows Form page that just returns the request back to the AJAX client from the JavaScript HttpXMLRequest protected void Page_Load(object sender, EventArgs e) { string txt = ""; string input = null;
11
2933
by: Simon van Beek | last post by:
Dear reader, By opening an application I get always the main Access window with the closing cross in the above right corner. Is there a possibility to make this closing cross invisible? All the settings in the Start-up form under Tools are disabled but the closing cross in the above right corner is still visible.
6
3967
by: ampo | last post by:
Hello. Can anyone help with cross-domain problem? I have HTML page from server1 that send xmlHTTPRequest to server2. How can I do it? Thanks.
1
3150
by: NeophyteDK | last post by:
hello Im trying to cross compile php for powerpc on Win XP with MinGW. I have succesfully cc'ed Lighttpd, with the same toochain. i use the command line: CC=powerpc-linux-gcc AR=powerpc-linux-ar LD=powerpc-linux-ld \ ./configure \ --target=powerpc-linux \ --prefix=/C/install_dir/php/ \ --enable-static=yes \ --enable-shared=no
0
7178
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7397
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7563
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7125
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5703
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5102
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3252
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.