Check the validity of a SQL statement before execution
Hi everyone,
In an applet I have created, I am allowing the user to create a SQL statement which will be sent to a servlet that in turn issues the JDBC request for the SQL statement. My concern is that since my GUI lets the user create more or less any kind of SQL statement (including an illegal one) I need to verify if the user has created the correct SQL. How can this be achieved?
To recapitulate and summarize, I need to know how I can check the validity of a SQL statement without actually executing it and handling the SQLException. FYI, I am using the mm-mysql driver.
Thanks,
Alan
jschell is correct. Unless you're writing something like an ISQL tool you want to be very careful doing this.
Having said that Mimer SQL have SQL validators that may do what you want http://developer.mimer.com/validator/index.htm
They've also got the SQL Validator running as a web service that you can use. Theres example code here showing how to use it.
http://sqlvalidator.mimer.com/index.html
At the risk of being accused of selfpromotion you can check out the SQL Validator plugin for SQuirreL SQL CLient. This is a fully functional example of using the Mimer SQL Validation web service. http://squirrel-sql.sourceforge.net/
Col
Similar Messages
-
View the reports sql statement before execution
Hi
I am developing reports with dynamic sql statements.
How can I view the complete reports sql statement which is sent to the database?
Thanks
JuergYou can turn on the trace functionality. That will display the actual SQL statements sent to the database in the trace file.
-
Determining the "type" of a SQL statement
I'm using the Oracle thin driver with my JDBC program.
I want to be able to accept a String containing a SQL statement from the user and execute it. If it's a select statement then present the rows returned in a JTable, otherwise retrieve the return value for the command (eg INSERT, DELETE, etc).
Is there any "readymade" method in JDBC or Oracle driver to determine the type of a SQL statement in this sense. Or do I have to parse it myself? (Imagine having to write code to strip comments out etc!)There is no "readymade" method. But an easy way to check will be to check the first 6 charchters of the string.
You could use
newString = SQL.substring(0, 5); to obtain the first 6 characters.
if the characters are "select"
//do select things
else
// do insert/delete whatever things -
Changing sql-statement before executing query
I want to change the sql-statement of a query just before it is executed.
I have tried it with a query redirector/sessionevent listener, but I could get it to work.
Do you have any examples.
I want to change the tablename in a sql-statement like this:
before
select id from emp
after
select id from emp_v
Any examples out there to do this?... I am using SAP NetWeaver BI 7.0
Monique -
Is there anyway we can check the validity of dump file in Unix system
Hi,
I have taken export of 2 tables which are huge in volume. one of the table seems to be successfully exported yet another one failed due to space scarcity. Since both the tables share a single dumpfile.
I wanted to know.
1. Can we use the same dumpfile to import the table which is successfull or it can not be used because the second table got error while exporting?
2. Is there any way we can check the validity of dumpfile in unix plateform.
Your reply is highly appreciated.784786 wrote:
Hi,
I have taken export of 2 tables which are huge in volume. one of the table seems to be successfully exported yet another one failed due to space scarcity. Since both the tables share a single dumpfile.
I wanted to know.
1. Can we use the same dumpfile to import the table which is successfull or it can not be used because the second table got error while exporting?No. It is better to take another backup of the same
>
2. Is there any way we can check the validity of dumpfile in unix plateform.
Please check the export log backup. If it says that export terminated successfully, then the dump may be fine. -
How to export the result from executing sql statement to excel file ?
HI all,
Great with Oracle SQL Developer, but I have have a trouble as follwing :
I want to export the result from executing sql statement to excel file . I do easily like that in TOAD ,
anyone can help me to do that ? Thanks so much
SigmasvnHello Sue,
I just tried to export to excel with the esdev extension and got java.lang.NumberFormatException. I found the workaround at Re: Windows Multi-language env, - how do I set English for application lang?
open the file sqldeveloper\jdev\bin\sqldeveloper.conf and add the following two lines:
AddVMOption -Duser.language=en
AddVMOption -Duser.country=USyet now my date formats in excel are 'american-style' instead of german. For example 01-DEC-01 so excel does not recognize it as date and therefore I can not simply change the format.
When export to excel will be native to 1.1 perhaps someone can have a look at this 'feature'
Regards
Marcus -
Can the format of a SQL Statement modify the execution time of an SQL statement?
Thanks in advanceIt depends on:
1) What oracle version are you using
2) What do you mean for "format"
For example: if you're on Oracle9i and changing format means changing the order of the tables in the FROM clause and you're using Rule Based Optimizer then the execution plan and the execution time can be very different...
Max
[My Italian Oracle blog|http://oracleitalia.wordpress.com/2009/12/29/estrarre-i-dati-in-formato-xml-da-sql/] -
hi..i'm creating a new user jsp page and in that i want to check whether the date entered by user as his/her date of birth is valid or not...i've taken three dropdown boxes to enter the date, month & year. how will i check the validity and concate three values and save it in database..thnx
Validate it using java.util.Calendar which is set not to be lenient.
Example: [http://balusc.blogspot.com/2007/09/calendarutil.html].
Save it in DB using PreparedStatement#setDate().
Example: [http://java.sun.com/docs/books/tutorial/jdbc/basics/prepared.html].
The field in DB must be a DATE, DATETIME, or TIMESTAMP. -
How to check the validation of RegEx
Hi,
My application needs users to enter RegEx. My question is how I can check the validation of the RegEx that users enter. The Class RegExp does not seem to provide any methods to check the validation of the RegEx.
Regards,
HaibinYou would need to hand roll your own validator, unless someone knows of one that is out there. Flex does not validate RegEx.
If this post answers your question or helps, please mark it as such. -
Ehancement for to check the validations in ME21n,ME22n,ME28,ME29n
Hi experts...
I have one requirement in Ehancement for to check the validations in ME21n,ME22n,ME28,ME29n...
If the PO document date is after 31.12.2010 and vendor Group 1800 then check the Inco-terms with "SET" values whether the user entered value fals with in the "SET" value, if so then allow to save the PO else Else system should read the "SET" values and suggest user to select correct Inco terms.
Example when user enter wrong Inco-Terms then system shoud give Error Message Please Select Inco-terms CPT or DAP or FCA..
Can any body plz suggest me the user exit or Is it possible through the enhancement Framework...
plz help me how to proceedd??
Thanks & Regards,
Veena.
Moderator Message: Spec-dumping is not allowed.
Edited by: kishan P on Jan 3, 2011 11:00 AMHi Veena,
To find a BADI for a given tcode follow the below steps.
1. Go to the TCode.
2. Menu Item System -> Status.
3. Double click on the transaction Name (For ME21N double click on ME21N).
4. Check the Package (e.g. ME)
5. Go to TCode SE80
6. In the drop down choose Package and type the Package Name (e.g. ME). Dont forget to Hit Enter or display.
7. Object Name Enhancements -> Business Add-ins (Def.) (You will see all the BADI's available here ).
In your case, you need BADI : ME_BAPI_PO_CUST.
Go to SE19 to implement the BADI.
If you put your conditions in Create Purchase Order(ME21N), you will not need to add them in Release PO(ME28N) since the conditions will be checked when PO is created.
Regards,
Jovito. -
How to check the validity period of saprouter ?
Dear all,
As per sap note 1178684, we can check the validity period of the saprouter by executing "sapgenpse get_my_name -n validity"
I am wondering how to run that command in as/400 ?
Please advise. I am not familiar with as/400 OS.
Thanks
Regards,
KentHi Kent,
please proceed as described on the http://www.easymarketplace.de/snc-iseries-setup.php
logon with sidadm (or sidofr):
(depending on the user, that is running the SAPRouter)
CD DIR('/usr/sap/saprouter')
ADDLIBLE LIB(SAPROUTER) ??? or whereever the stuff is ...
RMVENVVAR ENVVAR('SECUDIR')
ADDENVVAR ENVVAR('SECUDIR') VALUE('/usr/sap/saprouter')
RMVENVVAR ENVVAR('SNC_LIB')
ADDENVVAR ENVVAR('SNC_LIB') VALUE('/usr/sap/saprouter/sapcrypto')
CALL PGM(SAPGENPSE) PARM('get_my_name')
Regards
Volker Gueldenpfennig, consolut international ag
http://www.consolut.net - http://www.4soi.de - http://www.easymarketplace.de -
Can we capture SQL Queries before execution?
Hi Everyone,
I would like to know that is there any way to capture SQL queries before execution?
please advise.
thanks
kvHi!
You could capture the querys and use them as a payload for the "Database Engine Tuning Advisor".
Maybe it gives you some indexes which raise the performance.
But:
I only would add indexes to user tables.
Cheers,
Roland
PS.:
Indexes which are created directly through SQL could be lost after a B1 Upgrade. So saving the creation-statements in a warm and secure place is recommended
PPS.:
...and maybe such indexes are not supported by SAP...
Edited by: Roland Toschek on Dec 1, 2008 6:23 PM -
Size of SQL query before execution and after execution
hi all
I need help on how can i find out the size of SQL query before execution and after execution in java
The query can be any query select / insert / update
Can anyone help me if any system tables help to find out the required size i mentioned
Urgent help is required
Thanking in advanceI need the size in terms of bytes
like the rquirement is stated as below
select ................: 10 B , return 250 B
so i need size before and after execution in terms of bytes -
How to check the validation in UI before committing data?
Hi,
I'm using Jdev 11.1.2.1.0 version .
I needed to check whether there is duplication of values in Boolean check box before committing the data into the Database.
But this validation rule is to be checked based on the value selected in the Select One Choice drop down list in the page.
I did it with adding a ValueChangeEvent in the drop down list and checking the values in the Boolean check box. It worked , but only in the case of earlier committed data in the database.
How can i actually verify the data entered in the table in the page before it being committed into the DB ?
Nigel.Hi,
an improvement to your solution would be to move the major part of your code from the backing bean into a method on the ApplicationModuleImpl file (you create this from the AM editor)
public boolean checkForDuplicate(){
ViewObject vo = this.findViewObject("ResponseVO");
int numRows;
int j=0;
numRows = vo.getRowCount();
String rowValue = "a";
//the part below of your code I don't like at all. Why do you need to increase a flag
//and use an if statement ?
for (int i=0; i<numRows; i++){
rowValue = (String)vo.getCurrentRow().getAttribute("ResponseFlag");
if(rowValue.equals("Y")){
j++;
if(j>1)
return true;
return false;
}This code you then expose on the AM as a client interface (same AM editor --> Java menu option)
In the PageDef file (double click it to access the visual editor) click the plus icon next to the Bindings header. Choose "Generic Binding" --> method binding and point it to the AM and the exposed method. This creates a method binding "checkForDuplicate"
Change your managed bean code to
BindingContext bctx = BindingContext.getCurrent();
BindingContainer bindings = bctx.getCurrentBindingsEntry();
OperationBinding checkForDuplicate = (OperationBinding ) bindings.get("checkForDuplicate");
checkForDuplicate.execute();
boolean isDuplicate = checkForDuplicate.getResult();
if(isDuplicate){
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, null, "Two same respones!");
FacesContext.getCurrentInstance().addMessage(null, msg);
Frank -
Check for duplicate record in SQL database before doing INSERT
Hey guys,
This is part powershell app doing a SQL insert. BUt my question really relates to the SQL insert. I need to do a check of the database PRIOR to doing the insert to check for duplicate records and if it exists then that record needs
to be overwritten. I'm not sure how to accomplish this task. My back end is a SQL 2000 Server. I'm piping the data into my insert statement from a powershell FileSystemWatcher app. In my scenario here if the file dumped into a directory starts with I it gets
written to a SQL database otherwise it gets written to an Access Table. I know silly, but thats the environment im in. haha.
Any help is appreciated.
Thanks in Advance
Rich T.
#### DEFINE WATCH FOLDERS AND DEFAULT FILE EXTENSION TO WATCH FOR ####
$cofa_folder = '\\cpsfs001\Data_pvs\TestCofA'
$bulk_folder = '\\cpsfs001\PVS\Subsidiary\Nolwood\McWood\POD'
$filter = '*.tif'
$cofa = New-Object IO.FileSystemWatcher $cofa_folder, $filter -Property @{ IncludeSubdirectories = $false; EnableRaisingEvents= $true; NotifyFilter = [IO.NotifyFilters]'FileName, LastWrite' }
$bulk = New-Object IO.FileSystemWatcher $bulk_folder, $filter -Property @{ IncludeSubdirectories = $false; EnableRaisingEvents= $true; NotifyFilter = [IO.NotifyFilters]'FileName, LastWrite' }
#### CERTIFICATE OF ANALYSIS AND PACKAGE SHIPPER PROCESSING ####
Register-ObjectEvent $cofa Created -SourceIdentifier COFA/PACKAGE -Action {
$name = $Event.SourceEventArgs.Name
$changeType = $Event.SourceEventArgs.ChangeType
$timeStamp = $Event.TimeGenerated
#### CERTIFICATE OF ANALYSIS PROCESS BEGINS ####
$test=$name.StartsWith("I")
if ($test -eq $true) {
$pos = $name.IndexOf(".")
$left=$name.substring(0,$pos)
$pos = $left.IndexOf("L")
$tempItem=$left.substring(0,$pos)
$lot = $left.Substring($pos + 1)
$item=$tempItem.Substring(1)
Write-Host "in_item_key $item in_lot_key $lot imgfilename $name in_cofa_crtdt $timestamp" -fore green
Out-File -FilePath c:\OutputLogs\CofA.csv -Append -InputObject "in_item_key $item in_lot_key $lot imgfilename $name in_cofa_crtdt $timestamp"
start-sleep -s 5
$conn = New-Object System.Data.SqlClient.SqlConnection("Data Source=PVSNTDB33; Initial Catalog=adagecopy_daily; Integrated Security=TRUE")
$conn.Open()
$insert_stmt = "INSERT INTO in_cofa_pvs (in_item_key, in_lot_key, imgfileName, in_cofa_crtdt) VALUES ('$item','$lot','$name','$timestamp')"
$cmd = $conn.CreateCommand()
$cmd.CommandText = $insert_stmt
$cmd.ExecuteNonQuery()
$conn.Close()
#### PACKAGE SHIPPER PROCESS BEGINS ####
elseif ($test -eq $false) {
$pos = $name.IndexOf(".")
$left=$name.substring(0,$pos)
$pos = $left.IndexOf("O")
$tempItem=$left.substring(0,$pos)
$order = $left.Substring($pos + 1)
$shipid=$tempItem.Substring(1)
Write-Host "so_hdr_key $order so_ship_key $shipid imgfilename $name in_cofa_crtdt $timestamp" -fore green
Out-File -FilePath c:\OutputLogs\PackageShipper.csv -Append -InputObject "so_hdr_key $order so_ship_key $shipid imgfilename $name in_cofa_crtdt $timestamp"
Rich ThompsonHi
Since SQL Server 2000 has been out of support, I recommend you to upgrade the SQL Server 2000 to a higher version, such as SQL Server 2005 or SQL Server 2008.
According to your description, you can try the following methods to check duplicate record in SQL Server.
1. You can use
RAISERROR to check the duplicate record, if exists then RAISERROR unless insert accordingly, code block is given below:
IF EXISTS (SELECT 1 FROM TableName AS t
WHERE t.Column1 = @ Column1
AND t.Column2 = @ Column2)
BEGIN
RAISERROR(‘Duplicate records’,18,1)
END
ELSE
BEGIN
INSERT INTO TableName (Column1, Column2, Column3)
SELECT @ Column1, @ Column2, @ Column3
END
2. Also you can create UNIQUE INDEX or UNIQUE CONSTRAINT on the column of a table, when you try to INSERT a value that conflicts with the INDEX/CONSTRAINT, an exception will be thrown.
Add the unique index:
CREATE UNIQUE INDEX Unique_Index_name ON TableName(ColumnName)
Add the unique constraint:
ALTER TABLE TableName
ADD CONSTRAINT Unique_Contraint_Name
UNIQUE (ColumnName)
Thanks
Lydia Zhang
Maybe you are looking for
-
Report generation for users having specific license type
Hi friends, For my project purpose i have to generate report which has userId,License type of the user,corresponding composite role and single roles assigned to the user and transaction code. I can get the report for user and license type from USR06
-
A question about SKTO in condition tab
Hi all, i am a starter in SD, and trying to figure out how to create a sales deal, so i created one sales deal with payment term ZB03. And conditon K007 5% discount for customer1 ist created under this sales deal. customer1 master data has payment ZB
-
Battery down after reinstalling WXP on Satellite 2450
Hi all, that's my first topic and wish to get help on a serious problem i got with my notebook. So, after reinstalling XP on my Satellite 2450-101, the battery gone down. I did reinstall the common modules , the utilities and the powersaver, but ever
-
How to install netgear wgr614v6 wireless router
im having so much trouble with this. its not doing nething it sud be. absolutely no help off netgear and no instillation cd. can anyone help please!
-
Dot1x - Difference between "mab" and "mab eap"
Hi guys, can someone explain the difference between "mab" and "mab eap" to me? I`m trying to do dot1x with EAP-TLS with MAB as a fallback method. The explanations I found in the config-guides are very poor. Thank you for your help. Mathias