How to call stored procedure in another server

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
emmbec
Forum Contributor
Posts: 112
Joined: Thu Sep 21, 2006 12:19 pm
Location: Queretaro, Mexico

How to call stored procedure in another server

Post by emmbec »

Hi, I have an application running on a web server (Server 1). What I want to do, is create a trigger on a table of a database located in Server1 which calls a stored procedure located in a Server2, which will store some value in the database of server2. Is this possible? Or do I need to put both databases in the same server?

Thanks!
DaiLaughing
Forum Commoner
Posts: 76
Joined: Thu Jul 16, 2009 8:03 am

Re: How to call stored procedure in another server

Post by DaiLaughing »

Without knowing what technologies you are using this is a bit of a stab in the dark but in principle there is not problem.

I use PHP and MySQL and (as with any other Web access to a database I expect) you need to connect to the database from the PHP script. To connect to a remote server database you just replace localhost with the address of that server. That server would have to be willing to accept remote connections of course. You would have to create and drop connections as required by the script to access the local and remote servers
User avatar
emmbec
Forum Contributor
Posts: 112
Joined: Thu Sep 21, 2006 12:19 pm
Location: Queretaro, Mexico

Re: How to call stored procedure in another server

Post by emmbec »

Hi, I guess I didn't make myself clear, I actually I don't want to use any PHP code or any other language whatsoever, I want to call the SP directly from a trigger in the MySQL table. The only sollution I've found is to have both databases located on the same server...
DaiLaughing
Forum Commoner
Posts: 76
Joined: Thu Jul 16, 2009 8:03 am

Re: How to call stored procedure in another server

Post by DaiLaughing »

It might well be my mistake. I saw "I have an application" and assumed a web app. Sorry, tunnel vision.
Post Reply