Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #364 > unrolled thread

SS 2008: Front-End Language Processor for Scripts

Started byGene Wirchenko <genew@ocis.net>
First post2011-05-23 15:24 -0700
Last post2011-05-25 17:27 +0100
Articles 10 — 3 participants

Back to article view | Back to comp.databases.ms-sqlserver


Contents

  SS 2008: Front-End Language Processor for Scripts Gene Wirchenko <genew@ocis.net> - 2011-05-23 15:24 -0700
    Re: SS 2008: Front-End Language Processor for Scripts Erland Sommarskog <esquel@sommarskog.se> - 2011-05-24 07:21 +0000
      Re: SS 2008: Front-End Language Processor for Scripts Gene Wirchenko <genew@ocis.net> - 2011-05-24 17:21 -0700
        Re: SS 2008: Front-End Language Processor for Scripts Erland Sommarskog <esquel@sommarskog.se> - 2011-05-25 12:39 +0000
          Re: SS 2008: Front-End Language Processor for Scripts Gene Wirchenko <genew@ocis.net> - 2011-05-25 12:46 -0700
            Re: SS 2008: Front-End Language Processor for Scripts Erland Sommarskog <esquel@sommarskog.se> - 2011-05-25 23:33 +0200
              Re: SS 2008: Front-End Language Processor for Scripts Gene Wirchenko <genew@ocis.net> - 2011-05-25 15:21 -0700
                Re: SS 2008: Front-End Language Processor for Scripts Erland Sommarskog <esquel@sommarskog.se> - 2011-05-26 23:44 +0200
                  Re: SS 2008: Front-End Language Processor for Scripts Gene Wirchenko <genew@ocis.net> - 2011-05-26 15:24 -0700
    Re: SS 2008: Front-End Language Processor for Scripts Bernard Peek <bap@shrdlu.com> - 2011-05-25 17:27 +0100

#364 — SS 2008: Front-End Language Processor for Scripts

FromGene Wirchenko <genew@ocis.net>
Date2011-05-23 15:24 -0700
SubjectSS 2008: Front-End Language Processor for Scripts
Message-ID<ctmlt61e9p7uarqa20uc24qurkdirv6lnv@4ax.com>
Dear SQLers:

     I am trying to get around some of the limitations of T-SQL.

     I wish to run a preprocessor over script files much as the C
preprocessor does for C programs.  File inclusion and symbol
definition commands are about all I need.  Does anyone know of one
that will work well with SQL Server script files?

     I want to be able to define symbols like
          #define ERRSTL N'50001: String %s is too long.'
