Solved

Oracle to_date function in Matlab

Posted on 2010-08-27
3
821 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 77

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

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…
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

626 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