Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi guys..

I have written a query to insert a record in oracle but it gives me error
"Bind Variable not declared"


Query is :
SQL
insert into VISITOR_REG values ('Nilesh',8999890654,'caGloo','Project Meet','C10001','E00001','Ahmedabad',15-Mar-11 11:39:00 AM,'ASHUTOSH','','In')


The table description is :
<br />
Name                                      Null?    Type<br />
----------------------------------------- -------- -----------------<br />
VISITOR_NAME                                       VARCHAR2(30)<br />
MOBILE_NO                                          NUMBER(10)<br />
COMPANY                                            VARCHAR2(50)<br />
PURPOSE                                            VARCHAR2(50)<br />
DEPARTMENT                                         VARCHAR2(50)<br />
CONTACT_PERSON                                     VARCHAR2(20)<br />
CITY                                               VARCHAR2(30)<br />
VISIT_DATE                                         DATE<br />
ENTRY_PERSON                                       VARCHAR2(50)<br />
EXIT_PERSON                                        VARCHAR2(50)<br />
STATUS                                             VARCHAR2(10)<br />
<br />

Help me out...
Posted
Updated 14-Mar-11 20:29pm
v3

1 solution

Date you need to pass like this.
SQL
INSERT INTO X VALUES (TO_DATE('1998/05/31 12:00:00', 'YYYY/MM/DD HH24:MI:SS'));

The date format in which the date is stored may be different for a database. So we have to explicitly mention the format of the date/time when we are storing (to_date function with format string). The data will be stored in the format as specified at the database level.
 
Share this answer
 
v2
Comments
ashu2188 15-Mar-11 2:31am    
I am making this insert query in ASP.NET, c# and i have also used Convert.ToDateTime function for this still i am facing the problem.
I have connected my application with Oracle database and performing this insert statement.
Toniyo Jackson 15-Mar-11 2:33am    
Use single quotes for date
ashu2188 15-Mar-11 2:35am    
still getting error..."Date format picture ends before converting whole input string"
ashu2188 15-Mar-11 3:01am    
hey...got the reason why above error comes...it suggests that it converts the earlier part into the date format but with the time also coming with datetime in ASP.NET, it can not perform the insert statement as it can't convert the time into the date format...finding the solution for this now.
Toniyo Jackson 15-Mar-11 3:03am    
Good.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900