Using SQL Server 2000...
I wrote a wrapper to call a sub proc (code provided below). The
intended varchar value returned in the output parameter of each proc
is a string implementation of an array.
(The string separates elements by adding a period after each value.
e.g. 1. 2. 3. 4. 5. etc., although my simplified example only creates
two elements.)
My vb.net calling code parses the returned string into individual
elements.
I TESTED BOTH PROCS FIRST:
The wrapper returns 'hello' when I test it by inserting
SELECT @lString='hello '
before the GO, so I believe it is called properly.
The sub_proc returns the "array" I want when I call it directly.
THE PROBLEM: When I call the wrapper, and expect it to call sub_proc,
it returns a zero.
In fact, when I assign a literal (like 'hello') to @lString in
sub_proc, 'hello' is not returned.
So the wrapper is not calling the sub_proc, or the sub_proc is not
returning an output value.
OR...I have read about some issues with OUTPUT string parameters being
truncated or damaged somehow when passed. I doubt this is the
problem, but I'm open to anything.
I want to use the wrapper because, when it's finally working, it will
call several sub_procs and
return several output values.
Any thoughts? Thanks for looking at it! - Bob
The Wrapper:
-----------------------------------------------------------------
CREATE PROCEDURE wrapper
@lString varchar(255) OUT
AS
EXEC @lString = sub_proc @CommCode, @lString OUT
GO
-----------------------------------------------------------------
The subordinate procedure:
-----------------------------------------------------------------
CREATE PROCEDURE sub_proc
@lString varchar(255) OUT
AS
DECLARE @var1 int,
@var2 int
SELECT @var1 =
(SELECT count(mycolumn)
FROM mytable
WHERE condition=1)
SELECT @var2 =
(SELECT count(mycolumn)
FROM mytable
WHERE condition=2)
/* If @var1 returns 5 and @var2 returns 7, Then @lString below would
be "5. 7." */
SELECT @lString = STR(@var1) + '.' + STR(@var7) + '.'
GO
----------------------------------------------------------------- 3 2274
On Sep 27, 3:36 pm, bobc <bcana...@fmbne whomes.comwrote :
Using SQL Server 2000...
I wrote a wrapper to call a sub proc (code provided below). The
intended varchar value returned in the output parameter of each proc
is a string implementation of an array.
(The string separates elements by adding a period after each value.
e.g. 1. 2. 3. 4. 5. etc., although my simplified example only creates
two elements.)
My vb.net calling code parses the returned string into individual
elements.
I TESTED BOTH PROCS FIRST:
The wrapper returns 'hello' when I test it by inserting
SELECT @lString='hello '
before the GO, so I believe it is called properly.
The sub_proc returns the "array" I want when I call it directly.
THE PROBLEM: When I call the wrapper, and expect it to call sub_proc,
it returns a zero.
In fact, when I assign a literal (like 'hello') to @lString in
sub_proc, 'hello' is not returned.
So the wrapper is not calling the sub_proc, or the sub_proc is not
returning an output value.
OR...I have read about some issues with OUTPUT string parameters being
truncated or damaged somehow when passed. I doubt this is the
problem, but I'm open to anything.
I want to use the wrapper because, when it's finally working, it will
call several sub_procs and
return several output values.
Any thoughts? Thanks for looking at it! - Bob
The Wrapper:
-----------------------------------------------------------------
CREATE PROCEDURE wrapper
@lString varchar(255) OUT
AS
EXEC @lString = sub_proc @CommCode, @lString OUT
GO
-----------------------------------------------------------------
The subordinate procedure:
-----------------------------------------------------------------
CREATE PROCEDURE sub_proc
@lString varchar(255) OUT
AS
DECLARE @var1 int,
@var2 int
SELECT @var1 =
(SELECT count(mycolumn)
FROM mytable
WHERE condition=1)
SELECT @var2 =
(SELECT count(mycolumn)
FROM mytable
WHERE condition=2)
/* If @var1 returns 5 and @var2 returns 7, Then @lString below would
be "5. 7." */
SELECT @lString = STR(@var1) + '.' + STR(@var7) + '.'
GO
-----------------------------------------------------------------
Correction: delete "@CommCode, " from the EXEC statement in wrapper.
Should read as follows:
EXEC @lString = sub_proc @lString OUT
It's been a long day. -BobC
bobc (bc******@fmbne whomes.com) writes:
The Wrapper:
-----------------------------------------------------------------
CREATE PROCEDURE wrapper
@lString varchar(255) OUT
AS
EXEC @lString = sub_proc @CommCode, @lString OUT
GO
Remove "@lString =". The return value from a stored procedure is
always integer, and customary you use it to return success/failure
indication, with 0 meaning success.
DECLARE @var1 int,
@var2 int
SELECT @var1 =
(SELECT count(mycolumn)
FROM mytable
WHERE condition=1)
SELECT @var2 =
(SELECT count(mycolumn)
FROM mytable
WHERE condition=2)
Rather you can do:
SELECT @lString =
ltrim(str(SUM(C ASE condition WHEN 1 THEN 1 ELSE 0 END)) + '.' +
ltrim(str(SUM(C ASE condition WHEN 2 THEN 1 ELSE 0 END)) + '.' +
...
ltrim(str(SUM(C ASE condition WHEN 7 THEN 1 ELSE 0 END))
FROM mytable
WHERE mycolumn IS NOT NULL
AND condition BETWEEN 1 AND 7
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx
On Sep 27, 5:38 pm, Erland Sommarskog <esq...@sommars kog.sewrote:
bobc (bcana...@fmbne whomes.com) writes:
The Wrapper:
-----------------------------------------------------------------
CREATE PROCEDURE wrapper
@lString varchar(255) OUT
AS
EXEC @lString = sub_proc @CommCode, @lString OUT
GO
Remove "@lString =". The return value from a stored procedure is
always integer, and customary you use it to return success/failure
indication, with 0 meaning success.
DECLARE @var1 int,
@var2 int
SELECT @var1 =
(SELECT count(mycolumn)
FROM mytable
WHERE condition=1)
SELECT @var2 =
(SELECT count(mycolumn)
FROM mytable
WHERE condition=2)
Rather you can do:
SELECT @lString =
ltrim(str(SUM(C ASE condition WHEN 1 THEN 1 ELSE 0 END)) + '.' +
ltrim(str(SUM(C ASE condition WHEN 2 THEN 1 ELSE 0 END)) + '.' +
...
ltrim(str(SUM(C ASE condition WHEN 7 THEN 1 ELSE 0 END))
FROM mytable
WHERE mycolumn IS NOT NULL
AND condition BETWEEN 1 AND 7
--
Erland Sommarskog, SQL Server MVP, esq...@sommarsk og.se
Books Online for SQL Server 2005 athttp://www.microsoft.c om/technet/prodtechnol/sql/2005/downloads/books...
Books Online for SQL Server 2000 athttp://www.microsoft.c om/sql/prodinfo/previousversion s/books.mspx
Thanks very much, Erland! -BobC This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rhino |
last post by:
I am trying to verify that I correctly understand something I saw in the DB2
Information Center.
I am running DB2 Personal Edition V8.2.1 on Windows. I came across the
following in the Info Center:
To return a result set from a procedure to the originating application, use
the WITH RETURN TO CLIENT clause. When WITH RETURN TO CLIENT is specified on
a result set, no nested procedures can access the result set.
|
by: orencs |
last post by:
Hi,
I am using Datareader and stored procedure in C# ADO.NET.
When I am running the stored procedure in the SQL Query Analyzer and
recieve two rows (as I hace expected)
col1 col2
0 1
0 2
4 2
|
by: Peter |
last post by:
Hi, there
I have created an stored procedure using the DDL below for my MS Access
Database and no error occurs. Also it can create an stored procedure if I
changed the parameter from "" to ""@zSampleName".
OleDbcmd.CommandText = _
"CREATE PROCEDURE udpGetSampleIDByName" & vbCrLf & _
"( VarChar(64))" & vbCrLf & _
"AS" & vbCrLf & _
|
by: Fir5tSight |
last post by:
Hi All,
I have a C#.NET code as follows:
private void ScanInput_KeyPress(object sender,
System.Windows.Forms.KeyPressEventArgs e)
{
try
{
Row lRow = this.Connection.InsertScannedFile(ID);
|
by: Mick Walker |
last post by:
Hi Everyone,
I am stumped here. I have the following stored proceedure:P
CREATE PROCEDURE .
@SupplierSKU varchar(50),
@RetVal int
AS
Select @Retval = count(*) from dbo.ImportLines
Where = @SupplierSKU
| |
by: bobc |
last post by:
In my stored procedure, I want to parse @ArrayOfDays into @d1 through
@d5.
@ArrayOfDays is a varchar input parameter containing,
for example, "1.7.21.25.60." - five elements.
Most active vars:
@i - loop counter
@char - current char in string
@tempVal - contains the current element as it is being built
|
by: Lin100 |
last post by:
Access ADP and Stored Procedure Did not Return Any Records
Access 2002 and SQL 2000 Server
I have a form named "Selector", and it have four combo boxes and a subform named
Q_FilteringQuery_subform. When any of the combo box is selected, the code will
call a VBA procedure which will then activate the stored procedure named Get_Records_For_Selector_Form.
When I first select an item from the combo box Dept while all three other combo boxes...
|
by: E11esar |
last post by:
Hi there.
I have written a C# web service that calls an Oracle stored procedure. The SP is a simple select-max query and the table it is getting the value from has about 2.8 million rows in it. The field being MAX'd is an index field in the table. I have further ensured that the table has had an analysis and rebuild run on it to ensure good integrity but still I am finding the stored procedure takes around 3 minutes to return the MAX...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |