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.

How to determine directory that database was started in

3 posts in General Discussion Last posting was on 2008-03-04 23:15:55.0Z
Dave Westphal Posted on 2008-03-04 19:06:42.0Z
From: "Dave Westphal" <Dave_Westphal@aal.org>
Newsgroups: ianywhere.public.general
Subject: How to determine directory that database was started in
Keywords: startup directory
Lines: 16
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <47cd9dc2$1@forums-1-dub>
Date: 4 Mar 2008 11:06:42 -0800
X-Trace: forums-1-dub 1204657602 10.22.241.152 (4 Mar 2008 11:06:42 -0800)
X-Original-Trace: 4 Mar 2008 11:06:42 -0800, vip152.sybase.com
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:6742
Article PK: 4988

Is there a db property that I can look at to see in what directory that
dbsrv9 was started in?

I have a stored procedure that is expecting a data file in a specific
directory. But some times when this stored procedure is called the database
had been started in a different directory. I get an error that the data file
can not be found.

version ASA 9.0.2.3486



Thanks,
Dave


Jeff Albion (Sybase iAnywhere) Posted on 2008-03-04 21:44:22.0Z
From: "Jeff Albion (Sybase iAnywhere)" <firstname.lastname@ianywhere.com>
User-Agent: Thunderbird 2.0.0.12 (Windows/20080213)
MIME-Version: 1.0
Newsgroups: ianywhere.public.general
Subject: Re: How to determine directory that database was started in
References: <47cd9dc2$1@forums-1-dub>
In-Reply-To: <47cd9dc2$1@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <47cdc2b6$1@forums-1-dub>
Date: 4 Mar 2008 13:44:22 -0800
X-Trace: forums-1-dub 1204667062 10.22.241.152 (4 Mar 2008 13:44:22 -0800)
X-Original-Trace: 4 Mar 2008 13:44:22 -0800, vip152.sybase.com
Lines: 41
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:6744
Article PK: 4987

Dave,

I assume you're looking to establish "the current working directory" of
the server.

There aren't any server-level properties in v9 that I'm aware of that
would give you this, but you might be able to skirt around this through
the liberal usage of xp_cmdshell / xp_readfile in a function:

CREATE FUNCTION get_cwd()
RETURNS VARCHAR(255)
BEGIN
DECLARE local_cwd VARCHAR(255);
CALL xp_cmdshell('cd > C:\\wd.txt', 'no_output');
SELECT xp_read_file( 'C:\\wd.txt' ) INTO local_cwd;
CALL xp_cmdshell('rm C:\\wd.txt', 'no_output');
RETURN local_cwd;
END;

SELECT get_cwd();

... bit of a kludge, I agree. But works. :)

Regards,

Dave Westphal wrote:
> Is there a db property that I can look at to see in what directory that
> dbsrv9 was started in?
> I have a stored procedure that is expecting a data file in a specific
> directory. But some times when this stored procedure is called the database
> had been started in a different directory. I get an error that the data file
> can not be found.

--
Jeff Albion, Product Support Analyst
Sybase iAnywhere

iAnywhere Developer Community : http://www.ianywhere.com/developer
iAnywhere Documentation : http://www.ianywhere.com/developer/product_manuals
ASA Patches and EBFs :
http://downloads.sybase.com/swd/summary.do?baseprod=144&client=ianywhere&timeframe=0


Jeff Albion (Sybase iAnywhere) Posted on 2008-03-04 23:15:55.0Z
From: "Jeff Albion (Sybase iAnywhere)" <firstname.lastname@ianywhere.com>
User-Agent: Thunderbird 2.0.0.12 (Windows/20080213)
MIME-Version: 1.0
Newsgroups: ianywhere.public.general
Subject: Re: How to determine directory that database was started in
References: <47cd9dc2$1@forums-1-dub> <47cdc2b6$1@forums-1-dub>
In-Reply-To: <47cdc2b6$1@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <47cdd82b@forums-1-dub>
Date: 4 Mar 2008 15:15:55 -0800
X-Trace: forums-1-dub 1204672555 10.22.241.152 (4 Mar 2008 15:15:55 -0800)
X-Original-Trace: 4 Mar 2008 15:15:55 -0800, vip152.sybase.com
Lines: 48
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:6745
Article PK: 4989

*Note: My first version is clearly not thread-safe. :) A better strategy
would be to put the value in a table on database start-up and select
from it as needed.

=========
CREATE TABLE my_cwd(
cwd VARCHAR(255);
)

INSERT INTO my_cwd (cwd) VALUES (NULL);

CREATE EVENT update_cwd TYPE DatabaseStart
HANDLER
BEGIN
CALL xp_cmdshell('cd > C:\\wd.txt', 'no_output');
UPDATE my_cwd SET cwd = xp_read_file( 'C:\\wd.txt' );
COMMIT;
CALL xp_cmdshell('rm C:\\wd.txt', 'no_output');
END;
=========

If this was v10, I'd probably recommend a global temporary table instead.

Still kinda kludgy, but less dangerous this way. :)

Regards,

Jeff Albion (Sybase iAnywhere) wrote:
> CREATE FUNCTION get_cwd()
> RETURNS VARCHAR(255)
> BEGIN
> DECLARE local_cwd VARCHAR(255);
> CALL xp_cmdshell('cd > C:\\wd.txt', 'no_output');
> SELECT xp_read_file( 'C:\\wd.txt' ) INTO local_cwd;
> CALL xp_cmdshell('rm C:\\wd.txt', 'no_output');
> RETURN local_cwd;
> END;
>
> SELECT get_cwd();

--
Jeff Albion, Product Support Analyst
Sybase iAnywhere

iAnywhere Developer Community : http://www.ianywhere.com/developer
iAnywhere Documentation : http://www.ianywhere.com/developer/product_manuals
ASA Patches and EBFs :
http://downloads.sybase.com/swd/summary.do?baseprod=144&client=ianywhere&timeframe=0