Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread It is possible to call a function from another database/schema?
Wed, Jul 24 2013 5:14 PMPermanent Link

Mario Enríquez

Open Consult

hi,

As you all know, it is possible to access objects from another databases in the following way:

SELECT * FROM Database.Table1;

However, I haven't found a way to the same with functions, since the following form throws an error:

SET ret = Database.Function1(Param1, Param2);

It this is possible, what would be the correct form?

I've searched the documentation but haven't found an answer.

Regards,
Mario
Thu, Jul 25 2013 6:50 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Mario


You can't. What you have to do is copy the functions from one database to the other. Have a look in the extensions newsgroup for a thread with the subject

C;loning functions from disk to memory

Roy Lambert [Team Elevate]
Thu, Jul 25 2013 11:16 AMPermanent Link

Uli Becker

Roy,

it depends if you use a script and/or if you want to use the function in
a statement or just getting a value into a variable.

E.G.:

SCRIPT
BEGIN

  DECLARE MyValue VarCHAR;

  USE Dataset2;
  SET MyValue = MyFunction(MyParam);

  USE Dataset1;
  DoSomething with MyValue


END

Uli
Thu, Jul 25 2013 11:31 AMPermanent Link

Mario Enríquez

Open Consult

Actually, what I'm trying to achieve is using a function in another database to process some data in a local database.

Something along this form...

SELECT Database1.fnCalcSomething(Table1.Field1) FROM Table1

I would look into the copy/clon approach.

Regards,
Mario
Thu, Jul 25 2013 12:19 PMPermanent Link

Uli Becker

Mario,

ok, then Roy's approach is the best.

Uli
Thu, Jul 25 2013 1:12 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Mario


I've asked Tim for session level functions but its a tad difficult to see how to implement it since you can have multiple sessions (not simultaneously) pointing at the same database.

Roy Lambert
Image