Solved

Oracle to_date function in Matlab

Posted on 2010-08-27
3
795 Views
Last Modified: 2016-03-02
Hello-- in TOAD when I write the following SQL code to insert a record into an Oracle database:

insert into ALG_IMP_SCHEDULE(TIME_PERIOD_KEY, SCHEDULE_DATE) values ('100',to_date('4/1/2012', 'm/d/yyyy'))

it works fine, but when I try to replicate this in Matlab with the code:

colnames = {'TIME_PERIOD_KEY','SCHEDULE_DATE'};
exdata = {'100','to_date(''4/1/2012'',''MM/DD/YYYY'')'};
insert(connALG, 'ALG_IMP_SCHEDULE', colnames, exdata);
cursor = exec(connALG, 'commit');

I get a Matlab error citing an Oracle error:
Error using ==> database.insert at 178
ORA-00917: missing comma

any idea why??

Thanks.
0
Comment
Question by:Jeff9687
  • 2
3 Comments
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 33543856
I've never heard of matlab...so I had to go looking (I was curious).

From the few minutes with Google and Matlabs homepage....it appears it 'should' work.

Just for grins to help troubleshoot try the following change:
exdata = {'100','sysdate'};


My guess is Matlab is interpreting the information as a 'string' and not a 'value' to pass off to Oracle to interpret.
0
 

Accepted Solution

by:
Jeff9687 earned 0 total points
ID: 33650547
Nevermind, I figured it out... if there's a way to do this with the Matlab insert function that incorporates the Oracle to_date function then I still don't know what it is, but I just worked around it by writing a query string and executing it:

sqls = ['insert into ALG_IMP_SCHEDULE(TIME_PERIOD_KEY, SCHEDULE_DATE) values (''', datestr('09/09/2010','yyyymmdd'), ''',  to_date(''','10/3/2011'',''mm/dd/yyyy''))'];
cursor = exec(connALG, sqls);
cursor2 = exec(connALG, 'commit');
0
 

Author Closing Comment

by:Jeff9687
ID: 33650555
Solved.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question