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.

output parameter in stored procedure

3 posts in General Discussion Last posting was on 2004-09-08 15:14:50.0Z
Glenn Stein Posted on 2004-09-08 07:52:48.0Z
From: "Glenn Stein" <glenns@bezeqint.net>
Newsgroups: ianywhere.public.general
Subject: output parameter in stored procedure
Lines: 21
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
X-Original-NNTP-Posting-Host: teck-netvision.ser.netvision.net.il
Message-ID: <413ebbef$1@forums-2-dub>
X-Original-Trace: 8 Sep 2004 00:59:43 -0700, teck-netvision.ser.netvision.net.il
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 8 Sep 2004 00:41:22 -0700, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 8 Sep 2004 00:52:48 -0700
X-Trace: forums-1-dub 1094629968 10.22.108.75 (8 Sep 2004 00:52:48 -0700)
X-Original-Trace: 8 Sep 2004 00:52:48 -0700, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:3498
Article PK: 7400

I am trying to write a stored procedure with an output parameter -- but it
doesn't seem to be working.

My SQL is:

CREATE PROCEDURE DBA.spAddOrganization(@newID integer output)
as
insert into organizations( name_long) values( 'Unknown')
select @newID=@@identity

I am trying to test it with the following script:

Declare @newID integer
spAddOrganization @newID
Select @newID

Can anyone tell me what I am doing wrong?

Thanks!


Greg Fenton Posted on 2004-09-08 15:14:50.0Z
From: Greg Fenton <greg.fenton_NOSPAM_@ianywhere.com>
Organization: iAnywhere Solutions Inc.
User-Agent: Mozilla Thunderbird 1.6.3.2f (Windows/20040803)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: ianywhere.public.general
Subject: Re: output parameter in stored procedure
References: <413ebbef$1@forums-2-dub>
In-Reply-To: <413ebbef$1@forums-2-dub>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
X-Original-NNTP-Posting-Host: gfenton-xp.sybase.com
Message-ID: <413f238c$1@forums-2-dub>
X-Original-Trace: 8 Sep 2004 08:21:48 -0700, gfenton-xp.sybase.com
Lines: 31
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 8 Sep 2004 08:03:25 -0700, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 8 Sep 2004 08:14:50 -0700
X-Trace: forums-1-dub 1094656490 10.22.108.75 (8 Sep 2004 08:14:50 -0700)
X-Original-Trace: 8 Sep 2004 08:14:50 -0700, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:3505
Article PK: 7406


Glenn Stein wrote:
>
> CREATE PROCEDURE DBA.spAddOrganization(@newID integer output)
> as
> insert into organizations( name_long) values( 'Unknown')
> select @newID=@@identity
>

You might consider writing this as a Watcom SQL stored procedure:

CREATE PROCEDURE DBA.spAddOrganization( OUT @newID INTEGER )
BEGIN
insert into DBA.organizations(name_long) values('Unknown');
SET @newID = @@identity;
END;

Then call it as:

DECLARE @newID INTEGER
CALL DBA.spAddOrganization(@newID)
SELECT @newID

Hope this helps,
greg.fenton
--
Greg Fenton
Consultant, Solution Services, iAnywhere Solutions
--------
Visit the iAnywhere Solutions Developer Community
Whitepapers, TechDocs, Downloads
http://www.ianywhere.com/developer/


Dmitriy Popov <none Posted on 2004-09-08 13:50:52.0Z
Newsgroups: ianywhere.public.general
Subject: Re: output parameter in stored procedure
From: Dmitriy Popov <none@none.>
References: <413ebbef$1@forums-2-dub>
Organization: Tenmast
User-Agent: Xnews/5.04.25
NNTP-Posting-Host: 216.248.61.18
X-Original-NNTP-Posting-Host: 216.248.61.18
Message-ID: <413f0e3c$1@forums-1-dub>
Date: 8 Sep 2004 06:50:52 -0700
X-Trace: forums-1-dub 1094651452 216.248.61.18 (8 Sep 2004 06:50:52 -0700)
X-Original-Trace: 8 Sep 2004 06:50:52 -0700, 216.248.61.18
Lines: 38
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:3502
Article PK: 7409

Try calling it this way instead:

spAddOrganization @newID OUTPUT


or, better off,

spAddOrganization @newID = @newID OUTPUT



"Glenn Stein" <glenns@bezeqint.net> wrote in
news:413ebbef$1@forums-2-dub:

> I am trying to write a stored procedure with an output parameter --
> but it doesn't seem to be working.
>
> My SQL is:
>
> CREATE PROCEDURE DBA.spAddOrganization(@newID integer output)
> as
> insert into organizations( name_long) values( 'Unknown')
> select @newID=@@identity
>
> I am trying to test it with the following script:
>
> Declare @newID integer
> spAddOrganization @newID
> Select @newID
>
> Can anyone tell me what I am doing wrong?
>
> Thanks!
>
>
>