From: Joseph Cohen on
Hello,
I tried to execute the following matlab command:

exec(conn,'SOURCE C:\\test.sql')

However, the resulting cursor reported that I had an error in my sql syntax. But when I ran the same SQL command from my mysql command line, it worked fine.

What Should I do?

Thanks!
From: Oleg Komarov on
"Joseph Cohen" <hypergrapes(a)hotmail.com> wrote in message <i12b60$bp0$1(a)fred.mathworks.com>...
> Hello,
> I tried to execute the following matlab command:
>
> exec(conn,'SOURCE C:\\test.sql')
>
> However, the resulting cursor reported that I had an error in my sql syntax. But when I ran the same SQL command from my mysql command line, it worked fine.
>
> What Should I do?
>
> Thanks!

The error may be caused by the content of c:\\test.sql rather than by the statement 'SOURCE C:\\test.sql' alone.
For example, when you connect to mySQL you may be chosing a db while the tables used inside test.sql are not referenced completely.

Post the error message, otherways it will be difficult to tell more precisely.

Oleg
From: Walter Roberson on
Joseph Cohen wrote:

> I tried to execute the following matlab command:
>
> exec(conn,'SOURCE C:\\test.sql')
>
> However, the resulting cursor reported that I had an error in my sql
> syntax. But when I ran the same SQL command from my mysql command line,
> it worked fine.
>
> What Should I do?

Try removing one of the \ in the string. I suspect the mysql command line
needs \\ to represent a single \ but that you only need \ by itself when using
exec().
From: Joseph Cohen on
Walter Roberson <roberson(a)hushmail.com> wrote in message <i12iev$3sd$2(a)canopus.cc.umanitoba.ca>...
> Joseph Cohen wrote:
>
> > I tried to execute the following matlab command:
> >
> > exec(conn,'SOURCE C:\\test.sql')
> >
> > However, the resulting cursor reported that I had an error in my sql
> > syntax. But when I ran the same SQL command from my mysql command line,
> > it worked fine.
> >
> > What Should I do?
>
> Try removing one of the \ in the string. I suspect the mysql command line
> needs \\ to represent a single \ but that you only need \ by itself when using
> exec().

No, I tried that and it didn't work. The full error message is as follows:

"You have an error in your SQL syntax near 'SOURCE C:\\test.sql' "

Any other suggestions?
From: Walter Roberson on
Joseph Cohen wrote:
> Walter Roberson <roberson(a)hushmail.com> wrote in message
> <i12iev$3sd$2(a)canopus.cc.umanitoba.ca>...
>> Joseph Cohen wrote:
>>
>> > I tried to execute the following matlab command:
>> > > exec(conn,'SOURCE C:\\test.sql')
>> > > However, the resulting cursor reported that I had an error in my
>> sql > syntax. But when I ran the same SQL command from my mysql
>> command line, > it worked fine.
>> > > What Should I do?
>>
>> Try removing one of the \ in the string. I suspect the mysql command
>> line needs \\ to represent a single \ but that you only need \ by
>> itself when using exec().
>
> No, I tried that and it didn't work. The full error message is as follows:
>
> "You have an error in your SQL syntax near 'SOURCE C:\\test.sql' "
>
> Any other suggestions?

If that is the error you get when you use

exec(conn,'SOURCE C:\test.sql')

then what is the error when you used your original

exec(conn,'SOURCE C:\\test.sql')

??


Or is the error *exactly* the same, character for character, when you use a
single \ or the double \\ ?


I think after that the next thing I would try would be

exec(conn,'SOURCE "C:\\test.sql"')