Home > Archive > SQL Anywhere database > May 2005 > remote dsn named later









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author remote dsn named later
Confused

2005-05-24, 8:23 pm

Can I create a remote server using a dsn to be named later?
Such as.....

create procedure remoteTCTrans(in dsnName varchar(16))
begin
CREATE SERVER remoteTCTrans
CLASS 'ASAODBC'
USING dsnName
end

......or something to that effect?
Greg Fenton

2005-05-25, 3:23 am

Confused wrote:
> Can I create a remote server using a dsn to be named later?


Yes. However you cannot use that remote server until the DNS name
exists (e.g. you cannot CREATE EXISTING TABLE to create a proxy table).

greg.fenton
--
Greg Fenton
Consultant, Solution Services, iAnywhere Solutions
--------
Visit the iAnywhere Solutions Developer Community
Whitepapers, TechDocs, Downloads
http://www.ianywhere.com/developer/
confused

2005-05-25, 9:23 am

OK, so when I try this...

create procedure remoteTCTrans(in dsnName varchar(16))
begin
CREATE SERVER remoteTCTrans
CLASS 'ASAODBC'
USING dsnName
end

.... it fails to create a stored procedure, stating: "Syntax
error near dsnName".
>
> Yes. However you cannot use that remote server until the
> DNS name exists (e.g. you cannot CREATE EXISTING TABLE to
> create a proxy table).
>
> greg.fenton
> --
> Greg Fenton
> Consultant, Solution Services, iAnywhere Solutions
> --------
> Visit the iAnywhere Solutions Developer Community
> Whitepapers, TechDocs, Downloads
> http://www.ianywhere.com/developer/

Reg Domaratzki \(iAnywhere Solutions\)

2005-05-25, 11:23 am

The using clause of the CREATE SERVER command cannot take a variable.
You'll need to use Execute Immediate

create procedure remoteTCTrans(in dsnName varchar(16))
begin
delcare stmt long varchar;
set stmt = 'CREATE SERVER remoteTCTrans CLASS ''ASAODBC'' USING ' ||
dsnName;
execute immediate stmt;
end


--
Reg Domaratzki, Sybase iAnywhere Solutions
Sybase Certified Professional - Sybase ASA Developer Version 8
Please reply only to the newsgroup

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/swx/sdmain.stm
-> Choose SQL Anywhere Studio
-> Set "Platform Preview" and "Time Frame" to ALL

<confused> wrote in message news:42948d82.4724.1681692777@sybase.com...[color=darkred]
> OK, so when I try this...
>
> create procedure remoteTCTrans(in dsnName varchar(16))
> begin
> CREATE SERVER remoteTCTrans
> CLASS 'ASAODBC'
> USING dsnName
> end
>
> ... it fails to create a stored procedure, stating: "Syntax
> error near dsnName".


Erik Anderson

2005-05-25, 11:23 am

Umm, try EXECUTE IMMEDIATE?

<confused> wrote in message news:42948d82.4724.1681692777@sybase.com...[color=darkred]
> OK, so when I try this...
>
> create procedure remoteTCTrans(in dsnName varchar(16))
> begin
> CREATE SERVER remoteTCTrans
> CLASS 'ASAODBC'
> USING dsnName
> end
>
> ... it fails to create a stored procedure, stating: "Syntax
> error near dsnName".


Bruce Hay

2005-05-25, 1:23 pm

You'll also need to add quotes around the connection string:

create procedure remoteTCTrans(in dsnName long varchar)
begin
execute immediate 'CREATE SERVER remoteTCTrans ' ||
'CLASS ''ASAODBC'' USING ''' || dsnName || '''';
end


Whitepapers, TechDocs, bug fixes are all available through the iAnywhere
Developer Community at http://www.ianywhere.com/developer

"Reg Domaratzki (iAnywhere Solutions)" < Spam_bad_rdomarat@ia
nywhere.com>
wrote in message news:4294a079$1@foru
ms-1-dub...
> The using clause of the CREATE SERVER command cannot take a variable.
> You'll need to use Execute Immediate
>
> create procedure remoteTCTrans(in dsnName varchar(16))
> begin
> delcare stmt long varchar;
> set stmt = 'CREATE SERVER remoteTCTrans CLASS ''ASAODBC'' USING ' ||
> dsnName;
> execute immediate stmt;
> end
>
>
> --
> Reg Domaratzki, Sybase iAnywhere Solutions
> Sybase Certified Professional - Sybase ASA Developer Version 8
> Please reply only to the newsgroup
>
> 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/swx/sdmain.stm
> -> Choose SQL Anywhere Studio
> -> Set "Platform Preview" and "Time Frame" to ALL
>
> <confused> wrote in message news:42948d82.4724.1681692777@sybase.com...
>
>



Thanks!!!!!!!

2005-05-25, 8:23 pm

I appreciate everyone's help, that was just what I needed!


> Can I create a remote server using a dsn to be named
> later? Such as.....
>
> create procedure remoteTCTrans(in dsnName varchar(16))
> begin
> CREATE SERVER remoteTCTrans
> CLASS 'ASAODBC'
> USING dsnName
> end
>
> .....or something to that effect?

Breck Carter [TeamSybase]

2005-05-26, 7:23 am

FWIW you don't actually *need* a DSN...

CREATE SERVER sss CLASS 'ASAODBC'
USING 'DRIVER=Adaptive Server Anywhere 9.0;ENG=sss;DBN=ddd';

Breck

On 24 May 2005 16:32:51 -0700, Confused wrote:

>Can I create a remote server using a dsn to be named later?
>Such as.....
>
>create procedure remoteTCTrans(in dsnName varchar(16))
>begin
>CREATE SERVER remoteTCTrans
>CLASS 'ASAODBC'
>USING dsnName
>end
>
>.....or something to that effect?


--
SQL Anywhere Studio 9 Developer's Guide
Buy the book: http://www.amazon.com/exec/obidos/A...7/risingroad-20
bcarter@risingroad.com
RisingRoad SQL Anywhere and MobiLink Professional Services
www.risingroad.com
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com