[unixODBC-support] isql won't accept multiple SQL statements in a single call ?

Maxim Veksler maxim.veksler at gmail.com
Mon Nov 10 11:13:59 GMT 2008


On Mon, Nov 10, 2008 at 11:18 AM, Martin Evans
<martin.evans at easysoft.com> wrote:
>
> Maxim Veksler wrote:
>>
>> Hello list,
>>
>> I'm trying to use isql in a "cat | isql" manner to populate our
>> database scheme, I'm failing to understand why the following does not
>> work.
>>
>> isql is called as follows : """cat mysql_files/config_scheme.sql |
>> isql -b myodbc5-ml ml dbAppPassword"""
>>
>> """cat mysql_files/config_scheme.sql
>>
>> -- MySQL dump 10.11
>> --
>> -- Host: localhost    Database: ml
>> -- ------------------------------------------------------
>> -- Server version       5.0.45-community-log
>>
>> /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
>> /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
>> /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
>> /*!40101 SET NAMES utf8 */;
>> /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
>> /*!40103 SET TIME_ZONE='+00:00' */;
>> /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
>> /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS,
>> FOREIGN_KEY_CHECKS=0 */;
>> /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
>> /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
>>
>>
>> --
>> -- Table structure for table `cfg_compo_module`
>> --
>>
>> DROP TABLE IF EXISTS `cfg_compo_module`;
>> CREATE TABLE `cfg_compo_module` (   `COMP_MODULE_ID` int(11) NOT NULL,
>>  `COMP_ID` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
>>
>> --
>> -- Table structure for table `cfg_components`
>> --
>>
>> DROP TABLE IF EXISTS `cfg_components`;
>> CREATE TABLE `cfg_components` (   `COMP_ID` int(11) NOT NULL,
>> `COMP_NAME` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT
>> CHARSET=utf8;
>> """ (more statements follow...)
>>
>>
>>
>> If I run each statement in the file separately, it works flawlessly,
>> but running them one after the other the script fails and no db
>> modifications are performed.
>> Please note that if I run the same script with mysql command line
>> utility the operation is successful.
>>
>> I would appreciate your help.
>>
>> Thank you,
>> Maxim.
>>
>
> I don't believe you can have empty lines in isql input as it uses that to indicate you are finished and will stop processing the rest of the file. You look to have empty lines.
>

I see, well thank you Martin.

I think that it could help if 2 issues that I've stumbled upon when
using isql would be documented is some kind of a FAQ.

The first is that all SQL statements must be in a single line, for
this awk script could prove to be handy:
""" awk '/^--|^$/ {print; next} !/;$/ {printf("%s ", $0); next} { print }' """

And the second is the issue with the empty lines.

> Martin
> --
> Martin J. Evans
> Easysoft Limited
> http://www.easysoft.com
> _______________________________________________
> unixODBC-support mailing list
> unixODBC-support at mailman.unixodbc.org
> http://mailman.unixodbc.org/mailman/listinfo/unixodbc-support



--
Cheers,
Maxim Veksler

"Free as in Freedom" - Do u GNU ?


More information about the unixODBC-support mailing list