in a secondary file and have statements like
          raiserror(ERRSTL,16,1,N'ACUK)
expand to
          raiserror(N'50001: String %s is too long.',16,1,N'ACUK)
This would allow me to freely reorganise error codes without having to
hunt manually, and it would allow me to have consistency over multiple
scripts.

     I have done some searching and apparently one such is m4, but I
have been unable to download it.  (I only get a partial download and
do not know how to proceed.)

     Any ideas?

Sincerely,

Gene Wirchenko

[toc] | [next] | [standalone]


#366

FromErland Sommarskog <esquel@sommarskog.se>
Date2011-05-24 07:21 +0000
Message-ID<Xns9EEF5F37CE96DYazorman@127.0.0.1>
In reply to#364
Gene Wirchenko (genew@ocis.net) writes:
>      I wish to run a preprocessor over script files much as the C
> preprocessor does for C programs.  File inclusion and symbol
> definition commands are about all I need.  Does anyone know of one
> that will work well with SQL Server script files?
 
So this is a shameless plug, but you asked for it, didn't you? :-)
http://www.sommarskog.se/AbaPerls/index.html will give you everything you 
need and probably too much you don't need, at least for the moment.

For a more modest effort - and with a more complete preprocessor - get 
Visual C++ and use that preprocessors. I don't have any samples, but I 
believe I've heard people who have done it.

-- 
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

[toc] | [prev] | [next] | [standalone]


#371

FromGene Wirchenko <genew@ocis.net>
Date2011-05-24 17:21 -0700
Message-ID<8liot6lm9t1b5reup0fqq7kkn68tbg6uhi@4ax.com>
In reply to#366
On Tue, 24 May 2011 07:21:36 +0000 (UTC), Erland Sommarskog
<esquel@sommarskog.se> wrote:

>Gene Wirchenko (genew@ocis.net) writes:
>>      I wish to run a preprocessor over script files much as the C
>> preprocessor does for C programs.  File inclusion and symbol
>> definition commands are about all I need.  Does anyone know of one
>> that will work well with SQL Server script files?
> 
>So this is a shameless plug, but you asked for it, didn't you? :-)
>http://www.sommarskog.se/AbaPerls/index.html will give you everything you 
>need and probably too much you don't need, at least for the moment.

     Yes, I did.

     I tried and ran into some trouble.  The tests for
Win32::SqlServer failed.  I got:

SQL Server message 2, Severity 16, State 1
Named Pipes Provider: Could not open a connection to SQL Server [2]. 
Message 08001 from 'Microsoft SQL Server Native Client 10.0',
Severity: 16
A network-related or instance-specific error has occurred while
establishing a connection to SQL Server. Server is not found or not
accessible. Check if instance name is correct and if SQL Server is
configured to allow remote connections. For more information see SQL
Server Books Online.
Message HYT00 from 'Microsoft SQL Server Native Client 10.0',
Severity: 16
Login timeout expired
Terminating on fatal error at t\testsqllogin.pl line 59

     My guess is that it is trying to use the wrong instance name. How
do I specify the instance?

     Or is it something else?

>For a more modest effort - and with a more complete preprocessor - get 
>Visual C++ and use that preprocessors. I don't have any samples, but I 
>believe I've heard people who have done it.

     I will try hunting down some docs for this.

Sincerely,

Gene Wirchenko

[toc] | [prev] | [next] | [standalone]


#372

FromErland Sommarskog <esquel@sommarskog.se>
Date2011-05-25 12:39 +0000
Message-ID<Xns9EF0951605EBAYazorman@127.0.0.1>
In reply to#371
Gene Wirchenko (genew@ocis.net) writes:
>      I tried and ran into some trouble.  The tests for
> Win32::SqlServer failed.  I got:
> 
> SQL Server message 2, Severity 16, State 1
> Named Pipes Provider: Could not open a connection to SQL Server [2]. 
> Message 08001 from 'Microsoft SQL Server Native Client 10.0',
> Severity: 16
> A network-related or instance-specific error has occurred while
> establishing a connection to SQL Server. Server is not found or not
> accessible. Check if instance name is correct and if SQL Server is
> configured to allow remote connections. For more information see SQL
> Server Books Online.

Which means that you were not able to contact SQL Server.

>      My guess is that it is trying to use the wrong instance name. How
> do I specify the instance?
> 
>      Or is it something else?
 
If you were running the test suite for Win32::SqlServer, you need to set up 
connection details with OLLEDBTEST as described in Tests.html. If you are 
trying to use an AbaPerls tool, use the -S switch to specify a server.


-- 
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

[toc] | [prev] | [next] | [standalone]


#375

FromGene Wirchenko <genew@ocis.net>
Date2011-05-25 12:46 -0700
Message-ID<vqmqt65aenrhondskctpgjiu1fsd0ku2i9@4ax.com>
In reply to#372
On Wed, 25 May 2011 12:39:20 +0000 (UTC), Erland Sommarskog
<esquel@sommarskog.se> wrote:

[snip]

>If you were running the test suite for Win32::SqlServer, you need to set up 
>connection details with OLLEDBTEST as described in Tests.html. If you are 
>trying to use an AbaPerls tool, use the -S switch to specify a server.

     Ah, missed that bit.  All of the test work (or are skipped). Now,
the next part is actually getting AbaPerls set up.  I put the commands
in a batch file and get:

C:\cbs2dev\SQLServer\AbaPerls\Perl>go

C:\cbs2dev\SQLServer\AbaPerls\Perl>set
path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\system32\WindowsPowerShell\v1.0;c:\Program
Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft
SQL Server\100\DTS\Binn\;c:\Program Files\Microsoft SQL
Server\100\Tools\Binn\VSShell\Common7\IDE\;c:\Program Files\Microsoft
Visual Studio
9.0\Common7\IDE\PrivateAssemblies\;c:\batch;c:\util;c:\util\Sysinternals;c:\Program
Files\MiKTeX\miktex\bin;C:\Perl\site\bin;C:\Perl\bin;c:\cbs2dev\SQLServer\AbaPerls\Perl

C:\cbs2dev\SQLServer\AbaPerls\Perl>set
perllib=c:\cbs2dev\SQLServer\AbaPerls\Perl

C:\cbs2dev\SQLServer\AbaPerls\Perl>dbbuild -Server LOOP\SQLEXPRESS
-database Banking
defined(%hash) is deprecated at
c:\cbs2dev\SQLServer\AbaPerls\Perl/AbaPerls/AbaS
ql.pm line 433.
        (Maybe you should just omit the defined()?)
Use of uninitialized value $opt_subsystem in uc at dbbuild.bat line
458.
      DECLARE @name sysname,
Cannot change directory to NAMELESS\sql: No such file or directory

C:\cbs2dev\SQLServer\AbaPerls\Perl>

Sincerely,

Gene Wirchenko

[toc] | [prev] | [next] | [standalone]


#377

FromErland Sommarskog <esquel@sommarskog.se>
Date2011-05-25 23:33 +0200
Message-ID<Xns9EF0EF9AF1888Yazorman@127.0.0.1>
In reply to#375
Gene Wirchenko (genew@ocis.net) writes:
> C:\cbs2dev\SQLServer\AbaPerls\Perl>dbbuild -Server LOOP\SQLEXPRESS
> -database Banking
> defined(%hash) is deprecated at
> c:\cbs2dev\SQLServer\AbaPerls\Perl/AbaPerls/AbaS
> ql.pm line 433.
>         (Maybe you should just omit the defined()?)
> Use of uninitialized value $opt_subsystem in uc at dbbuild.bat line
> 458.

They added more warnings to Perl in 5.12, so you get a lot of these
with AbaPerls. I have address these, but I have not made a public
release of those changes yet. And it will probably take some time
before I do, since I've recently completed a major overhaul to add
support for TFS. I think I want to see it stabilise first...

I think Perl 5.10 is a better choice for the time being.

>       DECLARE @name sysname,
> Cannot change directory to NAMELESS\sql: No such file or directory
 
Just a word of warning: if you found Microsoft's documentation difficult
to get through, AbaPerls is definitely rougher. Now, I don't know
what your current directory is, but let's say you have your SQL files
in Banking\SQL in an AbaPerls directory structure. Then you need to be
in the folder above Banking and specify -subsy BANKING.




-- 
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx

[toc] | [prev] | [next] | [standalone]


#378

FromGene Wirchenko <genew@ocis.net>
Date2011-05-25 15:21 -0700
Message-ID<2svqt6t7tr63dcbd5552cal5arpckk72jn@4ax.com>
In reply to#377
On Wed, 25 May 2011 23:33:14 +0200, Erland Sommarskog
<esquel@sommarskog.se> wrote:

>Gene Wirchenko (genew@ocis.net) writes:
>> C:\cbs2dev\SQLServer\AbaPerls\Perl>dbbuild -Server LOOP\SQLEXPRESS
>> -database Banking
>> defined(%hash) is deprecated at
>> c:\cbs2dev\SQLServer\AbaPerls\Perl/AbaPerls/AbaS
>> ql.pm line 433.
>>         (Maybe you should just omit the defined()?)
>> Use of uninitialized value $opt_subsystem in uc at dbbuild.bat line
>> 458.
>
>They added more warnings to Perl in 5.12, so you get a lot of these
>with AbaPerls. I have address these, but I have not made a public

     Warnings or errors?  By a warning, I mean emit error message and
continue.  By an error, I mean emit error and stop.

>release of those changes yet. And it will probably take some time
>before I do, since I've recently completed a major overhaul to add
>support for TFS. I think I want to see it stabilise first...
>
>I think Perl 5.10 is a better choice for the time being.

     Groan!  That will be three Perl downloads and installations.  I
suppose I need the practice.

>>       DECLARE @name sysname,
>> Cannot change directory to NAMELESS\sql: No such file or directory

     And this?  Where is "NAMELESS\sql" coming from?

>Just a word of warning: if you found Microsoft's documentation difficult
>to get through, AbaPerls is definitely rougher. Now, I don't know
>what your current directory is, but let's say you have your SQL files
>in Banking\SQL in an AbaPerls directory structure. Then you need to be
>in the folder above Banking and specify -subsy BANKING.

     No, c:\cbs2dev\SQLServer is the directory name.  I have not
gotten into organising my SQL Server code into different directories
yet.  I do not have very much.

     I do not find Microsoft's documentation difficult to get through.
I find it difficult to find anything in it above the tactical level.
(The syntax of a command is tactical.  Why one might use it or the
approach that one uses it in is strategic and often of much greater
concern for me.)

Sincerely,

Gene Wirchenko

[toc] | [prev] | [next] | [standalone]


#380

FromErland Sommarskog <esquel@sommarskog.se>
Date2011-05-26 23:44 +0200
Message-ID<Xns9EF1F17CC3329Yazorman@127.0.0.1>
In reply to#378
Gene Wirchenko (genew@ocis.net) writes:
>>They added more warnings to Perl in 5.12, so you get a lot of these
>>with AbaPerls. I have address these, but I have not made a public
> 
>      Warnings or errors?  By a warning, I mean emit error message and
> continue.  By an error, I mean emit error and stop.

Warnings. Had I meant errors, I would have said errors. :-)
 
>>I think Perl 5.10 is a better choice for the time being.
> 
>      Groan!  That will be three Perl downloads and installations.  I
> suppose I need the practice.

Bzzt! I have six Perl installations on my machine. And since they have
released 5.14, I will need two more. But, OK, I build Perl modules and
you don't (I assume).

 
>>       DECLARE @name sysname,
>>> Cannot change directory to NAMELESS\sql: No such file or directory
> 
>      And this?  Where is "NAMELESS\sql" coming from?
>...
>      No, c:\cbs2dev\SQLServer is the directory name.  I have not
> gotten into organising my SQL Server code into different directories
> yet.  I do not have very much.

Well, to use DBBUILD you will have no choice to adhere to the AbaPerls
Directory structure. Which means that stored procedures goes into
the SP directory, and they need to have the .sp extension. And so
on, see http://www.sommarskog.se/AbaPerls/doc/structure.html. (The
manual is also in your download.)

