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.

Declaring and Using Variables

5 posts in Windows NT Last posting was on 2001-01-31 20:54:28.0Z
Wes Barrett Posted on 2001-01-29 20:31:30.0Z
Message-ID: <3A75D322.3EC11CEC@pop200.gsfc.nasa.gov>
Date: Mon, 29 Jan 2001 15:31:30 -0500
From: Wes Barrett <wbarrett@pop200.gsfc.nasa.gov>
Organization: NASA/Goddard Space Flight Cente
X-Mailer: Mozilla 4.5 [en] (WinNT; U)
X-Accept-Language: en
MIME-Version: 1.0
Subject: Declaring and Using Variables
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.sqlserver.nt
Lines: 12
NNTP-Posting-Host: ecn1951527.gsfc.nasa.gov 128.183.74.35
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.sqlserver.nt:1274
Article PK: 1088741

Can anyone tell me how to declare variables in a NT batch file. I am
setting up my dbscripts for our daily db routines. My batch file calls
a SQL script file. When it executes I get syntax error near the "=" and
also when I try to reference the variable I get the message '$' is an
invalid money amount.

Ex.
DBNAME="mydb"
sp_helpdb $DBNAME

These variables work in the Unix world. Is it possible to duplicate in
the NT world.

Thanks,


sverre Posted on 2001-01-30 08:52:56.0Z
From: "sverre" <stvedt@mds.nordion.com>
References: <3A75D322.3EC11CEC@pop200.gsfc.nasa.gov>
Subject: Re: Declaring and Using Variables
Date: Tue, 30 Jan 2001 09:52:56 +0100
Lines: 33
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6600
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
Message-ID: <gVtRxtpiAHA.305@forums.sybase.com>
Newsgroups: sybase.public.sqlserver.nt
NNTP-Posting-Host: 193.214.127.151
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.sqlserver.nt:1272
Article PK: 1088743

rem --- declaration:
SET DBNAME=mydb
rem .. remember to avoid blanks in front of and after the '=' sign, i.e do
not write SET DBNAME = <something>
...
rem --- usage:
sp_helpdb %DBNAME%

rem --- remove the variable:
SET DBNAME=

/sverre

"Wes Barrett" <wbarrett@pop200.gsfc.nasa.gov> wrote in message
news:3A75D322.3EC11CEC@pop200.gsfc.nasa.gov...
> Can anyone tell me how to declare variables in a NT batch file. I am
> setting up my dbscripts for our daily db routines. My batch file calls
> a SQL script file. When it executes I get syntax error near the "=" and
> also when I try to reference the variable I get the message '$' is an
> invalid money amount.
>
> Ex.
> DBNAME="mydb"
> sp_helpdb $DBNAME
>
> These variables work in the Unix world. Is it possible to duplicate in
> the NT world.
>
> Thanks,
>


Wes Barrett Posted on 2001-01-30 13:51:53.0Z
Message-ID: <3A76C6F8.D81DC2B7@pop200.gsfc.nasa.gov>
Date: Tue, 30 Jan 2001 08:51:53 -0500
From: Wes Barrett <wbarrett@pop200.gsfc.nasa.gov>
Organization: NASA/Goddard Space Flight Cente
X-Mailer: Mozilla 4.5 [en] (WinNT; U)
X-Accept-Language: en
MIME-Version: 1.0
Subject: Re: Declaring and Using Variables
References: <3A75D322.3EC11CEC@pop200.gsfc.nasa.gov> <gVtRxtpiAHA.305@forums.sybase.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.sqlserver.nt
Lines: 35
NNTP-Posting-Host: ecn1951527.gsfc.nasa.gov 128.183.74.35
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.sqlserver.nt:1270
Article PK: 1088735

Good morning sverre, I tried this Set command yesterday as again this morning.
Here is the bat file calling the SQL. It is very simple:

isql -Usa -Pxxxxxxx -Snodis_dev < test -----

Here the the file called test...

rem --- declaration:
SET DBNAME=nodis_dev
sp_helpdb %DBNAME%
go

I receive this message : Msg 102, level 15, state 1:
line 3:
incorrect syntax near '='

Can you see a problem with this code?

Thanks in advance

Wes

sverre wrote:

