Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion validating SQL syntax

Received: by 10.68.233.69 with SMTP id tu5mr7008013pbc.6.1334495198349;
        Sun, 15 Apr 2012 06:06:38 -0700 (PDT)
Path: r9ni59097pbh.0!nntp.google.com!news2.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
From: "zi...@dmateck.com" <zionass...@gmail.com>
Newsgroups: sybase.public.ase.general
Subject: Re: validating SQL syntax
Date: Sun, 15 Apr 2012 06:04:54 -0700 (PDT)
Organization: http://groups.google.com
Lines: 111
Message-ID: <1924996.1918.1334495094419.JavaMail.geo-discussion-forums@ynej18>
References: <4035aa00$1@forums-2-dub> <4035b0cf$1@forums-1-dub>
 <403615c0$1@forums-2-dub> <40361c4e@forums-1-dub>
NNTP-Posting-Host: 94.188.248.131
Mime-Version: 1.0
X-Trace: posting.google.com 1334495198 25772 127.0.0.1 (15 Apr 2012 13:06:38 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sun, 15 Apr 2012 13:06:38 +0000 (UTC)
Cc: Rob Verschoor <r...@do.not.spam.sypron.nl.remove.this.decoy>
In-Reply-To: <40361c4e@forums-1-dub>
Complaints-To: groups-abuse@google.com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=94.188.248.131;
 posting-account=HnQfFgoAAADBdPeBZwmnhYq_1AxHHhC3
User-Agent: G2/1.0
Content-Type: text/plain; charset=ISO-8859-1

On Friday, February 20, 2004 5:45:20 PM UTC+2, Rob Verschoor wrote:
> No - this would have the effect of not executing the exec() statement,
> invalidating the entire concept.  Please try this yourself!
> FYI, I've tried whether 'set parseonly on/off' would work, but this
> does not seem to have an effect inside a stored proc.
> 
> HTH,
> 
> Rob V.
> 
> "Name" <n...@somewhere.com> wrote in message
> news:403615c0$1@forums-2-dub...
> > Could I put a 'set noexec on' statement before the call to 'exec' so
> the query
> > wouldn't be executed? Would the procedure still work this way?
> >
> > On 19 Feb 2004 23:01:35 -0800,
> >  in sybase.public.ase.general
> > Rob Verschoor <r...@DO.NOT.SPAM.sypron.nl.REMOVE.THIS.DECOY> wrote:
> > >"Name" <n...@somewhere.com> wrote in message
> > >news:4035aa00$1@forums-2-dub...
> > >> Is there a stored procedure that can validate the syntax of a SQL
> > >statement?
> > >
> > >
> > >Not supplied by Sybase. But as I described in my book "Tips, Tricks
> &
> > >Recipes for Sybase ASE" (www.sypron.nl/ttr) you can use
> > >execute-immediate to perform such a check. Create a procedure like
> > >this:
> > >
> > >create proc p
> > >@cmd varchar(100)
> > >as
> > >exec(@cmd)
> > >if @@error != 0
> > >print "Syntax invalid"
> > >else
> > >print "Syntax valid"
> > >go
> > >
> > >This will work for most T-SQL statements. Some statements, like
> exec()
> > >itself, dbcc commands, and a few others, cannot be executed inside
> > >exec() so it would seem to be invalid syntax even though it's
> actually
> > >correct (this is because exec() wasn't intended to be used this
> way).
> > >
> > >You can optionally suppress the 'error message output with 'set
> > >background' as described in my book (see page 19). However, I
> strongly
> > >recommend not doing this unless you're aware of the sharp edges of
> > >this command (described in detail in my book).
> > >
> > >
> > >HTH,
> > >
> > >Rob V.
> > >-------------------------------------------------------------
> > >Rob Verschoor
> > >
> > >Certified Sybase Professional DBA for ASE 12.5/12.0/11.5/11.0
> > >and Replication Server 12.5
> > >
> > >Author of "Tips, Tricks & Recipes for Sybase ASE" and
> > >"The Complete Sybase ASE Quick Reference Guide"
> > >Online orders accepted at http://www.sypron.nl/shop
> > >
> > >mailto:r...@YOUR.SPAM.sypron.nl.NOT.FOR.ME
> > >http://www.sypron.nl
> > >Sypron B.V., P.O.Box 10695, 2501HR Den Haag, The Netherlands
> > >-------------------------------------------------------------
> > >

Hi,

See my try :

use ems
go


create  table dbo.toto(
   z   int  null
)
go
create  procedure titi
as
begin
declare @sql varchar(200)
select @sql="select getdate()"
exec (@sql)
end
go

create trigger tu_toto on toto for update
as
begin

/* Assume the loopback server was added as well (see mda installation requirements) */

exec loopback.ems..titi
end
go

declare @sql varchar(200)
select @sql="Update toto set z = 1"
exec (@sql)
go