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
Solved

Oracle to_date function in Matlab

Posted on 2010-08-27
3
799 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can i Import Access Table Into Oracle Using Toad 36 213
use lov values 2 61
update statement in oracle 9 28
date show only hh:mm 2 25
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…
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.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

790 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