473,799 Members | 2,723 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checking SQL syntax

WF
Hello,
I don't know if it is the right place for my question but I would like to
know if ther's a way to validate a SQL request before sending it to the
database. I was thinking abut using Regular Expresssion or something like
that .
Thanks for your answer.
Nov 16 '05 #1
5 4654
Hi WF:

You might try sending the SQL command to the database after a SET
PARSEONLY ON command. This instructs the server to check syntax and
return error messages without compiling and executing the statement.

Don't forget to SET PARSEONLY OFF afterwards.

--
Scott
http://www.OdeToCode.com

On Thu, 2 Sep 2004 22:08:48 +0200, "WF" <wf*******@tele 2.fr> wrote:
Hello,
I don't know if it is the right place for my question but I would like to
know if ther's a way to validate a SQL request before sending it to the
database. I was thinking abut using Regular Expresssion or something like
that .
Thanks for your answer.


Nov 16 '05 #2
WF
Thanks for your answer.
More details on my problem.
I'm coding an ASP.Net application and one of the web forms allow the user to
build SQL request using basic field and operators. So the string generated
can look like that :
(field1='test' and (field3 > 10 and field3 < 30)) OR field2 like '%user'
......
I use C# to develop and that's why I was thinking about using Regex.
My purpose is to validate the string before it is sent to the database.
I've searched the net about and found nothing.
Has anybody already done that ?
"Scott Allen" <bitmask@[nospam].fred.net> a écrit dans le message de
news:3u******** *************** *********@4ax.c om...
Hi WF:

You might try sending the SQL command to the database after a SET
PARSEONLY ON command. This instructs the server to check syntax and
return error messages without compiling and executing the statement.

Don't forget to SET PARSEONLY OFF afterwards.

--
Scott
http://www.OdeToCode.com

On Thu, 2 Sep 2004 22:08:48 +0200, "WF" <wf*******@tele 2.fr> wrote:
Hello,
I don't know if it is the right place for my question but I would like to
know if ther's a way to validate a SQL request before sending it to the
database. I was thinking abut using Regular Expresssion or something like
that .
Thanks for your answer.

Nov 16 '05 #3

You'll have to check the docs to be sure, but I think
starting in SQL 7.x or 2000 there was a feature to send
the request and have it validated rather than processed.
-----Original Message-----
Hello,
I don't know if it is the right place for my question but I would like toknow if ther's a way to validate a SQL request before sending it to thedatabase. I was thinking abut using Regular Expresssion or something likethat .
Thanks for your answer.


Nov 16 '05 #4
The complexity of the Structured Query Language is so high that it doesn't
make sense to write your own "validator" especially when you can pass the
SQL to the database and have it validate the statement for you.

--- Nick

"WF" <wf*******@tele 2.fr> wrote in message
news:%2******** *******@TK2MSFT NGP10.phx.gbl.. .
Thanks for your answer.
More details on my problem.
I'm coding an ASP.Net application and one of the web forms allow the user to build SQL request using basic field and operators. So the string generated
can look like that :
(field1='test' and (field3 > 10 and field3 < 30)) OR field2 like '%user'
.....
I use C# to develop and that's why I was thinking about using Regex.
My purpose is to validate the string before it is sent to the database.
I've searched the net about and found nothing.
Has anybody already done that ?
"Scott Allen" <bitmask@[nospam].fred.net> a écrit dans le message de
news:3u******** *************** *********@4ax.c om...
Hi WF:

You might try sending the SQL command to the database after a SET
PARSEONLY ON command. This instructs the server to check syntax and
return error messages without compiling and executing the statement.

Don't forget to SET PARSEONLY OFF afterwards.

--
Scott
http://www.OdeToCode.com

On Thu, 2 Sep 2004 22:08:48 +0200, "WF" <wf*******@tele 2.fr> wrote:
Hello,
I don't know if it is the right place for my question but I would like toknow if ther's a way to validate a SQL request before sending it to the
database. I was thinking abut using Regular Expresssion or something likethat .
Thanks for your answer.


