Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Oracle to_date function in Matlab

Posted on 2010-08-27
3
Medium Priority
?
834 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This article will show, step by step, how to integrate R code into a R Sweave document
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
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…

705 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