> rem --- declaration:
> SET DBNAME=mydb
> rem .. remember to avoid blanks in front of and after the '=' sign, i.e do
> not write SET DBNAME = <something>
> ...
> rem --- usage:
> sp_helpdb %DBNAME%
>
> rem --- remove the variable:
> SET DBNAME=
>
> /sverre
>
> "Wes Barrett" <wbarrett@pop200.gsfc.nasa.gov> wrote in message
> news:3A75D322.3EC11CEC@pop200.gsfc.nasa.gov...
> > Can anyone tell me how to declare variables in a NT batch file. I am
> > setting up my dbscripts for our daily db routines. My batch file calls
> > a SQL script file. When it executes I get syntax error near the "=" and
> > also when I try to reference the variable I get the message '$' is an
> > invalid money amount.
> >
> > Ex.
> > DBNAME="mydb"
> > sp_helpdb $DBNAME
> >
> > These variables work in the Unix world. Is it possible to duplicate in
> > the NT world.
> >
> > Thanks,
> >


sverre Posted on 2001-01-30 14:40:36.0Z
From: "sverre" <stvedt@mds.nordion.com>
References: <3A75D322.3EC11CEC@pop200.gsfc.nasa.gov> <gVtRxtpiAHA.305@forums.sybase.com> <3A76C6F8.D81DC2B7@pop200.gsfc.nasa.gov>
Subject: Re: Declaring and Using Variables
Date: Tue, 30 Jan 2001 15:40:36 +0100
Lines: 108
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6600
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
Message-ID: <zxD#DwsiAHA.216@forums.sybase.com>
Newsgroups: sybase.public.sqlserver.nt
NNTP-Posting-Host: 193.214.127.151
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.sqlserver.nt:1269
Article PK: 1088738

Sorry Wes, I treated your isql code as if it was NT shell commands...

Here's how to do it:

If you want to execute a single sql statement, like the example you have
provided, then you have to create an sql file from within the NT batch file,
like this:

rem ----- start of batch file
SET DBNAME=nodis_dev

echo sp_help %DBNAME% > command.sql
echo go >> command.sql
isql -S<servername> -U<user> -P<password) -i command.sql -o command.out
rem ---- end of batch file

In a number of instances I have had the problem that I want to transfer 1 or
more parameters to a large sql file to be executed. Since I have a rather
outdated version of ASE there's no possibility for transferring the database
name as a parameter in the isql statement itself. So I have to construct the
content of the isql input file by means of "echo" statements and file
combination statements.

