Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Get actual path of database connection

3 posts in AEP Last posting was on 2009-03-04 13:56:04.0Z
QuintonMartin Posted on 2009-03-02 21:48:57.0Z
From: "QuintonMartin" <quinton.martin@cox.net>
Newsgroups: Advantage.AEP
Subject: Get actual path of database connection
Date: Mon, 2 Mar 2009 14:48:57 -0700
Lines: 19
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 12.44.147.194
Message-ID: <49ac5484@solutions.advantagedatabase.com>
X-Trace: 2 Mar 2009 14:49:56 -0700, 12.44.147.194
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!12.44.147.194
Xref: solutions.advantagedatabase.com Advantage.AEP:685
Article PK: 1103969

Is there a way to get the actual path of the ADD or ADT file from an AEP.
My AEP is written in Delphi, but I could use another language if necessary.
I want the actual path from the server, not from the client. In other
words, no matter how the client passes the connection path to the server

x:\mydata\mydb.add
\\server\share\mydata\mydb.add
\\1.2.3.4:6262\share\mydata\mydb.add

I always want to get back this result

c:\databases\production\mydata\mydb.add

ADS 8.1 and 9.0

TIA
Quinton Martin


Peter Funk (ADS) Posted on 2009-03-02 22:59:51.0Z
Date: Mon, 2 Mar 2009 22:59:51 +0000 (UTC)
Message-ID: <864d0bcb170dd8cb69670e6749d1@devzone.advantagedatabase.com>
From: Peter Funk (ADS) <pfunk@nospam.com>
Subject: Re: Get actual path of database connection
Newsgroups: Advantage.AEP
References: <49ac5484@solutions.advantagedatabase.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=iso-8859-1; format=flowed
X-Newsreader: JetBrains Omea Pro 1098.1
NNTP-Posting-Host: 10.24.38.185
X-Trace: 2 Mar 2009 15:59:24 -0700, 10.24.38.185
Lines: 36
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!10.24.38.185
Xref: solutions.advantagedatabase.com Advantage.AEP:686
Article PK: 1103964

Hello Quinton,
To get a server-side table path you'll need to use a management API or system
procedure. I think sp_mgGetAllTables will be your best bet (AdsMgGetOpenTables
is the ACE API equivalent).

Inside your AEP, use a TAdsQuery component to execute sp_mgGetAllTables and
then find the appropriate path for your ADD file. Here's a quick-n-dirty
example I just wrote using the Delphi AEP template:

AdsQuery1 := TAdsQuery.Create( nil );
AdsQuery1.AdsConnection := DM1.DataConn; // Connection provided
to the AEP by ADS
AdsQuery1.SourceTableType := ttAdsADT;
AdsQuery1.SQL.Add('EXECUTE PROCEDURE sp_mgGetAllTables()' );
AdsQuery1.ExecSQL;
AdsQuery1.Open;
AdsQuery1.First;

{* Finally return any output parameters. *}
tblOutput.open;
tblOutput.append;
tblOutput.FieldByName( 'path' ).Value := AdsQuery1.Fields[0].Value;
// Server-side path of the first table
tblOutput.post;
tblOutput.close;
AdsQuery1.Close;

This example only works if the ADD is the only table open, but you get the
idea. To make this actually work, you'd have to find the ADD in the result
set returned by AdsQuery1.

Regards,
Peter Funk
Advantage R&D


Joachim Duerr (ADS) Posted on 2009-03-04 13:56:04.0Z
From: "Joachim Duerr (ADS)" <jojo.duerr@gmx.de>
Subject: Re: Get actual path of database connection
Newsgroups: Advantage.AEP
References: <49ac5484@solutions.advantagedatabase.com>
Date: Wed, 4 Mar 2009 14:56:04 +0100
User-Agent: XanaNews/1.19.1.110
X-Face: u2p+</,mb|Ah!x!/qxX5q0t:O~.<1&JzwNHYhSqcviY{~&|iDc"U.Je1A.ZeHR`d;;y#R
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
NNTP-Posting-Host: 130.214.79.11
Message-ID: <49ae885a@solutions.advantagedatabase.com>
X-Trace: 4 Mar 2009 06:55:38 -0700, 130.214.79.11
Lines: 57
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!130.214.79.11
Xref: solutions.advantagedatabase.com Advantage.AEP:687
Article PK: 1103968


QuintonMartin wrote:

>Is there a way to get the actual path of the ADD or ADT file from an
>AEP. My AEP is written in Delphi, but I could use another language if
>necessary. I want the actual path from the server, not from the
>client. In other words, no matter how the client passes the
>connection path to the server
>
>x:\mydata\mydb.add
>\\server\share\mydata\mydb.add
>\\1.2.3.4:6262\share\mydata\mydb.add
>
>I always want to get back this result
>
>c:\databases\production\mydata\mydb.add
>
>ADS 8.1 and 9.0

I'd suggest using ApplicationId to identify the connection:

<snip>
declare @id string;
declare @c cursor;
declare @tmp string;

@id=applicationid();

execute procedure sp_SetApplicationId('123_mytest_321');

open @c as execute procedure sp_mggetconnectedusers();
while fetch @c do
@tmp=@c.username;
if @c.applicationid='123_mytest_321' then
leave;
endif;
end while;
close @c;

/// (1)

execute procedure sp_SetApplicationId(@id);
select @tmp from system.iota;
</snip>

Then, in (1), use a cursor with
<snip>
execute procedure sp_mgGetUserTables(@tmp);
</snip>
to get all open tables of this user. Unfortunately if a machine
connects to more than one database, you might get the path of the other
one. There's currently no way to use just this connection.

--
Joachim Duerr
Advantage Presales
Sybase GmbH
please don't reply via email