473,405 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

the best way to: SP B exec SP A where A returns value

I got this:
-------------------------------------------------------------------------
CREATE PROCEDURE A
@Aoutput BIGINT OUTPUT
AS
BEGIN
SET @Aoutput = @Aoutput + 1
END
GO

CREATE PROCEDURE B
@Boutput BIGINT OUTPUT
AS
BEGIN
EXECUTE A @Boutput OUTPUT
END
GO

DECLARE @Ab AS BIGINT
SET @Ab = 3

EXECUTE B @Ab OUTPUT

PRINT @Ab
GO
DROP PROCEDURE A
DROP PROCEDURE B
GO
-------------------------------------------------------------------------

It works great, but cant you do something like:
-------------------------------------------------------------------------
CREATE PROCEDURE A
AS
BEGIN
RETURN 1
END
GO

CREATE PROCEDURE B
AS
BEGIN
DECLARE @B AS BIGINT
SET @B = 3
SET @B = @B + (EXECUTE A)
--AND THEN USE @B = 4 HERE
END
GO
-------------------------------------------------------------------------
Tnx to all in advance
toLucky
Oct 5 '07 #1
2 1394
azimmer
200 Expert 100+
I got this:
-------------------------------------------------------------------------
CREATE PROCEDURE A
@Aoutput BIGINT OUTPUT
AS
BEGIN
SET @Aoutput = @Aoutput + 1
END
GO

CREATE PROCEDURE B
@Boutput BIGINT OUTPUT
AS
BEGIN
EXECUTE A @Boutput OUTPUT
END
GO

DECLARE @Ab AS BIGINT
SET @Ab = 3

EXECUTE B @Ab OUTPUT

PRINT @Ab
GO
DROP PROCEDURE A
DROP PROCEDURE B
GO
-------------------------------------------------------------------------

It works great, but cant you do something like:
-------------------------------------------------------------------------
CREATE PROCEDURE A
AS
BEGIN
RETURN 1
END
GO

CREATE PROCEDURE B
AS
BEGIN
DECLARE @B AS BIGINT
SET @B = 3
SET @B = @B + (EXECUTE A)
--AND THEN USE @B = 4 HERE
END
GO
-------------------------------------------------------------------------
Tnx to all in advance
toLucky
You have a couple of choices:
  1. Make A a FUNCTION instead of a PROCEDURE. (It's OK in your example but it has limitations in general; not that strict, though.)
  2. Introduce a new variable in PROCEDURE B, such as @X, EXECUTE A against @X, then SET @B=@B+@X
Hope it helps.
Oct 6 '07 #2
You have a couple of choices:
  1. Make A a FUNCTION instead of a PROCEDURE. (It's OK in your example but it has limitations in general; not that strict, though.)
  2. Introduce a new variable in PROCEDURE B, such as @X, EXECUTE A against @X, then SET @B=@B+@X
Hope it helps.

well I just deleted the "RETURN" and replaced it with "SELECT" - and now i can do what ever i want to :)
Your solution is ok tho :D
Oct 10 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: Piotr Wolski | last post by:
can anyone help me: using exec() function in PHP i can execute linux programms like ls,who and other, however i can not execute C programms and i really don't know why. Please help me, Peter
2
by: tedsuzman | last post by:
----- def f(): ret = 2 exec "ret += 10" return ret print f() ----- The above prints '12', as expected. However,
0
by: Jan | last post by:
I store sql-commands in a database table. In the first step I get the sql command out of the database table with embedded sql. In the second step I try to execute the command, which i got from the...
6
by: philipdm | last post by:
I am building a SQL statement that returns a number. when I execute the Built SQL statment EXEC(@Build). What I need to do now is take that number that comes back and store it in another variable...
17
by: comp.lang.tcl | last post by:
The TCL command I am using will do a command-line action on a PHP script: set cannotRunPHP I have to do it this way as both the TCL script and the PHP script run as CLI. However, "info.php"...
1
by: Crazy Cat | last post by:
Hi, whenever the underlying query being called by EXEC in the following has an empty result set I get the following error -- Invalid Data for 'Numeric' when EXEC returns empty row. However if I...
2
by: Uldis Bojars | last post by:
Hi All, I have encountered problems with JS RegExp.exec() and can't find what is the problem. Could you help me? formRequest is a function that extracts some information from XMLHTTPRequest...
26
by: warth33 | last post by:
Hello I have a php site. Some page needs to call an external program. The programs are home made c# applications. It uses to work without problem. For a while. Maybe it work for some hour....
23
by: Maarten | last post by:
Howdy, Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and I have a little problem with one function within my cd-management script. For extracting a bit of info from my...
0
by: salavatomas | last post by:
create function dbo.fnc_varchar_columns_alltrim () returns @vysledek table ( tabulka sysname null, sloupec sysname null, pocet_zaznamu int null, datovy_typ varchar(256) null ) as
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.