Solved

Oracle to_date function in Matlab

Posted on 2010-08-27
3
786 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)
Comment Utility
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
Comment Utility
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
Comment Utility
Solved.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video teaches viewers about errors in exception handling.
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.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now