Popular Posts

Sunday, 25 August 2013

ERROR WHILE RETRIVING COLUMNS FROM DATABASE(SELECT QUERY)

YES SOmetimes the simple looking retrival becomes so headache that you douth your capabilities.The simple retrival of the data from database WITH SELECT QUERY.


Lets see the simple example and look into the matteR:



SAY a TABLE is created with name seismic_details .It contains the information of the area and time where earth quack occurs.

desc seismic_details   //describe the database table
Name             Null Type          
---------------- ---- ------------- 
SI_NO                 NUMBER(5)     
DATES                 VARCHAR2(25)  
Time(IST)             VARCHAR2(25)  
EPICENTER_REGION      VARCHAR2(100) 
LAT(North)            FLOAT(126)    
LONG(East)            FLOAT(126)    
MAGNITUDE             FLOAT(126) 

NOW when you name the table name or the column name with special character in it i.e(contains (,)-@) etc then the name has to be retrieved via putting in DOUBLES QUOTES"".

i.e NOW your retrival query will becomes:
  SELECT SI_NO,
  DATES,
  "Time(IST)",
  EPICENTER_REGION,
 "LAT(North)",
  "LONG(East)",
  MAGNITUDE 
FROM SEISMIC_DETAILS ;



THE CODE BEHIND:

If you are not getting query result due to column names then fire like this:

 


 strSql = "select DATES," + '"' + "Time(IST)" + '"' + " ,EPICENTER_REGION,"+'"'+"LAT(North)"+'"'+","+'"'+"LONG(East)"+'"'+",MAGNITUDE FROM seismic_details "




Yes their are more and more ways....it depends on you...just chose the one that works for U.

SO ENJOY.........................................................

No comments :

Post a Comment