Syntax error: SQL
INSERT INTO Apart1 (First Name, Last Name, MonthIN, DayIN, YearIN, MonthOUT, DayOUT, YearOUT, Notes) VALUES ( 'Google', 'Eyes', 12, 1, 2006, 12, 3, 2006, 'Test Data' )
Can anyone explan why that is giving me a SQL Sytax error?
Or 200 other things.
But in any case, you don't want to include spaces in column names. Also, I suggest using all upper case column names. For instance, if you use lowercase names in MySQL, and you then transfer those tables to Oracle, you'll have to explicitly tell Oracle that the columns can only be found if it looks for lowercase names. Did that make sense? In other words, DON'T USE LOWERCASE NAMES.
dailysun
Similar Messages
-
DB2 9.7 DFACT.SQL syntax error in Import ABAP phase - System Copy
Hi all. I'm trying a system copy with a source system SAP ECC 6.0 ehp4 based on NW 701 and db2 LUW 9.1 .
As it seems supported by SAP, i'm using db2 LUW 9.7 in target system.
O.S. is Windows 2008.
I got an error in phase "Import ABAP".
Sapinst.log says:
INFO 2010-02-18 10:12:14.337
An error occured and the user decided to retry the current step: "|NW_ABAP_OneHost|ind|ind|ind|ind|0|0|NW_Onehost_System|ind|ind|ind|ind|1|0|NW_CreateDBandLoad|ind|ind|ind|ind|10|0|NW_ABAP_Import_Dialog|ind|ind|ind|ind|5|0|NW_ABAP_Import|ind|ind|ind|ind|0|0|runMigrationMonitor".
INFO 2010-02-18 10:12:14.509
Switched to user: devadm.
INFO 2010-02-18 10:12:14.572
Creating file C:\Program Files\sapinst_instdir\ERPEhP4\LM\COPY\DB6\SYSTEM\CENTRAL\AS-ABAP\import_monitor.java.log.
INFO 2010-02-18 10:12:14.603
Switched to user: devadm.
INFO 2010-02-18 10:12:14.618
Working directory changed to C:\Program Files\sapinst_instdir\ERPEhP4\LM\COPY\DB6\SYSTEM\CENTRAL\AS-ABAP.
INFO 2010-02-18 10:12:14.618
Output of C:\j2sdk1.4.2_24-x64\bin\java.exe -classpath migmon.jar -showversion -Xmx1024m com.sap.inst.migmon.imp.ImportMonitor -sapinst is written to the logfile import_monitor.java.log.
WARNING 2010-02-18 10:12:44.790
Execution of the command "C:\j2sdk1.4.2_24-x64\bin\java.exe -classpath migmon.jar -showversion -Xmx1024m com.sap.inst.migmon.imp.ImportMonitor -sapinst" finished with return code 103. Output:
java version "1.4.2_24-rev"
Java(TM) Platform, Standard Edition for Business (build 1.4.2_24-rev-b06)
Java HotSpot(TM) 64-Bit Server VM (build 1.4.2_24-rev-b06, mixed mode)
Import Monitor jobs: running 1, waiting 1, completed 73, failed 0, total 75.
Loading of 'SAPDFACT' import package: ERROR
Import Monitor jobs: running 0, waiting 1, completed 73, failed 1, total 75.
WARNING[E] 2010-02-18 10:12:44.790
CJS-30022 Program 'Migration Monitor' exits with error code 103. For details see log file(s) import_monitor.java.log, import_monitor.log.
ERROR 2010-02-18 10:12:44.790
FCO-00011 The step runMigrationMonitor with step key |NW_ABAP_OneHost|ind|ind|ind|ind|0|0|NW_Onehost_System|ind|ind|ind|ind|1|0|NW_CreateDBandLoad|ind|ind|ind|ind|10|0|NW_ABAP_Import_Dialog|ind|ind|ind|ind|5|0|NW_ABAP_Import|ind|ind|ind|ind|0|0|runMigrationMonitor was executed with status ERROR .
Looking into import_monitor.java.log i found that the problem is in dfact import.
I've looked into sapdfact.log and i found:
S:\usr\sap\DEV\SYS\exe\uc\NTAMD64\R3load.exe: START OF LOG: 20100218105045
S:\usr\sap\DEV\SYS\exe\uc\NTAMD64\R3load.exe: sccsid @(#) $Id: //bas/701_REL/src/R3ld/R3load/R3ldmain.c#8 $ SAP
S:\usr\sap\DEV\SYS\exe\uc\NTAMD64\R3load.exe: version R7.01/V1.4 [UNICODE]
Compiled Jan 28 2010 20:22:25
S:\usr\sap\DEV\SYS\exe\uc\NTAMD64\R3load.exe -i SAPDFACT.cmd -dbcodepage 4103 -l SAPDFACT.log -stop_on_error -loadprocedure fast LOAD:COMPRESS_ALL
(DB) INFO: connected to DB
(DB6) INFO: COMPRESS YES is set during table creation.
(DB6) DB2 9.5 automatic dictionary creation does not require an explicit REORG.
(DB6) Compression threshold is ignored.
(GSI) INFO: dbname = "DEV "
(GSI) INFO: vname = "DB6 "
(GSI) INFO: hostname = "UNKNOWN "
(GSI) INFO: sysname = "Windows NT"
(GSI) INFO: nodename = "SRVSAPDEV"
(GSI) INFO: release = "6.0"
(GSI) INFO: version = "6002 Service Pack 2"
(GSI) INFO: machine = "4x AMD64 Level 6 (Mod 26 Step 5)"
(DB) ERROR: DDL statement failed with SQL error
( ALTER TABLE "/BI0/E0PPM_VC1" DROP PRIMARY KEY )
(SQL error -539)
error message returned by dsql:
SQL0539N Table or nickname "SAPDEV./BI0/E0PPM_VC1" does not have a "PRIMARY" key. SQLSTATE=42888
(IMP) INFO: a failed DROP attempt is not necessarily a problem
(DB6) INFO: executing DDL statements for object /BI0/E0PPM_VC1 from external SQL file.
(DB) ERROR: DDL statement failed with SQL error
( CREATE TYPE 2 UNIQUE INDEX "/BI0/E0PPM_VC1~0" ON "/BI0/E0PPM_VC1" ("KEY_0PPM_VC1T" , "KEY_0PPM_VC11" , "KEY_0PPM_VC1U" , "KEY_0PPM_VC1P" ) USING STOGROUP ___FAI PRIQTY 16 SECQTY 10240 FREEPAGE 0 PCTFREE 0 GBPCACHE CHANGED DEFINE NO BUFFERPOOL BP3 COPY NO PIECESIZE 2097152 K CLUSTER NOT PADDED )
(SQL error -7)
error message returned by dsql:
SQL0007N The character "_" following "" ) USING STOGROUP" is not valid. SQLSTATE=42601
(DB) INFO: disconnected from DB
S:\usr\sap\DEV\SYS\exe\uc\NTAMD64\R3load.exe: job finished with 1 error(s)
S:\usr\sap\DEV\SYS\exe\uc\NTAMD64\R3load.exe: END OF LOG: 20100218105045
So as you can see it seems that there's some syntax error in dfacl.log. The wrong SQL statement referred by sapdfact.log is
ind: /BI0/E0PPM_VC1~0
sql: CREATE TYPE 2 UNIQUE INDEX "/BI0/E0PPM_VC1~0" ON "/BI0/E0PPM_VC1"
("KEY_0PPM_VC1T" ,
"KEY_0PPM_VC11" ,
"KEY_0PPM_VC1U" ,
"KEY_0PPM_VC1P" )
USING STOGROUP ___FAI PRIQTY 16
SECQTY 10240 FREEPAGE 0 PCTFREE 0
GBPCACHE CHANGED DEFINE NO
BUFFERPOOL BP3 COPY NO
PIECESIZE 2097152 K CLUSTER NOT PADDED ;
|
ALTER TABLE "/BI0/E0PPM_VC1"
ADD PRIMARY KEY ("KEY_0PPM_VC1T",
"KEY_0PPM_VC11",
"KEY_0PPM_VC1U",
"KEY_0PPM_VC1P") ;
Am i missing something?
Data in referred tables (infocubes) isn't really important.
Is there a safe way to proceed?
Thanks in advance.
Regards
Simone ZaffalonAnd this is the strange point: my source system is not a BI and my dataclasses .SQL files are not empty.
Me too i would expect that the files should be empty but instead they are full of object definitions.
For example i have APPL0.SQL that contains a list of all tables of ECC system, for example
tab: MAMT
sql: CREATE TABLE "MAMT"
("MANDT" SAPDB6VARCHAR(000003)
DEFAULT '000' NOT NULL,
"MATNR" SAPDB6VARCHAR(000018)
DEFAULT ' ' NOT NULL,
"SPRAS" SAPDB6VARCHAR(000001)
DEFAULT ' ' NOT NULL,
"MEINH" SAPDB6VARCHAR(000003)
DEFAULT ' ' NOT NULL,
"MTXID" SAPDB6VARCHAR(000002)
DEFAULT ' ' NOT NULL,
"LFDNR" SAPDB6VARCHAR(000002)
DEFAULT '00' NOT NULL,
"MAKTM" SAPDB6VARCHAR(000040)
DEFAULT ' ' NOT NULL)
IN "&location&"
INDEX IN "&locationI&"
LONG IN "&locationL&"
COMPRESS YES;
ALTER TABLE "MAMT" LOCKSIZE ROW;
and like this for all others tables.
What would occur if i launch an import with such .SQL files?
(shuld i put this question to another thread or is fine for you to answer on this?)
Thank you again.
Simone Zaffalon -
Syntax error when creating a user-defined table type in SQL Server 2012
Why am I getting a syntax error when creating a user-defined table type in SQL Server 2014?
CREATE TYPE ReportsTableType AS TABLE
( reportId INT
, questionId INT
, questionOrder INT );
Results:
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'AS'.Hope these posts could help,
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/37a45a9a-ed8c-4655-be93-f6e6d5ef44be/getting-incorrect-syntax-while-creating-a-table-type-in-sql-server-2008-r2?forum=transactsql
Regards, Dineshkumar,
Please Mark as Answer if my post answers your question and
Vote as Helpful if it helps you -
MS SQL - Syntax error for valid query
I have a problem with the second query in this code (gives me
a syntax error in my HAVING line)
<cfquery name="getDupes" datasource="#application.ODBC1#"
dbtype="ODBC" username="#application.userNameODBC1#"
password="#application.userPassODBC1#">
SELECT *
FROM view_FormCount
WHERE formCount >= 2
ORDER BY formNum
</cfquery>
<cfset variables.lstForms = "">
<cfoutput query="getDupes">
<cfset variables.lstForms=
listAppend(variables.lstForms,"'#getDupes.formNum#'")>
</cfoutput>
<cfset variables.whereClause = "(formNum =
#ReplaceNoCase(variables.lstForms,',',' OR formNum =
','ALL')#)">
<cfquery name="getDetails"
datasource="#application.ODBC1#" dbtype="ODBC"
username="#application.userNameODBC1#"
password="#application.userPassODBC1#">
SELECT tblForms.formNum, tblForms.formName,
tblForms.formCustNum, tblCompanies.companyAbbr
FROM tblForms INNER JOIN tblCompanies ON tblForms.formCustNum
= tblCompanies.companyNum
GROUP BY tblForms.formNum, tblForms.formName,
tblForms.formCustNum, tblCompanies.companyAbbr
HAVING #variables.whereClause#
ORDER BY tblForms.formNum, tblForms.formCustNum
</cfquery>
Now, the really odd thing is if I just take the query text
out of the CFQUERY tags and use CFOUTPUT instead (to see in my
browser what query is getting executed) I get a query that I can
paste into Enterprise Mgr and runs fine.
I can even paste the resulting text into my code in a CFQUERY
and CF will run it fine.
In other words, the dynamic version query gives me an error,
but if I just output the SQL statement, copy-and-paste that into
the CFQUERY that's erroring out (replacing what's there) to run as
a static query, it works fine (sample of static query below).
The error I get when I try to do it dynamically is "Error
Executing Database Query. [Macromedia][SQLServer JDBC
Driver][SQLServer]Line 4: Incorrect syntax near '10169318'. The
error occurred on line 21." which is where the HAVING clause
starts.
SELECT tblForms.formNum, tblForms.formName,
tblForms.formCustNum, tblCompanies.companyAbbr FROM tblForms INNER
JOIN tblCompanies ON tblForms.formCustNum = tblCompanies.companyNum
GROUP BY tblForms.formNum, tblForms.formName, tblForms.formCustNum,
tblCompanies.companyAbbr HAVING (formNum = '10169318' OR formNum =
'1016CONCERTA' OR formNum = '1016NSAIDS' OR formNum =
'1016STRATTERA' OR formNum = '1016WELLBUTRIN' OR formNum =
'18504211' OR formNum = '185093807' OR formNum = '73208565' OR
formNum = '732120027' OR formNum = '7322154' OR formNum = '7323402'
OR formNum = '7323522' OR formNum = '73238900' OR formNum =
'7324211' OR formNum = '7324211S' OR formNum = '7324265' OR formNum
= '73242891' OR formNum = '732434341' OR formNum = '732434342' OR
formNum = '73243435' OR formNum = '73243436' OR formNum =
'73243439' OR formNum = '73243440' OR formNum = '73243441' OR
formNum = '73243442' OR formNum = '73243443' OR formNum = '7324359'
OR formNum = '7324360' OR formNum = '7324370' OR formNum =
'7324560' OR formNum = '7324959' OR formNum = '7326411ptreg' OR
formNum = '7326599' OR formNum = '7326600' OR formNum = '7326620'
OR formNum = '7326707' OR formNum = '7326931' OR formNum =
'7328410' OR formNum = '732851031TOP' OR formNum = '7328512' OR
formNum = '7328548' OR formNum = '7328548P2' OR formNum =
'7328548P3' OR formNum = '7328548P4' OR formNum = '73289400' OR
formNum = '73290D' OR formNum = '7329154' OR formNum =
'73291544JHS' OR formNum = '73291545JHS' OR formNum =
'73291546JHSMH' OR formNum = '73291547JHSMH' OR formNum = '7329174'
OR formNum = '7329308' OR formNum = '7329402' OR formNum =
'7329424' OR formNum = '7329455' OR formNum = '7329520' OR formNum
= '7329539' OR formNum = '73297701JH' OR formNum = '73298273' OR
formNum = '73298400' OR formNum = '73298403' OR formNum =
'73298404' OR formNum = '7329883' OR formNum = '73298860' OR
formNum = '7329887' OR formNum = '73298974' OR formNum = '7329899'
OR formNum = '7329899S' OR formNum = '73299190' OR formNum =
'7329987' OR formNum = '7329999PTO' OR formNum = '732AV5160' OR
formNum = '732CMHFRAZ' OR formNum = '732HIPAA' OR formNum =
'732HIPAAFLYERS' OR formNum = '734HEART' OR formNum = '7444711' OR
formNum = '7449230' OR formNum = '744HR4991' OR formNum =
'7538014MI' OR formNum = '77511044' OR formNum = '77511045' OR
formNum = '775stampnochange' OR formNum = '80851001BLUE' OR formNum
= '80MR4200' OR formNum = '80MR4273' OR formNum = '80MR4274' OR
formNum = '80MR4300' OR formNum = '80MR9934' OR formNum =
'80MR9935' OR formNum = '80SHC100' OR formNum = '80SHC4301' OR
formNum = '80SHC9830' OR formNum = '80SHC9832') ORDER BY
tblForms.formNum, tblForms.formCustNumAWFrueh1808 wrote:
> OK, that's simple enough. But then I'm really confused
as to why the query in
> my original post/example didn't work.
>
> The only single quotes in my #whereClause# variable were
wrapped around each
> varchar value in the WHERE clause (well, HAVING) as in
HAVING formNum = '12345'
> OR formNum = '54321'
>
> I never used a single quote within the value itself. And
yet
> preservesinglequotes fixed it. So what was CF doing? Why
did the single
> quotes still show up in the error msg - and in the right
place?
>
As I said the default behavior is to escape the quotes in
your variables
as data. So the default output of your SQL statement, before
preserveSingleQuotes() would be like this.
HAVING formNum = ''12345'' OR formNum = ''54321''
As you can see that is not the desired results in your case.
In your
case you have the proper number of single quotes in your
string and you
do not want any added. You want to preserve them so to say.
Thus
adding preserveSingleQuotes() around your whereClase
variable, i.e.
preserveSingleQuotes(whereClause) says do not add any quotes,
keep them
all single. -
No syntax errors in a sql query
Hello,
We are trying to eliminate Toad from our Standards. One of our people did a test for me to decided weather or not to go with SQL Developer. He compared TOAD with SQL Developer & SQL Plus. He intentially put select * ffrr table_name; to see if it would throw an error. TOAD gave an ORA-00923, SQL Plus gave the same, SQL Developer did not give anything but ran the sql. If I tell users to use this product and they are not exactly familiar with sql and they had syntax errors they wouldn't know if the sql ran properly or not.
Is there a work around. My company will not provide any more TOAD licenses. I'm trying to find a solution for helping our users do their job but get the right results. Any suggestions would be welcome. This product is still new to me. They bought the DBA's the licenses we need but came up short for the end users.
Thanks
CJWhen I try to run
select * ffrr dual;in SQL Developer 1.2.1 (3200), I get an alert box reporting an ORA-00923 error. Does this not happen on your machine? -
Use Of "#EC CI_EXECSQL in ABAP with EXEC SQL. Statement giving Syntax Error
Dear Gurus,
I have encountered an issue while trying to remove warning for using Native SQL statement using pseudo comment "#EC CI_EXECSQL
The thing is like this -- i have used follwing native sql command in abap.
EXEC SQL.
CONNECT TO 'SURROUND_DB'
ENDEXEC.
Now when i am checking this code in code inspector it is showing a warning with information below
CA CL_CI_TEST_CRITICAL_STATEMENTS0006
Code Inspector
Critical Statements
Use of Native SQL
Authorization checks cannot be appropriately run using EXEC SQL and should be carried out at program level.
The message can be hidden using the pseudo-comment "#EC CI_EXECSQL
Use of exceptin handling section for that warning showing me to use :
The message can be hidden using pseudo
comment "#EC CI_EXECSQL
Now when I am using "#EC CI_EXECSQL in the abap like below :
EXEC SQL. "#EC CI_EXECSQL
CONNECT TO 'SURROUND_DB'
ENDEXEC.
It is giving syntax error
The text literal ""#EC CI_EXECSQL " is longer than 255
characters.Check whether it ends correctly.
Please provide the guideline to resolve this issue.
Thanks & regards
Saifur Rahaman.Hi Saifur,
You can remove the warning using the following syntax:
EXEC "#EC CI_EXECSQL
SQL.
CONNECT TO 'SURROUND_DB'
ENDEXEC.
At least, it worked fine for me when using OPEN CURSOR, SELECT, FETCH and so on statements.
The way to use the pseudo comment is not very intuitive, but at least for my examples worked fine.
I hope this may help you.
Best regards,
Edgardo G. König -
MOF Syntax Error Installing SQL Server 2014 Express
I am trying to install SQL Server 2014 Express With Tools on a fully updated Win 8.1 system having already installed Visual Studio Community 2013 with Update 4. During the installation of SQL Server, I am getting a "MOF Syntax Error".
I found this http://support.microsoft.com/kb/2387686 on the web but I can't see that that applies to me as I would have thought that any suggested fixes from this article would have been already installed
or corrected in Win 8.1 or SQL Server 2014. Neither do I know what fix I should install anyway.
An entry on this forum suggested that running Winmgmt /salvagerepository command fixed the problem. I ran the command in the Command Prompt and a /verifyrepository said it was consistent. However, the error still occurred when I installed SQL Server.
Can anyone help with this?Hi wagham,
From your description, you encounter the error when installing SQL Server 2014 Express on Windows 8.1. For further analysis, please help to post the summary and detail logs which locate under
%ProgramFiles%\Microsoft SQL Server\120\Setup Bootstrap\Log. For more details about viewing SQL Server setup log files, you can refer to this
article.
Additionally, based on my research, “MOF Syntax Error” could be caused by various reasons, such as insufficient account permissions, corrupted .NET Framework and so on. There are some proposals for you installing SQL Server 2014 Express as follows.
1. Make sure that the account you use to install SQL Server has admin rights. If you are using a domain administrator, please ensure that it is added to local administrator group.
2. Make sure that you right-click the SQL Server setup file (setup.exe) and choose “Run as administrator” to complete the installation.
3. Check that if the .NET Framework is corrupted on your system. You can verify the installation state of the .NET Framework via the
.NET Framework Setup Verification Tool. If the .NET Framework is corrupted, please
repair it using
.NET Framework Repair Tool, then reinstall SQL Server.
Here is a similar blog about “MOF Syntax Error” for your reference.
http://sqlservertimes2.com/?p=641
Thanks,
Lydia Zhang -
SQL*Loader-350: Syntax error at line 5.
Hi ,iam new for using sql*loader, with minimum understanding from the forums,Iam trying to load data from a flat file (.dat) to oracle database.
here is my .dat file-------> data_file.dat
aaaa, mumbai
bbbb,kolkat
here is my .ctl fle ------->ctrl_file.ctl
load data
infile 'F:\oracle_utils_kiranorcl\KIR_ORA_DIR\emp_data.dat'
into table test
fields terminated by ","
( NAM varchar2(12),
PLACE varchar2(8)
here is db_tab_name structure
create table test (nam Varchar2(15),place Varchar2(10));
SQL> select * from test;
NAM PLACE
now.......
iam running the command on cmd window on os level
F:\app\NANDAN\product\11.2.0\dbhome_1>sqlldr userid=kiranmai/kiranmai@kiranorcl control=F:\oracle_utils_kiranorcl\KIR_ORA_DIR\emp_data.ctl log=F:\oracle_utils_kiranorcl\KIR_ORA_DIR\emp_data.log bad=F:\oracle_utils_kiranorcl\KIR_ORA_DIR\emp_data.bad
when i run this above command ,I get an error,
SQL*Loader-350: Syntax error at line 5.
Expecting "," or ")", found "varchar2".
( NAM varchar2(12),
^
I tried so many times by creating new ctl files further. But couldn't able get what is the wrong thing ????
Please help me ..
ThanksInstead of:
fields terminated by ","
( NAM varchar2(12),
PLACE varchar2(8)
try:
fields terminated by ","
( NAM char,
PLACE char -
Incorrect syntax errors in sql server function. Please help.
This is my sql server function:
create function dbo.CleanTheStringAdv (@theString nvar
char(500), @CleanMode as int)
returns nvarchar(500)
begin
--define variables
declare @strAlphaNumeric nvarchar(500)
declare @i int
declare @strChar nvarchar(500)
declare @CleanedString nvarchar(500)
--initiate values
set @CleanedString =''
set @theString = @theString + ''
SET @i = 1
--Determine if we are looking for numeric values only or numbers and letters
return case @CleanMode
WHEN 1
THEN @strAlphaNumeric = '0123456789'
WHEN 2
THEN @strAlphaNumeric = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
WHEN 3
THEN @strAlphaNumeric = '|0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
else 0
end
--Search through chars in the string passed to the function
while (@i <= Len(@theString))
begin
@strChar = substring(@theString, @i, 1)
If (charindex(@strAlphaNumeric, @strChar) <>0)
--if the current char being reviewed is valid then add it to the new string
begin
@CleanedString = @CleanedString + @strChar
end
end
return @CleanedString
and below are the syntax errors I see when I press F5:
Msg 102, Level 15, State 1, Procedure CleanTheStringAdv, Line 24
Incorrect syntax near '='.
Msg 102, Level 15, State 1, Procedure CleanTheStringAdv, Line 39
Incorrect syntax near '@strChar'.
Msg 102, Level 15, State 1, Procedure CleanTheStringAdv, Line 43
Incorrect syntax near '@CleanedString'.
Any help is highly appreciated.....Here is the full code for the function:
create function dbo.CleanTheStringAdv (@theString nvarchar(500), @CleanMode as int)
returns nvarchar(500)
as
begin
--define variables
declare @strAlphaNumeric nvarchar(500)
declare @i int
declare @strChar nvarchar(500)
declare @CleanedString nvarchar(500)
--initiate values
set @CleanedString =''
set @theString = @theString + ''
SET @i = 1
--Determine if we are looking for numeric values only or numbers and letters
SET @strAlphaNumeric = case @CleanMode
WHEN 1
THEN '0123456789'
WHEN 2
THEN '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
WHEN 3
THEN '|0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
else 0
end
--Search through chars in the string passed to the function
while (@i <= Len(@theString))
begin
set @strChar = substring(@theString, @i, 1);
If (charindex(@strAlphaNumeric, @strChar) <>0) --if the current char being reviewed is valid then add it to the new string
begin
SET @CleanedString = @CleanedString + @strChar;
end
END
return @CleanedString;
END -
[Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error
Hi , i am trying to execute siple SP using JDBC-ODBC Bridge Driver
Here my code :
String dsn="Tritek1";
String user="sa";
String password="imcindia";
Connection con1 = null;
CallableStatement cstmt = null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
con1=DriverManager.getConnection("jdbc:odbc:"+dsn,user,password);
Statement st=con1.createStatement();
st.execute("use dm0102d");
st.execute("setuser 'dm01012'");
cstmt = conObject.connection(" ?=Call dms_ex_get_folder_info(?,?,?)");
cstmt.setString(1,folderType);
cstmt.registerOutParameter(2,java.sql.Types.VARCHAR);
cstmt.registerOutParameter(3,java.sql.Types.VARCHAR); bFlag=cstmt.execute();
Here my SP :
Procedure Name : dms_ex_get_folder_info
Input Parameter(s) : a. folder_type char(20)
Return Parameter(s) : a. Recordset consist edit_mask and folder_type_code from folder_reference table / error
Procedure Type : select
Programmer : Prashanth Kumar M.
Creation Date : 12/20/2005 (20th Dec, 2005)
Tables Accessed : folder_reference
Revised :
Programmer: Date: Description:
Prashanth Kumar M. 12/21/2005 Modified the script as per the approved program specifications.
Test Query:
Declare @edit_mask char(15)
Declare @folder_type_code char(2)
execute dms_ex_get_folder_info 'Policy Folder',@edit_mask output,@folder_type_code output
Print 'Edit Mask : ' + @edit_mask
Print 'Folder Type Code : ' + @folder_type_code
CREATE PROCEDURE dms_ex_get_folder_info
@folder_type char(20),
@edit_mask char(15) output,
@folder_type_code char(2) output
AS
BEGIN
-- Check if the record for @folder_type exists or not.
BEGIN
-- return the record from folder_reference
SELECT
@edit_mask= IsNull(edit_mask,''),
@folder_type_code = IsNull(folder_type_code,'')
FROM folder_reference
WHERE
folder_decode = ltrim(rtrim(@folder_type))
-- return the error message
IF @@error <> 0
BEGIN
RAISERROR 100016 'Error in gettting the record from folder_reference table'
RETURN (@@error)
END
IF @edit_mask = '' AND @folder_type_code = ''
BEGIN
RAISERROR 100017 'No matching details in the folder_reference table'
RETURN (@@error)
END
END
END
GO
Here My Exception:
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLExecute(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(Unknown Source)
at com.nyl.dms.bl.Folder.createFolder(Folder.java:121)
at com.nyl.dms.bl.Folder.main(Folder.java:223)
Any one can help me to overcome this problem . Thanks in advance.
venkatHere's from one of those 10s of books.
Quoted from JDBC 3.0 by Bernard Van Haecke:
Stored procedures can return multiple result types because they can be composed of SQL statements that return diverse result types: resultsets and update counts (this includes special error codes).
Now this doesn't sound very satisfactory. So I use Sybase since I don't have any other database at the moment, and write a simple stored procedure.
CREATE proc testproc AS
BEGIN
-- My return code
return 7
END
goThen a sample patchy buggy code to play around:
import java.sql.*;
public class ProcTesting {
public static void main(String[] args) {
String connUrl = "jdbc:sybase:Tds:myserver:5150/dbinst";
String userName = "username";
String password = "password";
Connection con = null;
CallableStatement stmt = null;
ResultSet rs = null;
String sql = "{? = call testproc}";
try {
Class.forName("com.sybase.jdbc2.jdbc.SybDriver").newInstance();
con = DriverManager.getConnection(connUrl, userName, password);
stmt = con.prepareCall(sql);
stmt.registerOutParameter(1, Types.INTEGER);
stmt.execute();
System.out.println(stmt.getInt(1));
} catch(Exception e) {
e.printStackTrace();
} finally {
closeAll(con, stmt);
public static void closeAll(Connection con, Statement stmt) {
try {
con.close();
} catch(Exception e) { }
try {
stmt.close();
} catch(Exception e) { }
}Followed by:
javac ProcTesting.java
java -cp "%CLASSPATH%;C:\jarutils\jconn2.jar" ProcTesting
Output:
7
Didn't you know this could be done?
Happy new year, grandpa! -
Hi all,
I am able to INSERT and SELECT records from FoxPRo database successfully.
The driver is Sun JDBC-ODBC bridge
The DELETE statement throws no exception.
I've tried to execute PACK after the DELETE call and got following exception:
java.sql.SQLException: [Microsoft][ODBC Visual FoxPro Driver]File must be opened exclusively.So I tried USE MYTABLE EXCLUSIVE in a Statement before calling PACK and got the exception:
java.sql.SQLException: [Microsoft][ODBC Visual FoxPro Driver]Syntax error or access violationI've also tried inserting the USE MYTABLE EXCLUSIVE before calling DELETE but got the same exception above.
The ODBC DSN for MYTABLE is setup as:
- Free Tables (not database)
- Null (checked)
- Deleted (checked)
- Fetch data in background (checked)
I am not able to issue any of the following commands to FoxPro using java
OPEN - To open a table
CLOSE - To close a table
USE - To open a table for uer either in exclusive mode or shared mode
The exception being generated is :
java.sql.SQLException: [Microsoft][ODBC Visual FoxPro Driver]Syntax error or access violationThe help file of the Microsoft Visual Foxpro Driver states that the driver has support for the above commands.I a not able to get the way to issue the above commands to the driver using java.
In setting up the ODBC DSN I saw no "read only" setting.
In the Visual Foxpro table, I saw no READ ONLY settings.And also, there are no delete permission grants and there is no user database sesssion concept.
I've tried all of the above with DSN mapped to a database(NOT free tables) and setting AUTO-COMMIT OFF and AUTO-COMMIT ON.But in vain. The same exceptions as those stated above persisted.
Environment:
Microsoft Windows XP Professional
JDK version "1.4.2_09"
Microsoft Visual Foxpro 06.00.8167
Microsoft Visual Foxpro Driver 6.01.8629.01
Don't know what else to try.
Can anybody please help me.
Thanks in advance
Archanajava.sql.SQLException: [Microsoft][ODBC Visual FoxPro Driver]File must be opened exclusively.
In the Visual Foxpro table, I saw no READ ONLY settings.And also, there are
no delete permission grants and there is no user database sesssion concept.
The ODBC DSN for MYTABLE is setup as:
- Free Tables (not database)
- Null (checked)
- Deleted (checked)If you're using Visual Foxpro database(.DBC), you should see "Exclusive" option too. You can try check it, but I don't know whether your issue will disappear. -
Help! Syntax Error in SQL statement
Hello. I'm getting an error message and I'm just not seeing
where I went wrong. The SQL statement is:
updateSQL = "UPDATE TrainingHistory SET Status='" &
fFormat(Request.Form(cStatus)) & "', StatusComments='" &
fFormat(Request.Form(cStatusComments)) & " WHERE Training_ID="
& fFormat(Request.Form(cTrainingID))
The error message is:
[Microsoft][ODBC Microsoft Access Driver] Syntax error in
string in query expression '' WHERE Training_ID=9054'.
I've been looking at it for a while. Not sure where I went
wrong. Here is a more complete version of the code:
<%
Function fFormat(vText)
fFormat = Replace(vText, "'", "''")
End Function
Sub sRunSQL(vSQL)
set cExecute = Server.CreateObject("ADODB.Command")
With cExecute
.ActiveConnection = MM_coldsuncrea_lms_STRING
.CommandText = vSQL
.CommandType = 1
.CommandTimeout = 0
.Prepared = true
.Execute()
End With
End Sub
If Request.Form("action")="update" Then
'Set variables for update
Dim updateSQL, i
Dim cTrainingID, cStatus, cStatusComments
'Loop through records on screen and update
For i = 1 To fFormat(Request.Form("counter"))
'Create the proper field names to reference on the form
cTrainingID = "Training_ID" & CStr(i)
cStatus = "Status" & CStr(i)
cStatusComments = "StatusComments" & CStr(i)
'Create the update sql statement
updateSQL = "UPDATE TrainingHistory SET Status='" &
fFormat(Request.Form(cStatus)) & "', StatusComments='" &
fFormat(Request.Form(cStatusComments)) & " WHERE Training_ID="
& fFormat(Request.Form(cTrainingID))
'Run the sql statement
Call sRunSQL(updateSQL)
Next
'Refresh page
Response.Redirect("ClassUpdateRoster.asp?Training_ID=") &
(rsClassDetails.Fields.Item("event_ID").Value)
End If
%>You need another single quote after the double quote before
the WHERE clause. You are not closing the single quote you used to
delimit the value for StatusComments. -
Second call of an SQL query throws a syntax error?
Private Sub RefreshDataSet()
Dim strSQL As String = DataAdapter1.SelectCommand.CommandText
Try
DataSet1.Clear()
DataAdapter1.SelectCommand.CommandText() = Trim(strSQL & " WHERE BadgeID = " & strEmployeeBadge)
DataAdapter1.Fill(DataSet1)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
When I call the above procedure, the sub does work correctly and I get the expected results / records in the dataset. But, when I call the Sub again (to refresh the dataset) it gives me an "incorrect syntax" error.
I'm not sure why it is doing this. Any suggestions or ideas?Youjun,
It's very frustrating when you keep asking if the code is the same, or if I have tested the code. I've said that I debugged.. I've said I have tested the code. Your continuing to ask me this is pointless, rude, and only serves to make YOU look
stupid. I'm sorry if that is rude, but please stop asking me!
To respond:
I supposed that the original DataAdapter1.SelectCommand.CommandText is "select * from table1"
-Yes, the base command is similar to this, except that I call each database field, not using the *.
1) When you run it the first time, the DataAdapter1.SelectCommand.CommandText will be "select * from table1 WHERE BadgeID ='123'".
-Yes, I append 'WHERE BadgeID = XXX' to the query, the first and
each subsequent time. Again, I said that the code/call/syntax DOES NOT CHANGE. It is the
same every time.
2) Then you changed the strEmployeeBadge, I supposed that is '234'
-NO! I do NOT change the code!! I'm sorry, but what part of 'the query is
exactly the same' is unclear?
3) when you run it next time, the DataAdapter1.SelectCommand.CommandText will change to "select * from table1 WHERE BadgeID ='123'
WHERE BadgeID = '234'"
-NO! I have specifically tested for this
and as stated, the SQL syntax does not change!
So it 'syntax' fail will pop out when second call.
-NO, your assumptions are INCORRECT.
I suggest you recording the commandText when first change the DataAdapter1.
I write a testing program for you.
-Your 'testing program' is for all purposes, the same exact code as what I used. There is no difference.
Now, as also stated before, I have several other instances
where I use the same 'technique' to amend the base SQL queries of the DataAdapter. Each of these other instances work fine, and I use them to 'refresh' my DataSet information several times throughout the running of my program. Just for some
reason, this time, it does not work. I don't know why and was hoping someone else had found the same/similar issue and also found a resolution. The DataAdapter is configured the same as the others, the code is the same as well. I will just
have to find a work around, or other way to do what I want I guess.
Lastly, yes, I set strSQL in the subroutine because I want that variable to be gone at the end of the procedure. It recalls, then sets the syntax, every time the Sub is called on purpose. I do not want strSQL to be 'global', which by the way,
according to Microsoft documentation I have read, is no longer possible. Global variables are 'technically' not used/recognized anymore. If this has changed, then I stand corrected.
Thank you for responding, I will just find another solution I guess. -
T-SQL Code to backup database with multiple files - Syntax error
Hello,
I'm trying to backup a database into multiple files but I'm getting a syntax error.
Here is the code:
declare @DBName varchar(100)
declare @DBFileName varchar(256)
declare @FolderName varchar(256)
declare @Path varchar(100)
set @Path = '\\Backup-Server\Test\'
set @DBName = 'DayNite'
set @DBFileName = 'DayNite-Full' + '-' + (SELECT CONVERT(char(10), GetDate(),110)) + '-' + 'P'
set @FolderName =(SELECT CONVERT(char(10), GetDate(),110))
set @Path = @Path + @FolderName + '\'
EXEC master.dbo.xp_create_subdir @Path
--Calculate broken files for BACKUP DATBASE Function
/*declare @dbsize int
set @dbsize = (SELECT ((size*8)/1024)/1000 as SizeGB FROM sys.database_files WHERE file_id = '1')
set @dbsize = @dbsize / 4
print @dbsize*/
EXEC
BACKUP DATABASE [test] TO
DISK = @Path + @DBFileName + '1.bak',
DISK = @Path + @DBFileName + '2.bak',
DISK = @Path + @DBFileName + '3.bak',
DISK = @Path + @DBFileName + '4.bak',
DISK = @Path + @DBFileName + '5.bak',
DISK = @Path + @DBFileName + '6.bak',
DISK = @Path + @DBFileName + '7.bak',
DISK = @Path + @DBFileName + '8.bak',
DISK = @Path + @DBFileName + '9.bak',
DISK = @Path + @DBFileName + '10.bak',
DISK = @Path + @DBFileName + '11.bak',
DISK = @Path + @DBFileName + '12.bak',
DISK = @Path + @DBFileName + '13.bak'
WITH INIT , NOUNLOAD , NAME = 'DayNite Full Backup', NOSKIP , NOFORMATMade some slight modifications to your script and it should work(worked when tested).. if you wnat more complete solution -- google -OLA Hallengren backups -- you should get some good scripts..
declare @DBName varchar(100)
declare @DBFileName varchar(256)
declare @FolderName varchar(256)
declare @Path varchar(100)
set @Path = '\\Backup-Server\Test\'
set @DBName = 'DayNite'
set @DBFileName = 'DayNite-Full' +''+ '-' +''+ (SELECT CONVERT(char(10), GetDate(),110)) +''+ '-' +''+ 'P'
set @FolderName =(SELECT CONVERT(char(10), GetDate(),110))
set @Path = @Path +''+ @FolderName +''+ '\'
EXEC master.dbo.xp_create_subdir @Path
--Calculate broken files for BACKUP DATBASE Function
/*declare @dbsize int
set @dbsize = (SELECT ((size*8)/1024)/1000 as SizeGB FROM sys.database_files WHERE file_id = '1')
set @dbsize = @dbsize / 4
print @dbsize*/
select @Path,@DbFileName
declare @SQL nvarchar(2000)
Set @SQL ='Backup DATABASE [DAYNITE] TO DISK = '''+@Path +''+ @DBFileName +''+ '1.bak'',
DISK = '''+@Path +''+ @DBFileName +''+ '2.bak'',
DISK = '''+@Path +''+ @DBFileName +''+ '3.bak'',
DISK = '''+@Path +''+ @DBFileName +''+ '4.bak'',
DISK = '''+@Path +''+ @DBFileName +''+ '5.bak'',
DISK = '''+@Path +''+ @DBFileName +''+ '6.bak'',
DISK = '''+@Path +''+ @DBFileName +''+ '7.bak'',
DISK = '''+@Path +''+ @DBFileName +''+ '8.bak'',
DISK = '''+@Path +''+ @DBFileName +''+ '9.bak'',
DISK = '''+@Path +''+ @DBFileName +''+ '10.bak'',
DISK = '''+@Path +''+ @DBFileName +''+ '11.bak'',
DISK = '''+@Path +''+ @DBFileName +''+ '12.bak'',
DISK = '''+@Path +''+ @DBFileName +''+ '13.bak''
WITH INIT , NOUNLOAD , NAME = ''DayNite Full Backup'', NOSKIP , NOFORMAT '
print @SQL
exec (@SQL)
Hope it Helps!! -
After updating our ODBC driver to match our current Unidata database version (7.1), we now get the following message from Crystal Reports 2011 on many of our existing reports:
"Failed to retrieve data from the database. Details: 37000:[Rocket U2][U2ODBC][1401249]Error ID: 21 Severity: ERROR Facility: DBCAPERR - SQL Syntax error. [Database Vendor Code: 5365440]
The generated SQL statement follows:
SELECT "INVCDETH_NF"."ITEM_NBR", "ITEMMAST_NF"."ITEM_DESC", "INVCDETH_NF"."SHIPPED_QUANTITY", "INVCDETH_NF"."Z_INV_DATE", "INVCDETH_NF"."Z_COMPANY", "INVCHDRH_NF"."INVOICE_TYPE", "INVCDETH_NF"."EXTENDED_PRICE", "INVCDETH_NF"."COST_OF_SALES", "INVCDETH_NF"."Z_PCC_CODE", "INVCDETH_NF"."DISCOUNT_AMOUNT", "INVCDETH_NF"."WAREHOUSE", "ITEMMAST_NF"."PRICE_CODE", "INVCHDRH_NF"."INVOICE_NBR", "INVCHDRH_NF"."REFERENCE_NBR"
FROM ("Administrators"."ITEMMAST_NF" "ITEMMAST_NF" INNER JOIN "Administrators"."INVCDETH_NF" "INVCDETH_NF" ON "ITEMMAST_NF"."ITEM_NBR"="INVCDETH_NF"."ITEM_NBR") INNER JOIN "Administrators"."INVCHDRH_NF" "INVCHDRH_NF" ON ((("INVCDETH_NF"."INVOICE_NBR"="INVCHDRH_NF"."INVOICE_NBR") AND ("INVCDETH_NF"."INV_HEADER_ID"="INVCHDRH_NF"."INV_HEADER_ID")) AND ("INVCDETH_NF"."REFERENCE_NBR"="INVCHDRH_NF"."REFERENCE_NBR")) AND ("INVCDETH_NF"."RELEASE_NBR"="INVCHDRH_NF"."RELEASE_NBR")
WHERE "INVCDETH_NF"."Z_COMPANY"='01' AND "INVCDETH_NF"."WAREHOUSE"='086' AND ("INVCDETH_NF"."Z_INV_DATE">={d '2013-12-08'} AND "INVCDETH_NF"."Z_INV_DATE"<={d '2013-12-26'})
ORDER BY "INVCDETH_NF"."WAREHOUSE"
I downloaded the trial version of CR2013 and get the same result. Can anyone shed any light? Thanks!Yes, in that the query is what Crystal generated from the report being built in the designer. I simply copied it from the Database > Show SQL Query screen. Since the error I'm receiving is a SQL Syntax Error, I thought it would be appropriate to show it.
The bottom line is that because I am not very knowledgeable in SQL, I can't look at the query and identify the error. However, I am responsible for supporting CR in-house. Naturally, I have reported this to Rocket (the makers of the ODBC driver) but haven't received their reply yet.
Maybe you are looking for
-
How to access components in a iview from program
Hi, Can we access the iview components from program dynamically? I have a Table Control , i want to refresh it in my program. How to set Mandatory (*) mark for a label? Is there any property for that? Thanks, Sridhar
-
More than 1 record by line in reports
Hello everybody. Can anybody tell me How I can display more than 1 record in same line of a report? Thanks in advanced. Regards everybody.
-
Loading multiple data from a XML file?
Hi, I'm having trouble loading multiple data from the same XML file. In this XML file I have a list of dishes I want to add into a menu. So, how can I load multiple data from different branches of the XML file into my text fields? Thanks in advance,
-
Need order form guidance / tutorial
I have been creating various php pages to submit detail to my database but I have come up against something that is more complicated. I would like to do more with a file orderform.php that is processed by and displays on processorder.php. When the us
-
IPad compatible with OS X 10.4.11?
Just bought an iPad, and cannot synch w/ my itunes on my PowerPC 10.4.11. Understand I need to upgrade to 10.5 so it is compatible with the iPad, but not sure where to find a software upgrade, or if this is even possible? Don't want to bring back the