Home > Back-end >  Super stupid question about SQL
Super stupid question about SQL

Time:09-29

Delphi SQL statement

SQL:='select * from dw where DWMC=' + DWMC so write wrong
SQL:='select * from dw where DWMC=' "+ +" 'DWMC so not write

How to write

DWMC is a variable of type character database using SQL server2008

CodePudding user response:

SQL:='select * from dw where DWMC=' DWMC '+ +' ' ' '

CodePudding user response:

If you want to use single quotation marks between two single quotes, use two single quotes to represent a single quotation marks

CodePudding user response:

You can also use QuotedStr function

SQL:='select * from dw where DWMC=' + QuotedStr (DWMC);

CodePudding user response:

Literally, you are right, the second

As for the error, the program inside the breakpoints, enable SQL event tracker to see specific execution of SQL statements, copied to the query editor and see what is the problem

CodePudding user response:

Better write like this:
SQL:='select * from dw where DWMC=' + # 39 + DWMC + # 39

CodePudding user response:

The second sentence last a single quotation marks

CodePudding user response:

Express or change your code with parameter
SQL:='select * from dw where DWMC=' DWMC '+ +' "'

CodePudding user response:

One more quote
SQL:='select * from dw where DWMC=' '+ DWMC +' ' '

CodePudding user response:

SQL:='select * from dw where DWMC=' "+ +" '"' DWMC back without a single quotes,

CodePudding user response:

The building Lord thoroughly learn the use of the Delphi quotes,

CodePudding user response:

SQL:='select * from dw where DWMC=' + QuotedStr (DWMC); I am using this method, save trouble

CodePudding user response:

1. The two single quotes in single quotation marks in the Delphi said a single number
2. Use QuotedStr, they don't have to take into account the issue of quotation marks

CodePudding user response:

Variable name don't call SQLSTR is commonly used in SQL statement is
SQLSTR:='select * from dw where DWMC=' DWMC '+ +' "';

CodePudding user response:

It is best to use the format to write, so try to avoid count number '
SQLSTR:='select * from dw where DWMC=' DWMC '+ +' "';
Use the format is SQLSTR:=format (' select * from dw where DWMC=', '% s'' ', [DWMC]); % s is refers to the character, if the plastic is % d format (' select * from dw where DWMC=% d ', [DWMC]); , floating-point is % f format (' select * from dw where DWMC=% f ", [DWMC]);

CodePudding user response:

DELPHI grammar mistakes: first.
SQL:='select * from dw where DWMC=' + DWMC so write wrong
SQL:='select * from dw where DWMC=' "+ +" 'DWMC so not write

Correct grammar is: SQL:='select * from dw where DWMC=' + ' '+ DWMC +' ';
Or: SQL:='select * from dw where DWMC=' + QuotedStr (DWMC);

2. The grammar of the SQL SERVER 2008 problems
Whether the SQL SERVER 2008 field case problems (I have not studied the SQL SERVER 2008), but the oracle is case-sensitive, this you note that

If you have any exception prompt box screenshots, good judgment
  • Related