Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
scripts
hosting
jscript
remote
scripting.wsh
scriptlets
vbscript
virus.discussion
  
 
date: Wed, 20 Aug 2008 00:52:37 -0700 (PDT),    group: microsoft.public.scripting.vbscript        back       


How can a Record type be returned by a stored procedure?   
Hi All,

I want to know, if i can define a recordType in the
createParameter().
Currently i am using the following code
    .Parameters.Append .CreateParameter("date_diff_days", 3, 1)
3- is for Integer,

I would like to know if there is a number for recordType? How can i
fetch the record that is returned by the stored procedure?

Thanks
Deepal
date: Wed, 20 Aug 2008 00:52:37 -0700 (PDT)   author:   unknown

Re: How can a Record type be returned by a stored procedure?   
deepal.82@gmail.com wrote:
> Hi All,
>
> I want to know, if i can define a recordType in the
> createParameter().
> Currently i am using the following code
>    .Parameters.Append .CreateParameter("date_diff_days", 3, 1)
> 3- is for Integer,
>
> I would like to know if there is a number for recordType? How can i
> fetch the record that is returned by the stored procedure?
>
What database? Type and version please.

In SQL Server, there is no "Record" type. You have to use a SELECT statement 
to return a resultset.
I suppose you could return xml in an output parameter ....

-- 
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
date: Wed, 20 Aug 2008 06:56:52 -0400   author:   Bob Barrows [MVP] com

Re: How can a Record type be returned by a stored procedure?   
I have a stored procedure that returns fetches two columns from a
table. It is goin to return a single row.
Will i be getting only 1 parameter is return (This will be a record
set and from there i need to fetch the two columns)
or would i be returned 2 out parameters ?
In my stored procedure i will have the query as below
                select a, b from pqr
date: Wed, 20 Aug 2008 04:21:58 -0700 (PDT)   author:   unknown

Re: How can a Record type be returned by a stored procedure?   
deepal.82@gmail.com wrote:
> I have a stored procedure that returns fetches two columns from a
> table. It is goin to return a single row.
> Will i be getting only 1 parameter is return (This will be a record
> set and from there i need to fetch the two columns)
> or would i be returned 2 out parameters ?
> In my stored procedure i will have the query as below
>                 select a, b from pqr

It appears you are using SQL Server ...??? Why are you making me guess?

************************************************************************
******
There are 3 ways to return values from a SQL Server stored procedure:
1. a Select statement that returns a resultset
--run this script in Query Analyzer (QA):
Create Procedure SelectValue
(@input    int)
AS
Select @input + 5
go
exec SelectValue 10
go
drop procedure SelectValue

2. a Return parameter:
--run this script in QA:
create procedure ReturnValue
(@input    int)
AS
Return @input + 5
go
declare @returnvalue    int
exec @returnvalue = ReturnValue 10
select @returnvalue
go
drop procedure ReturnValue


3. an Output Parameter:
--run this script in QA:
create procedure OutputValue
(@input    int output)
AS
SET @input = @input + 5
go
declare @outputvalue int
SET @outputvalue = 10
exec  OutputValue @outputvalue output
select @outputvalue
go
drop procedure OutputValue


I do not recommend method 1 for returning a single value. A resultset is
expensive to build, in that it must contain metadata in addition to
data. So
more network traffic is created, and the client app needs to expend more
resources in order to retrieve and expose the resultset to the calling
procedure.


Most developers use the Return parameter to return status codes instead
of
data. This is for the sake of consistency: there is no technical reason
not
to use RETURN to return data, except that RETURN can only be used to
return
integers. If you need to return other datatypes, you need to use an
output
parameter.
************************************************************************
******


So, if you use a resultset (option 1), in vbscript you would open a
recordset. I cannot get more specific than that given the lack of
information.

Read this:
http://groups.google.com/group/microsoft.public.inetserver.asp.general/msg/5d3c9d4409dc1701?hl=en

-- 
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
date: Wed, 20 Aug 2008 11:06:30 -0400   author:   Bob Barrows [MVP] com

Re: How can a Record type be returned by a stored procedure?   
hi..
sorry for misleading you.
I used a recordSet and got the data from the stored procedure. It
works fine.
The code is as belo

set objCmd = CreateObject("ADODB.Command")
set rs = CreateObject("ADODB.RecordSet")

    With objCmd
        .ActiveConnection = Scn
        .commandtimeout = 9000
        .CommandText = "StoredProcedure"
        .CommandType = 4
        .Parameters.Append .CreateParameter("date_diff_days", 3, 1)
        .Parameters("date_diff_days") = date_diff_days
    End With

    'stored procedure is executed
    Set rs =objCmd.Execute

    'data is fetched from the recordset
    If Not rs.EOF Then
       outTotalConfigId = rs.Fields(0)
       outTotalBundleId = rs.Fields(1)
    End If

Thanks for the help
date: Thu, 21 Aug 2008 02:26:31 -0700 (PDT)   author:   unknown

Re: How can a Record type be returned by a stored procedure?   
deepal.82@gmail.com wrote:
> hi..
> sorry for misleading you.
I'm glad you got it working, but "mislead" is the wrong word ... one can't 
be mislead when one isn't led at all <grin>


-- 
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
date: Thu, 21 Aug 2008 18:57:17 -0400   author:   Bob Barrows [MVP] com

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us