Nov 16 '05 #5
Even if you send it to the database and it validates it as correct, it
doesn't mean that it's guaranteed to run through successfully. It just means
that there aren't any compile-time errors, there may still be runtime errors.
"WF" wrote:
Hello,
I don't know if it is the right place for my question but I would like to
know if ther's a way to validate a SQL request before sending it to the
database. I was thinking abut using Regular Expresssion or something like
that .
Thanks for your answer.

Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3010
by: Tongu? Yumruk | last post by:
I have a little proposal about type checking in python. I'll be glad if you read and comment on it. Sorry for my bad english (I'm not a native English speaker) A Little Stricter Typing in Python - A Proposal As we all know, one of the best things about python and other scripting languages is dynamic typing (yes I know it has advantages and disadvantages but I will not discuss them now). Dynamic typing allows us to change types of...
6
25070
by: Jeff Duffy | last post by:
Hi all. I've been wondering why python itself doesn't provide a switch to check a file for valid syntax. I know that you can currently call python -c "import py_compile; py_compile.compile(r'MyApp.py')" but in order to manage this effectively you have to add a shell alias, write a script, mess about with your editor, or what have you. This becomes yet another small annoyance I'd like to get rid of. I'm also
2
2058
by: George Sakkis | last post by:
I downloaded the latest Komodo (3.1) and configured it for python 2.4 so that it doesn't show decorators and genexps as syntax errors, but background syntax checking doesn't seem to work at all for python 2.4. Even for correct files, it shows a "Syntax checking error: Error checking syntax: retval = 128, stderr=" alert. For python 2.3 it works fine (modulo the new 2.4 syntax of course). Both 2.3 and 2.4 are built from source on Cygwin, not...
84
5964
by: Andy Glew | last post by:
I am in search of any rigourous, scientific, academic or industrial studies comparing naming conventions in C++ or similar languages such as Ada: Specifically, are names formed with underscores more or less readable than names formed with MixedCase StudlyCaps camelCase?
8
10342
by: Clifford W. Racz | last post by:
Does anyone know of a decent tool, preferably free, that will check and validate DTD syntax, to make sure that my DTD is correct? The only tool that I have found thus far is the IBM visual DTD tool, which I do like, but is limited. Basically, your DTD is "good" when it parses... and I am not sure this is the best way to do it. As for validation of XML, I have found a great tool, xmlvalid, here: <...
67
4286
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. Unfortunately these ad hominem rhetorts are frequently introduced into purely technical discussions on the feasibility of supporting such functionality in C++. That usually serves to divert the discussion from the technical subject to a discussion of the...
4
2561
by: Rich | last post by:
I have a access form that is connected to linked sql table via odbc. I have some fields that I dont want to allow nulls when data is entered via the form. I can set the null checking on the SQL server database but the ODBC error tha tis returned is not very polite to the user since it mentions the sql field not the nice label. Is there a way for me to modify this error or put the check in access?
1
3310
by: Karim Nassar | last post by:
I am writing functions and I find it curious that CREATE FUNCTION does not do syntax checking. Example: test=# CREATE FUNCTION foo(INTEGER) RETURNS BOOLEAN test-# AS 'this is total crap' LANGUAGE plpgsql; CREATE FUNCTION test=# select foo(1); ERROR: syntax error at or near "this"
16
2638
by: lawrence k | last post by:
I've made it habit to check all returns in my code, and usually, on most projects, I'll have an error function that reports error messages to some central location. I recently worked on a project where someone suggested to me I was spending too much time writing error messages, and that I was therefore missing the benefit of using a scripting language. The idea, apparently, is that the PHP interpreter writes all the error messages that are...
7
6868
by: john.cole | last post by:
I have searched all the groups I can, and I still haven't been able to come up the solution I need. I have the following problem. In my form named sbfrmSpoolList, I am entering a job, spool and revision number. My table is indexed properly to not allow duplicates, but I would like teh user to be notified that they are typing a duplicate via a message box, then I woulld the update of the record to be cancelled. I have tried the...
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9543
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10488
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10029
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6808
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.