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.

ASE150 XP server executing an ESP fails when executing srv_numparams

3 posts in General Discussion Last posting was on 2009-06-02 15:07:54.0Z
mark87544 Posted on 2009-05-29 22:33:48.0Z
From: mark87544 <north35west106@gmail.com>
Newsgroups: sybase.public.ase.general
Subject: ASE150 XP server executing an ESP fails when executing srv_numparams
Date: Fri, 29 May 2009 15:33:48 -0700 (PDT)
Organization: http://groups.google.com
Lines: 25
Message-ID: <70b59fd3-bbee-45bf-a5ee-e61b687979d5@l12g2000yqo.googlegroups.com>
NNTP-Posting-Host: 65.100.117.195
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1243636428 29881 127.0.0.1 (29 May 2009 22:33:48 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 29 May 2009 22:33:48 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: l12g2000yqo.googlegroups.com; posting-host=65.100.117.195; posting-account=m13M-goAAAAJsLi5sXbI3tpd_sJjcc1F
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/530.5 (KHTML, like Gecko) Chrome/2.0.172.28 Safari/530.5,gzip(gfe),gzip(gfe)
X-HTTP-Via: 1.1 LA-IronPort-01.lanb.com:80 (IronPort-WSA/5.6.2-102)
Path: forums-1-dub!forums-master!newssvr.sybase.com!news-sj-1.sprintlink.net!news-peer1.sprintlink.net!newsfeed.yul.equant.net!transit4.readnews.com!transit3.readnews.com!news-out.readnews.com!news-xxxfer.readnews.com!postnews.google.com!l12g2000yqo.googlegroups.com!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:27801
Article PK: 77052

Hi,
I am writing a series of Extended Stored Procedures (ESP) in C++.
Within a function named "espGetVersion" i get an error (see message
below) when i execute srv_numparams. I searched Google for the error,
but have been unable to find a solution.

ERROR TEXT: "Error(16142) detected before Open Server initialized"

C++ code snippet:

CS_RETCODE espGetVersion(SRV_PROC* srvproc) {
string functionStr("espGetVersion");
ofstream* coutFPtr=(std::ofstream *)&std::cout;
CS_RETCODE retcode = CS_SUCCEED;
CS_INT parmsPassed=0;

srv_numparams(srvproc,&parmsPassed); // error occurs here

ASE VERSION: Adaptive Server Enterprise/15.0.2/EBF 15681 ESD#5/P/
RS6000/AIX 5.2/ase1502/2528/64-bit/
AIX VERSION: 6.1.2.0

Thanks
Mark


Neal Stack [Sybase] Posted on 2009-06-01 17:36:19.0Z
Message-ID: <4A241192.7070701@nospam.com>
From: "Neal Stack [Sybase]" <nstack@nospam.com>
User-Agent: Thunderbird 2.0.0.21 (Windows/20090302)
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
To: mark87544 <north35west106@gmail.com>
Subject: Re: ASE150 XP server executing an ESP fails when executing srv_numparams
References: <70b59fd3-bbee-45bf-a5ee-e61b687979d5@l12g2000yqo.googlegroups.com>
In-Reply-To: <70b59fd3-bbee-45bf-a5ee-e61b687979d5@l12g2000yqo.googlegroups.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
Date: 1 Jun 2009 10:36:19 -0700
X-Trace: forums-1-dub 1243877779 10.22.241.152 (1 Jun 2009 10:36:19 -0700)
X-Original-Trace: 1 Jun 2009 10:36:19 -0700, vip152.sybase.com
Lines: 96
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:27806
Article PK: 77057

Hello,

I'm not sure how you are compiling and linking your library.

The sample program uses srv_numparams() and does not have any issues....

% cd $SYBASE/$SYBASE_ASE/sample/esp
% make -f make.unix
cd .; cc -DSYB_LP64 -I/bluesky21/nstack/OCS-15_0/include -q64 -qarch=ppc64 -o ./xp_echo.o -c xp_echo.c
Loading examples.so

MODE: normal
OBJS: xp_echo.o
DEBUGOBJS:

cd .; gen_export.sh; ld -o ./examples.so -lc_r -lm -G -b64 -bM:SRE -bnoentry -bE:examples.exp -bI:examples.imp xp_echo.o


Are you using an import file as illustrated in the sample program?
% cat examples.imp
#! .
srv_bind
srv_descfmt
srv_numparams
srv_senddone
srv_sendinfo
srv_sendstatus
srv_xferdata


% cp examples.so $SYBASE/$SYBASE_ASE/lib

% isql -Usa -P
1> create procedure xp_echo @in varchar(255)
2> as external name "examples.so"
3> go
1> xp_echo "Hello world"
2> go
xp_echo


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Hello world


(1 row affected)
(return status = 0)


The sample program is a C program, not a C++ so I don't know if the instantiation of
your method espGetVersion() is somehow passing a NULL SRV_PROC. In general, here is
an explanation of the error:

Error Number: 16142
Symbolic Content: SRV_EPROCINVALID
Severity: 10
Message Text: Server process address 0x%1! not in pool in '%2!'
Possible Cause(s): The SRV_PROC address does not exist in the array of server processes maintained in the SRV_SERVER structure.
Action(s) To Take: Use the SRV_CURPROC macro to find the address of the currently active thread.


SRV_PROC *threadp; /* Thread control structure pointer. */

threadp = SRV_CURPROC; /* Get a pointer to thread control structure.*/

Regards,
Neal

mark87544 wrote:
> Hi,
> I am writing a series of Extended Stored Procedures (ESP) in C++.
> Within a function named "espGetVersion" i get an error (see message
> below) when i execute srv_numparams. I searched Google for the error,
> but have been unable to find a solution.
>
> ERROR TEXT: "Error(16142) detected before Open Server initialized"
>
> C++ code snippet:
>
> CS_RETCODE espGetVersion(SRV_PROC* srvproc) {
> string functionStr("espGetVersion");
> ofstream* coutFPtr=(std::ofstream *)&std::cout;
> CS_RETCODE retcode = CS_SUCCEED;
> CS_INT parmsPassed=0;
>
> srv_numparams(srvproc,&parmsPassed); // error occurs here
>
> ASE VERSION: Adaptive Server Enterprise/15.0.2/EBF 15681 ESD#5/P/
> RS6000/AIX 5.2/ase1502/2528/64-bit/
> AIX VERSION: 6.1.2.0
>
> Thanks
> Mark
>


Mark Murdock Posted on 2009-06-02 15:07:54.0Z
From: Mark Murdock <north35west106@gmail.com>
Newsgroups: sybase.public.ase.general
Subject: Re: ASE150 XP server executing an ESP fails when executing srv_numparams
Date: Tue, 2 Jun 2009 08:07:54 -0700 (PDT)
Organization: http://groups.google.com
Lines: 123
Message-ID: <57d64bde-5625-4647-a3ef-0177b08ab571@f16g2000vbf.googlegroups.com>
References: <70b59fd3-bbee-45bf-a5ee-e61b687979d5@l12g2000yqo.googlegroups.com> <4A241192.7070701@nospam.com>
NNTP-Posting-Host: 65.100.117.195
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1243955274 26610 127.0.0.1 (2 Jun 2009 15:07:54 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 2 Jun 2009 15:07:54 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: f16g2000vbf.googlegroups.com; posting-host=65.100.117.195; posting-account=m13M-goAAAAJsLi5sXbI3tpd_sJjcc1F
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/530.5 (KHTML, like Gecko) Chrome/2.0.172.28 Safari/530.5,gzip(gfe),gzip(gfe)
X-HTTP-Via: 1.1 LA-IronPort-01.lanb.com:80 (IronPort-WSA/5.6.2-102)
Path: forums-1-dub!forums-master!newssvr.sybase.com!news-sj-1.sprintlink.net!news-peer1.sprintlink.net!nntp1.phx1.gblx.net!nntp.gblx.net!nntp.gblx.net!border2.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!f16g2000vbf.googlegroups.com!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:27809
Article PK: 77063


On Jun 1, 11:36 am, "Neal Stack [Sybase]" <nst...@nospam.com> wrote:
> Hello,
>
> I'm not sure how you are compiling and linking your library.
>
> The sample program uses srv_numparams() and does not have any issues....
>
> % cd $SYBASE/$SYBASE_ASE/sample/esp
> % make -f make.unix
>          cd .;  cc -DSYB_LP64 -I/bluesky21/nstack/OCS-15_0/include -q64 -qarch=ppc64  -o ./xp_echo.o -c xp_echo.c
> Loading examples.so
>
>          MODE:           normal
>          OBJS:           xp_echo.o
>          DEBUGOBJS:
>
>          cd .;  gen_export.sh;  ld -o ./examples.so  -lc_r -lm -G  -b64 -bM:SRE -bnoentry -bE:examples.exp -bI:examples.imp  xp_echo.o
>
> Are you using an import file as illustrated in the sample program?
> % cat examples.imp
> #! .
> srv_bind
> srv_descfmt
> srv_numparams
> srv_senddone
> srv_sendinfo
> srv_sendstatus
> srv_xferdata
>
> % cp examples.so $SYBASE/$SYBASE_ASE/lib
>
> % isql -Usa -P
> 1> create procedure xp_echo @in varchar(255)
> 2> as external name "examples.so"
> 3> go
> 1> xp_echo "Hello world"
> 2> go
>   xp_echo
>
> --------------------------------------------------------------------------- --------------------------------------------------------------------------- --------------------------------------------------------------------------- ------------------------------
>
>   Hello world
>
> (1 row affected)
> (return status = 0)
>
> The sample program is a C program, not a C++ so I don't know if the instantiation of
> your method espGetVersion() is somehow passing a NULL SRV_PROC.  In general, here is
> an explanation of the error:
>
> Error Number: 16142
> Symbolic Content: SRV_EPROCINVALID
> Severity: 10
> Message Text: Server process address 0x%1! not in pool in '%2!'
> Possible Cause(s): The SRV_PROC address does not exist in the array of server processes maintained in the SRV_SERVER structure.
> Action(s) To Take: Use the SRV_CURPROC macro to find the address of the currently active thread.
>
>          SRV_PROC        *threadp; /* Thread control structure pointer.  */
>
>          threadp = SRV_CURPROC;  /* Get a pointer to thread control structure.*/
>
> Regards,
>    Neal
>
>
>
> mark87544 wrote:
> > Hi,
> > I am writing a series of Extended Stored Procedures (ESP) in C++.
> > Within a function named "espGetVersion" i get an error (see message
> > below) when i execute srv_numparams. I searched Google for the error,
> > but have been unable to find a solution.
>
> > ERROR TEXT: "Error(16142) detected before Open Server initialized"
>
> > C++ code snippet:
>
> > CS_RETCODE espGetVersion(SRV_PROC* srvproc) {
> > string          functionStr("espGetVersion");
> > ofstream*       coutFPtr=(std::ofstream *)&std::cout;
> > CS_RETCODE      retcode = CS_SUCCEED;
> > CS_INT          parmsPassed=0;
>
> >         srv_numparams(srvproc,&parmsPassed); // error occurs here
>
> > ASE VERSION: Adaptive Server Enterprise/15.0.2/EBF 15681 ESD#5/P/
> > RS6000/AIX 5.2/ase1502/2528/64-bit/
> > AIX VERSION:   6.1.2.0
>
> > Thanks
> > Mark

All,
Yes the problems lies in that i am using C++ (versus C as in the
example xp_echo.c).

What i found was a linker issue (i.e. runtime boundry issues). As C++
mangles the function names the ability to link in export and import
files (using the -bE and -bI linker options) to create a shared
library proved to be troublesome.

What i found was a utility named "makeC++SharedLib" which reconciled
my linker errors and created a usable C++ shared library.

Neal, thank you for finding the specific details on error# 16142, you
must have dug deep for that one!

Thanks for all the feedback.

Mark