-1

I'm facing a problem while validating a csv file. I'm using the csvJdbc api for validating csv. But in CSV, there is a header which contains the '>' sign. When I try to use that header for validation, it throws an exception. Is there any way to use that ,like some escape character? This is the query I'm trying to run:

SELECT *  FROM Temp_ where  SIDE_A_IVD_BIN12(>60)>=0

 SIDE_A_IVD_BIN10(50)    SIDE_A_IVD_BIN11(60)    SIDE_A_IVD_BIN12(>60)      
           0                         0                  0
           0                         0                  0
           0                         0                  0
           0                         0                  0

2 Answers2

1

Have you tried adding braces around the query?

CREATE TABLE Temp_ (
    [SIDE_A_IVD_BIN12(>60)] int
)

INSERT INTO Temp_ VALUES (-1)
INSERT INTO Temp_ VALUES (0)
INSERT INTO Temp_ VALUES (1)

SELECT * FROM Temp_ WHERE [SIDE_A_IVD_BIN12(>60)] >= 0
NeedHack
  • 2,943
  • 3
  • 30
  • 44
tpither
  • 256
  • 1
  • 11
  • ...assuming SQL Server, which to be fair is usually what people mean when they don't specify the SQL database. – NeedHack Nov 28 '14 at 10:48
  • How do you know Surinder is using SQL Server? –  Nov 28 '14 at 11:00
  • The [CsvJdbc documentation](http://csvjdbc.sourceforge.net/doc.html) says: "Use double quotes around table names or column names containing spaces or other special characters." – Gord Thompson Nov 28 '14 at 12:55
0

You didn't specify your DBMS, but in standard SQL (and nearly all DBMS) identifiers that contain special characters need to be enclosed in double quotes:

SELECT *  
FROM Temp_ 
where  "SIDE_A_IVD_BIN12(>60)" >= 0;

Edit (after realizing that the "DBMS" is CsvJdbc):

The CsvJdbc manual (thanks @Gord for the link) also states that it's using the SQL standard syntax for quoting identifiers that contain special characters.

The above syntax works for me:

enter image description here

But I could not get CsvJdbc to treat the numbers as numbers, that's why I used = '1'

  • @SurinderRajpal This answer is correct. The [CsvJdbc documentation](http://csvjdbc.sourceforge.net/doc.html) says: "Use double quotes around table names or column names containing spaces or other special characters." I just tested it with `csvjdbc-1.0-21.jar` and it does work. – Gord Thompson Nov 28 '14 at 12:53