Furthermore, with the version of AbaPerls you downloaded, when you build
from disk without SourceSafe, you need to be in a directory two levels
above the SQL directory. You did not specify a subsystem name, why 
AbaPerls assumes the name NAMELESS. Whence NAMELESS\sql.

What is silly is that you should be able to run DBBUILD in your SQL
directory or in, say, SQL\Scripts, and I have fixed this, but it's
in the public release.

I'm afraid that using AbaPerls without reading the manual can be a rough 
ride, since there are some things you may not expect at first. And the
rules are complex - Hey, I started the develop AbaPerls in 1996, so it
has acquired some complexity by time.


-- 
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx

[toc] | [prev] | [next] | [standalone]


#381

FromGene Wirchenko <genew@ocis.net>
Date2011-05-26 15:24 -0700
Message-ID<cmktt6d7qqd2v306q64qu7untol43n84ma@4ax.com>
In reply to#380
On Thu, 26 May 2011 23:44:20 +0200, Erland Sommarskog
<esquel@sommarskog.se> wrote:

[snip]

     I give up.  I can not even tell if anything useful is getting
done.

Sincerely,

Gene Wirchenko

[toc] | [prev] | [next] | [standalone]


#373

FromBernard Peek <bap@shrdlu.com>
Date2011-05-25 17:27 +0100
Message-ID<944ov3FetmU1@mid.individual.net>
In reply to#364
On 23/05/11 23:24, Gene Wirchenko wrote:
> Dear SQLers:
> 
>      I am trying to get around some of the limitations of T-SQL.
> 
>      I wish to run a preprocessor over script files much as the C
> preprocessor does for C programs.  File inclusion and symbol
> definition commands are about all I need.  Does anyone know of one
> that will work well with SQL Server script files?
> 
>      I want to be able to define symbols like
>           #define ERRSTL N'50001: String %s is too long.'
> in a secondary file and have statements like
>           raiserror(ERRSTL,16,1,N'ACUK)
> expand to
>           raiserror(N'50001: String %s is too long.',16,1,N'ACUK)

This is a simple substitution. Have you considered using sed?



-- 
Bernard Peek
bap@shrdlu.com

[toc] | [prev] | [standalone]


Back to top | Article view | comp.databases.ms-sqlserver


csiph-web