From: Oleg Komarov on
Walter Roberson <roberson(a)hushmail.com> wrote in message <i12tpj$l68$1(a)canopus.cc.umanitoba.ca>...
> 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"')

I know the solution:
http://markmail.org/message/2rtsgrlno7argd4v

"Not possible. The source command is implemented by the mysql command-line client, not the server itself. See http://www.mysql.com/doc/m/y/mysql.html "

Oleg
From: Joseph Cohen on
"Oleg Komarov" <oleg.komarovRemove.this(a)hotmail.it> wrote in message <i1448b$19g$1(a)fred.mathworks.com>...
> Walter Roberson <roberson(a)hushmail.com> wrote in message <i12tpj$l68$1(a)canopus.cc.umanitoba.ca>...
> > 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"')
>
> I know the solution:
> http://markmail.org/message/2rtsgrlno7argd4v
>
> "Not possible. The source command is implemented by the mysql command-line client, not the server itself. See http://www.mysql.com/doc/m/y/mysql.html "
>
> Oleg

Thanks Oleg,

Is there anyway I can get around this issue? I was hoping to avoid issuing too many command via the JBDC connection (cause its slow) and have mysql do most of the work through a .sql (this way I would just have to send the 'Source' command from matlab).
From: Oleg Komarov on
> > I know the solution:
> > http://markmail.org/message/2rtsgrlno7argd4v
> >
> > "Not possible. The source command is implemented by the mysql command-line client, not the server itself. See http://www.mysql.com/doc/m/y/mysql.html "
> >
> > Oleg
>
> Thanks Oleg,
>
> Is there anyway I can get around this issue? I was hoping to avoid issuing too many command via the JBDC connection (cause its slow) and have mysql do most of the work through a .sql (this way I would just have to send the 'Source' command from matlab).

You can use a stored procedure.
My personal experience is limited to a SP which returns a final SELECT preceeded by several DDL and DML operations.

Also, in MS SQL Server you have to suppress the messages which usually count the number of rows affected. I don't know if mySQL has the same behaviour, but leaving the messages on won't allow to retrieve the results in MATLAB.

Oleg