Board index » delphi » Stored Procedure question

Stored Procedure question

I use Delphi as the front end to two sql anywhere databases.  The app is
used mainly for one database, but sometimes I write to the other
database based on what is happening  in the first one.  Can I call a
stored procedure from that app that will then write to the second
database?  In other words, can a stored procedure in one database write
to another database?  I don't think it can, but I thought I would ask
anyway.  Thanks.
 

Re:Stored Procedure question


As long as the user has access to both the databases, what you want
(writing to one DB from a stored procedure in another) can be done.
All you have to do is qualify the tablename as
<DBName>.<owner>.<TableName> in your query.

The two problems I can see with needing to do this are:
a) If the two databases are on different servers
b) If you cannot hard code the name of the database you will need to qualify

The first one is not a real problem and all you need to do is make sure that
you set the two servers as linked servers, and in the qualification, include
the server name as well right up front.

The second one can be solved by passing the database name, etc. as params
to your procedure, and then building the query in a variable (varchar) and
then
use the Exec command.

Sorry for being a little cryptic, but do let me know if you need more
clarification.

HTH, DK.

Quote
"Rhea Urusky" <rh...@beaverplastics.com> wrote in message

news:3B4B356F.9D2A9865@beaverplastics.com...
Quote
> I use Delphi as the front end to two sql anywhere databases.  The app is
> used mainly for one database, but sometimes I write to the other
> database based on what is happening  in the first one.  Can I call a
> stored procedure from that app that will then write to the second
> database?  In other words, can a stored procedure in one database write
> to another database?  I don't think it can, but I thought I would ask
> anyway.  Thanks.

Other Threads