To add something to the beginning of a large script (typically "use
DBname"/"go"):

echo use databasename > command.sql
type largescript.sql >> command.sql
isql -....- i command.sql -o <output file>
del command.sql

You can of course also combine different script files with the NT copy
command. With a suitable combination of existing script files, echo
staments, type command with pipe and copy commands one can normally obtain
a specified result.

Also, beware that the echo command is quite restrictive and poorly
documented. Hint : use ^ prefix for special characters if you get problems
(very much like "\" on Unix).

regards,
/sverre

"Wes Barrett" <wbarrett@pop200.gsfc.nasa.gov> wrote in message
news:3A76C6F8.D81DC2B7@pop200.gsfc.nasa.gov...
> Good morning sverre, I tried this Set command yesterday as again this
morning.
> Here is the bat file calling the SQL. It is very simple:
>
> isql -Usa -Pxxxxxxx -Snodis_dev < test -----
>
> Here the the file called test...
>
> rem --- declaration:
> SET DBNAME=nodis_dev
> sp_helpdb %DBNAME%
> go
>
> I receive this message : Msg 102, level 15, state 1:
> line 3:
> incorrect syntax near '='
>
> Can you see a problem with this code?
>
> Thanks in advance
>
> Wes
>
>
> sverre wrote:
>
> > rem --- declaration:
> > SET DBNAME=mydb
> > rem .. remember to avoid blanks in front of and after the '=' sign, i.e
do
> > not write SET DBNAME = <something>
> > ...
> > rem --- usage:
> > sp_helpdb %DBNAME%
> >
> > rem --- remove the variable:
> > SET DBNAME=
> >
> > /sverre
> >
> > "Wes Barrett" <wbarrett@pop200.gsfc.nasa.gov> wrote in message
> > news:3A75D322.3EC11CEC@pop200.gsfc.nasa.gov...
> > > Can anyone tell me how to declare variables in a NT batch file. I am
> > > setting up my dbscripts for our daily db routines. My batch file
calls
> > > a SQL script file. When it executes I get syntax error near the "="
and
> > > also when I try to reference the variable I get the message '$' is an
> > > invalid money amount.
> > >
> > > Ex.
> > > DBNAME="mydb"
> > > sp_helpdb $DBNAME
> > >
> > > These variables work in the Unix world. Is it possible to duplicate
in
> > > the NT world.
> > >
> > > Thanks,
> > >
>


Wes Barrett Posted on 2001-01-31 20:54:28.0Z
Message-ID: <3A787B84.98D542AE@pop200.gsfc.nasa.gov>
Date: Wed, 31 Jan 2001 15:54:28 -0500
From: Wes Barrett <wbarrett@pop200.gsfc.nasa.gov>
Organization: NASA/Goddard Space Flight Cente
X-Mailer: Mozilla 4.5 [en] (WinNT; U)
X-Accept-Language: en
MIME-Version: 1.0
Subject: Re: Declaring and Using Variables
References: <3A75D322.3EC11CEC@pop200.gsfc.nasa.gov> <gVtRxtpiAHA.305@forums.sybase.com> <3A76C6F8.D81DC2B7@pop200.gsfc.nasa.gov> <zxD#DwsiAHA.216@forums.sybase.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.sqlserver.nt
Lines: 86
NNTP-Posting-Host: ecn1951527.gsfc.nasa.gov 128.183.74.35
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.sqlserver.nt:1261
Article PK: 1088733

Thanks again, you have been a big help.

sverre wrote:

> Sorry Wes, I treated your isql code as if it was NT shell commands...
>
> Here's how to do it:
>
> If you want to execute a single sql statement, like the example you have
> provided, then you have to create an sql file from within the NT batch file,
> like this:
>
> rem ----- start of batch file
> SET DBNAME=nodis_dev
>
> echo sp_help %DBNAME% > command.sql
> echo go >> command.sql
> isql -S<servername> -U<user> -P<password) -i command.sql -o command.out
> rem ---- end of batch file
>
> In a number of instances I have had the problem that I want to transfer 1 or
> more parameters to a large sql file to be executed. Since I have a rather
> outdated version of ASE there's no possibility for transferring the database
> name as a parameter in the isql statement itself. So I have to construct the
> content of the isql input file by means of "echo" statements and file
> combination statements.
>
> To add something to the beginning of a large script (typically "use
> DBname"/"go"):
>
> echo use databasename > command.sql
> type largescript.sql >> command.sql
> isql -....- i command.sql -o <output file>
> del command.sql
>
> You can of course also combine different script files with the NT copy
> command. With a suitable combination of existing script files, echo
> staments, type command with pipe and copy commands one can normally obtain
> a specified result.
>
> Also, beware that the echo command is quite restrictive and poorly
> documented. Hint : use ^ prefix for special characters if you get problems
> (very much like "\" on Unix).
>
> regards,
> /sverre
>
> "Wes Barrett" <wbarrett@pop200.gsfc.nasa.gov> wrote in message
> news:3A76C6F8.D81DC2B7@pop200.gsfc.nasa.gov...
> > Good morning sverre, I tried this Set command yesterday as again this
> morning.
> > Here is the bat file calling the SQL. It is very simple:
> >
> > isql -Usa -Pxxxxxxx -Snodis_dev < test -----
> >
> > Here the the file called test...
> >
> > rem --- declaration:
> > SET DBNAME=nodis_dev
> > sp_helpdb %DBNAME%
> > go
> >
> > I receive this message : Msg 102, level 15, state 1:
> > line 3:
> > incorrect syntax near '='
> >
> > Can you see a problem with this code?
> >
> > Thanks in advance
> >
> > Wes
> >
> >
> > sverre wrote:
> >
> > > rem --- declaration:
> > > SET DBNAME=mydb
> > > rem .. remember to avoid blanks in front of and after the '=' sign, i.e
> do
> > > not write SET DBNAME = <something>
> > > ...
> > > rem --- usage:
> > > sp_helpdb %DBNAME%
> > >
> > > rem --- remove the variable:
> > > SET DBNAME=
> > >
> > > /sverre
> > >
> > > "Wes Barrett" <wbarrett@pop200.gsfc.nasa.gov> wrote in message
> > > news:3A75D322.3EC11CEC@pop200.gsfc.nasa.gov...
> > > > Can anyone tell me how to declare variables in a NT batch file. I am
> > > > setting up my dbscripts for our daily db routines. My batch file
> calls
> > > > a SQL script file. When it executes I get syntax error near the "="
> and
> > > > also when I try to reference the variable I get the message '$' is an
> > > > invalid money amount.
> > > >
> > > > Ex.
> > > > DBNAME="mydb"
> > > > sp_helpdb $DBNAME
> > > >
> > > > These variables work in the Unix world. Is it possible to duplicate
> in
> > > > the NT world.
> > > >
> > > > Thanks,
> > > >
> >