Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

How to import SQL script into another

6 posts in General Discussion Last posting was on 2011-01-07 03:49:32.0Z
Surya Posted on 2011-01-06 03:56:30.0Z
Sender: 6e7a.4d253cf1.1804289383@sybase.com
From: Surya
Newsgroups: sybase.public.ase.general
Subject: How to import SQL script into another
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4d253d6e.6ecb.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 5 Jan 2011 19:56:30 -0800
X-Trace: forums-1-dub 1294286190 10.22.241.41 (5 Jan 2011 19:56:30 -0800)
X-Original-Trace: 5 Jan 2011 19:56:30 -0800, 10.22.241.41
Lines: 9
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:29843
Article PK: 79072

Hi folks,

I have a lot of scripts. I want one main script and import
other scripts into it and load with isql.

Please give me a example how to import script into another.

Thanks
Surya


Mark Posted on 2011-01-06 12:53:50.0Z
From: Mark <mlibner@yahoo.com>
Reply-To: mlibner@yahoo.com
Organization: Security Finance
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: How to import SQL script into another
References: <4d253d6e.6ecb.1681692777@sybase.com>
In-Reply-To: <4d253d6e.6ecb.1681692777@sybase.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4d25bb5e@forums-1-dub>
Date: 6 Jan 2011 04:53:50 -0800
X-Trace: forums-1-dub 1294318430 10.22.241.152 (6 Jan 2011 04:53:50 -0800)
X-Original-Trace: 6 Jan 2011 04:53:50 -0800, vip152.sybase.com
Lines: 19
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:29846
Article PK: 79074

Hi Surya,

We use the DOS copy command to combine all our scripts into one like the
example below...
copy *.* all_my_scripts.sql

hth,
Mark

On 1/5/2011 10:56 PM, Surya wrote:
> Hi folks,
>
> I have a lot of scripts. I want one main script and import
> other scripts into it and load with isql.
>
> Please give me a example how to import script into another.
>
> Thanks
> Surya


"Mark A. Parsons" <iron_horse Posted on 2011-01-06 20:15:53.0Z
From: "Mark A. Parsons" <iron_horse@no_spamola.compuserve.com>
User-Agent: Thunderbird 1.5.0.10 (Windows/20070221)
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: How to import SQL script into another
References: <4d253d6e.6ecb.1681692777@sybase.com>
In-Reply-To: <4d253d6e.6ecb.1681692777@sybase.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4d2622f9$1@forums-1-dub>
Date: 6 Jan 2011 12:15:53 -0800
X-Trace: forums-1-dub 1294344953 10.22.241.152 (6 Jan 2011 12:15:53 -0800)
X-Original-Trace: 6 Jan 2011 12:15:53 -0800, vip152.sybase.com
Lines: 69
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:29847
Article PK: 79075

You'll need to be a lot more specific ... OS (windows? unix/linux?) ... type of 'scripts' (OS/shell scripts? SQL
scripts? something else?) ... at what point are you trying to import your scripts and into what? (loading into an isql
session? pulling from a stored proc/batch that's already been forwarded to the dataserver? something else?)

In the meantime ... assuming unix/linux command line access, using isql, and access to a SQL script called test.sql, the
following works for me:

=====================
$ cat test.sql
select @@servername,
getdate(),
"hi, I'm a SQL script",
@@trancount,
@@spid

$ isql -SCC1 -Usa -P
1> :r test.sql
7> go <-- notice the jump in line numbers

------------------------------ -------------------------- -------------------- ----------- ------
CC1 Jan 6 2011 3:09PM hi, I'm a SQL script 0 26

(1 row affected)

1> exit

$ isql -v

Sybase CTISQL Utility/15.0/P-EBF16299 ESD #16/PC Intel/BUILD1500-112/OPT/Sun Oct 12 23:01:12 2008
... snip ...
=====================

This feature could be used in a shell script, eg:

=====================
$ cat test.ksh

#!/bin/ksh

DSQUERY=CC1
SYBUSER=sa
SYBPWD=
myscript=test.sql

isql -S${DSQUERY} -U${SYBUSER} -P${SYBPWD} -w1000 <<-EOF
:r ${myscript}
go
EOF

$ test.ksh

------------------------------ -------------------------- -------------------- ----------- ------
CC1 Jan 6 2011 3:14PM hi, I'm a SQL script 0 37

(1 row affected)
=====================

Surya wrote:
> Hi folks,
>
> I have a lot of scripts. I want one main script and import
> other scripts into it and load with isql.
>
> Please give me a example how to import script into another.
>
> Thanks
> Surya


Michael Peppler [Team Sybase] Posted on 2011-01-06 05:54:12.0Z
From: "Michael Peppler [Team Sybase]" <mpeppler@peppler.org>
Organization: Peppler Consulting SARL
Subject: Re: How to import SQL script into another
User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.)
Message-ID: <pan.2011.01.06.05.54.12.238020@peppler.org>
Newsgroups: sybase.public.ase.general
References: <4d253d6e.6ecb.1681692777@sybase.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Date: 5 Jan 2011 21:54:12 -0800
X-Trace: forums-1-dub 1294293252 10.22.241.152 (5 Jan 2011 21:54:12 -0800)
X-Original-Trace: 5 Jan 2011 21:54:12 -0800, vip152.sybase.com
Lines: 17
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:29844
Article PK: 79076


On Wed, 05 Jan 2011 19:56:30 -0800, Surya wrote:

> Hi folks,
>
> I have a lot of scripts. I want one main script and import other scripts
> into it and load with isql.
>
> Please give me a example how to import script into another.

isql doesn't support that sort of thing.
You'd have to build some sort of external "merge" tool (in perl, VB, etc)
that would parse and interpret your "import" directives and generate the
complete SQL script before feeding it to isql.

Michael


Cory Sane [TeamSybase] Posted on 2011-01-07 03:49:32.0Z
From: "Cory Sane [TeamSybase]" <cory!=sane>
Newsgroups: sybase.public.ase.general
References: <4d253d6e.6ecb.1681692777@sybase.com>
In-Reply-To: <4d253d6e.6ecb.1681692777@sybase.com>
Subject: Re: How to import SQL script into another
Lines: 22
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Windows Mail 6.0.6002.18197
X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6002.18263
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4d268d4c$1@forums-1-dub>
Date: 6 Jan 2011 19:49:32 -0800
X-Trace: forums-1-dub 1294372172 10.22.241.152 (6 Jan 2011 19:49:32 -0800)
X-Original-Trace: 6 Jan 2011 19:49:32 -0800, vip152.sybase.com
X-Authenticated-User: TeamSybase
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:29848
Article PK: 79081

in unix... i'll ocationally do the following to handle multiple scripts...

for i in `ls *.sql`
do echo $i; isql -U -P-S -i $i -o $i.out;done

The -i is the inputfile and -o is the outputfile.


--
Cory Sane
[TeamSybase]
Certified Sybase Associate DBA for ASE 15.0

"Surya" wrote in message news:4d253d6e.6ecb.1681692777@sybase.com...
> Hi folks,
>
> I have a lot of scripts. I want one main script and import
> other scripts into it and load with isql.
>
> Please give me a example how to import script into another.
>
> Thanks
> Surya