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 execute dynamic SQL statment from stored procedure?

3 posts in Windows NT Last posting was on 2000-01-25 15:57:17.0Z
prototechnika Posted on 2000-01-25 15:06:15.0Z
From: "prototechnika" <prototechnika@prototechnika.lt>
Subject: How to execute dynamic SQL statment from stored procedure?
Date: Tue, 25 Jan 2000 17:06:15 +0200
Lines: 15
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2314.1300
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
Message-ID: <Oa4OES0Z$GA.85@forums.sybase.com>
Newsgroups: sybase.public.sqlserver.nt
NNTP-Posting-Host: sl-195-22-163-126.p2p.omnitel.net 195.22.163.126
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.sqlserver.nt:2647
Article PK: 1090094

Hi,

How to execute dynamic SQL statments within stored procedures in Adaptive
Server Enterprise 11.9.2?

I try execute

EXECUTE ('SQL statment')

but get error message: Incorect syntax near '('.

Thanks for your help.


Bret Halford Posted on 2000-01-25 15:57:17.0Z
Message-ID: <388DC7DD.1ABC4DD@sybase.com>
Date: Tue, 25 Jan 2000 08:57:17 -0700
From: Bret Halford <bret@sybase.com>
Organization: Sybase, Inc.
X-Mailer: Mozilla 4.5 [en]C-CCK-MCD (WinNT; I)
X-Accept-Language: en
MIME-Version: 1.0
To: prototechnika <prototechnika@prototechnika.lt>
Subject: Re: How to execute dynamic SQL statment from stored procedure?
References: <Oa4OES0Z$GA.85@forums.sybase.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.sqlserver.nt
Lines: 19
NNTP-Posting-Host: bret-pc.sybase.com 157.133.80.211
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.sqlserver.nt:2644
Article PK: 1090092

The best way is to upgrade to ASE 12.0 where Dynamic SQL is actually a
supported feature of ASE.
It is not supported at all in ASE 11.9.2

The closest you can get in 11.9.2 to to use sp_remotesql against the local
server:

exec sp_remotesql myserver, "select * from mytable"

Note that this opens a new connection to the server and puts that connection
in your default database regardless of which database you are currently in.

-bret

prototechnika wrote:

> Hi,
>
> How to execute dynamic SQL statments within stored procedures in Adaptive
> Server Enterprise 11.9.2?
>
> I try execute
>
> EXECUTE ('SQL statment')
>
> but get error message: Incorect syntax near '('.
>
> Thanks for your help.


Jason Froebe Posted on 2000-01-25 15:52:38.0Z
Message-ID: <388DC6C6.9CD2823C@sybase.com>
Date: Tue, 25 Jan 2000 09:52:38 -0600
From: Jason Froebe <jfroebe@sybase.com>
Organization: Sybase, Inc.
X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.2.13 i686)
X-Accept-Language: en
MIME-Version: 1.0
To: prototechnika <prototechnika@prototechnika.lt>
Subject: Re: How to execute dynamic SQL statment from stored procedure?
References: <Oa4OES0Z$GA.85@forums.sybase.com>
Content-Type: multipart/mixed; boundary="------------C2BFC893E94BC5A0250A65B8"
Newsgroups: sybase.public.sqlserver.nt
Lines: 28
NNTP-Posting-Host: jfroebe-desktop.sybase.com 157.133.46.52
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.sqlserver.nt:2645
Article PK: 1090093


prototechnika wrote:

> Hi,
>
> How to execute dynamic SQL statments within stored procedures in Adaptive
> Server Enterprise 11.9.2?
>
> I try execute
>
> EXECUTE ('SQL statment')
>
> but get error message: Incorect syntax near '('.
>
> Thanks for your help.

Hi,

Dynamic SQL is supported starting in ASE 12.

You can emulate it by using extended stored procedures and such.

j


Download VCard jfroebe.vcf