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.

Sybase Server ISQL dynamic parameters

2 posts in Windows NT Last posting was on 2001-03-24 12:35:51.0Z
"Eric C." <nospam_eric.carmody Posted on 2001-03-23 18:26:12.0Z
From: "Eric C." <nospam_eric.carmody@visto.com_no_spams>
Organization: 208.146.114.30
X-Newsreader: AspNNTP 1.50 (Advent 2000, Inc.)
Subject: Sybase Server ISQL dynamic parameters
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Message-ID: <zXI68a8sAHA.301@forums.sybase.com>
Newsgroups: sybase.public.sqlserver.nt
Date: Fri, 23 Mar 2001 13:26:12 -0500
Lines: 38
NNTP-Posting-Host: 207.156.232.111
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.sqlserver.nt:1043
Article PK: 1087650

Hello everyone,

I want to be able to call Sybase Server ISQL from a WinNT cmd file and be able
to supply text for an INSERT statement. The sql is just to insert a record into
a error table. A column for the insert is a description of the error.

Can I use a single .sql file and pass a parameter for the description column?
How? Or else, can I code the whole sql statements on a isql command line using
different text for the description?

In the cmd file I am coding....(see below for sql code in the file)
isql -Sspsvm024 -Uxxx -Pyyy -ilog_error.sql

This runs the sql file ok, however I want to be able to pass text for the
description column of the INSERT record.

My sql code in the log_error.sql file is to insert a record into a error log
table in the database is something like...

use DBAdmin_db
go

INSERT INTO pmProcessLog
SELECT 'S' ,
max(ProcessLogId) + 1,
'OPOI',
'1',
'BCP out error @ ' + convert(char,getdate()) --this is the
description column
FROM pmProcessLog
go

Currently, I need a seperate .sql file for each predefined error message I am
logging. I'd rather one generic .sql file and pass the text to it, or else be
able to do this another dynamic way without having to code a bunch of sql files
for different error messages.

Thanks for any comments.
Cheers,
Eric

---== Posted via the PFCGuide Web Newsreader ==---
http://www.pfcguide.com/_newsgroups/group_list.asp


sverre Posted on 2001-03-24 12:35:51.0Z
From: "sverre" <stvedt@mds.nordion.com>
References: <zXI68a8sAHA.301@forums.sybase.com>
Subject: Re: Sybase Server ISQL dynamic parameters
Date: Sat, 24 Mar 2001 13:35:51 +0100
Lines: 102
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: <Ej1cYFGtAHA.199@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:1042
Article PK: 1087649

hello,

The simplest solution is to build the insert statement separately with some
tool and output it to a temp file.
Thereafter you can concatenate the temp file with your standard sql file.
This works fine if the insert statement is in the beginning or at the end of
the standard file. If it is in the middle, you will have to split the
standard script into 2 parts and concatenate part1 + insert statement +
part2 and finally execute the resulting file. If there is a lot of insertion
points, it becomes rather annoying.

I have elsewhere in this forum given examples of NT 'echo' statements used
to build the variable part of an sql file and how to combine the result with
a fixed-part sql file.

NT is pretty awkward for this kind of work, but there is a simple
work-around if you don't want to buy a scripting tool for handling such
problems:

In your example, you could simply build the whole sql file from the cmd file
like this:

rem --- this batch file could have an input parameters given by %1, %2,%3
etc
echo use DBAdmin_db > ilog_error.sql
use go >> ilog_error.sql
echo INSERT INTO pmProcessLog >> ilog_error.sql
echo SELECT 'S' , >> ilog_error.sql
echo max(ProcessLogId) + 1, >> ilog_error.sql
echo 'OPOI', >> ilog_error.sql
echo '1', >> ilog_error.sql
echo 'BCP out error %1 %2 %3 ' + convert(char,getdate()) >>
ilog_error.sql
echo FROM pmProcessLog >> ilog_error.sql
echo go >> ilog_error.sql
isql -Uxxx -Syyy -Pxx -i ilog_err.sql

The only care is that special characters echoed with the 'echo' command must
be preceded with ^ in order to not be interpreted as a syntactic part of
the echo statement. I have not tested the above suggestion for that.

f.instance, to append a statement like ' where X1 > X0' to a file, write:
echo where X1 ^> X0 >> filename.sql

/sverre

"Eric C." <nospam_eric.carmody@visto.com_no_spams> wrote in message
news:zXI68a8sAHA.301@forums.sybase.com...
> Hello everyone,
>
> I want to be able to call Sybase Server ISQL from a WinNT cmd file and be
able
> to supply text for an INSERT statement. The sql is just to insert a record
into
> a error table. A column for the insert is a description of the error.
>
> Can I use a single .sql file and pass a parameter for the description
column?
> How? Or else, can I code the whole sql statements on a isql command line
using
> different text for the description?
>
> In the cmd file I am coding....(see below for sql code in the file)
> isql -Sspsvm024 -Uxxx -Pyyy -ilog_error.sql
>
> This runs the sql file ok, however I want to be able to pass text for the
> description column of the INSERT record.
>
> My sql code in the log_error.sql file is to insert a record into a error
log
> table in the database is something like...
>
> use DBAdmin_db
> go
>
> INSERT INTO pmProcessLog
> SELECT 'S' ,
> max(ProcessLogId) + 1,
> 'OPOI',
> '1',
> 'BCP out error @ ' + convert(char,getdate()) --this is the
> description column
> FROM pmProcessLog
> go
>
> Currently, I need a seperate .sql file for each predefined error message I
am
> logging. I'd rather one generic .sql file and pass the text to it, or else
be
> able to do this another dynamic way without having to code a bunch of sql
files
> for different error messages.
>
> Thanks for any comments.
> Cheers,
> Eric
>
> ---== Posted via the PFCGuide Web Newsreader ==---
> http://www.pfcguide.com/_newsgroups/group_list.asp