🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.bazy-danych.msaccess
Article #137764

Re: Wartość zwracana przez procedurę SQL

#137764
From: siwy5
Date: Tue, 16 Mar 2021 11:58
78 lines
3930 bytes
piątek, 12 marca 2021 o 22:17:22 UTC+1 wardzyn napisał(a):
> piątek, 12 marca 2021 o 07:01:43 UTC+1 siwy5 napisał(a): 
> > piątek, 12 marca 2021 o 01:21:01 UTC+1 wardzyn napisał(a): 
> > > czwartek, 11 marca 2021 o 14:05:07 UTC+1 siwy5 napisał(a): 
> > > > środa, 10 marca 2021 o 11:59:45 UTC+1 siwy5 napisał(a): 
> > > > > Witam 
> > > > > 
> > > > > Procedura wykonuje się poprawnie ale powinna mi zwrócić wartość (ilośćGodzin) Jak dostać się do zwracanej wartości? 
> > > > > 
> > > > 
> > > > 
> > > > 
> > > > > conn.Execute "TestProcSql 1, 2021, 2", ile 
> > > > > ile zawsze zwraca 1 
> > > > > 
> > > > > Pozdrawiam 
> > > > > Daniel 
> > > > Coś się dogrzebałem - ale nie działa 
> > > > 
> > > > Set cmd = New ADODB.Command 
> > > > cmd.ActiveConnection = cn 
> > > > cmd.CommandType = adCmdStoredProc 
> > > > cmd.CommandText = "proceduraSQL" 'proceduraSQL( @Id int , @Rok int , @Mc int ) 
> > > > 
> > > > cmd.Parameters.Append cmd.CreateParameter("RETURN_VALUE", adInteger, adParamReturnValue, 0) 
> > > > cmd.Parameters.Append cmd.CreateParameter("Id", adInteger, adParamInput, 4, 1) 
> > > > cmd.Parameters.Append cmd.CreateParameter("Rok", adInteger, adParamInput, 4, 2021) 
> > > > cmd.Parameters.Append cmd.CreateParameter("Mc", adInteger, adParamInput, 4, 2) 
> > > > 
> > > > cmd.Execute Options:=adExecuteNoRecords 
> > > > 
> > > > 
> > > > msgbox cmd.Parameters("RETURN_VALUE") 'tu powinna zwrócić wartość ale zwraca 0 
> > > > msgbox cmd.Parameters("PrcId") 
> > > > 
> > > > 
> > > > 
> > > > Pomoże ktoś? 
> > > > 
> > > > Pozdrawiam 
> > > > Daniel 
> > > po pierwsze: 
> > > wrzuć może jak wygląda procedurka. 
> > > Zależy co chcesz odczytać (czyli de facto jak wygląda procedura) - parametr out (adParamOutput) z procedury czy return (adParamReturnValue). 
> > > > cmd.Parameters.Append cmd.CreateParameter("RETURN_VALUE", adInteger, adParamReturnValue, 0) 
> > > to zero na końcu zbędne. 
> > > 
> > > Pozdr 
> > > Wardzyn 
> > Procedura poniżej. Nigdzie nie widze parametrów OUT i RETURN. 
> > Odczytać chcę z niej @Wynik 
> > 
> > ALTER PROCEDURE [db].[proceduraSQL] ( @Id int , @Rok int , @Mc int ) 
> > As 
> > Begin 
> > DECLARE @Wynik int 
> > ... 
> > ... 
> > ... 
> > 
> > select @Wynik = ..... 
> > select @Wynik 
> > END
> w procedurze na końcu zamiast 
> > select @Wynik 
> return @Wynik 
> 
> pozdro 
> 
> Wardzyn




Dzięki serdeczne. Działa z Return-em

Pozdrawiam
Daniel
Technical Details
Message-ID: <38f55759-73e5-4f37-b078-ac643920fd1fn@googlegroups.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!fu-berlin.de!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
References: <588bae08-f9f2-42fa-8580-0e82f7db332bn@googlegroups.com> <4c00d818-c1f8-40fc-a646-be8fab0fe11bn@googlegroups.com> <6f1ebd5b-e7ac-4d22-bd14-991c0a686580n@googlegroups.com> <783ab691-9250-4b67-952c-31fc971637fcn@googlegroups.com> <ff460c04-e64d-4389-aa05-e7ee79618b59n@googlegroups.com>

Show Full Headers
Complete Article Headers
X-Received: by 2002:ae9:f719:: with SMTP id s25mr29811070qkg.42.1615895891436;        Tue, 16 Mar 2021 04:58:11 -0700 (PDT)
X-Received: by 2002:a05:6902:1d2:: with SMTP id u18mr6384065ybh.103.1615895891255; Tue, 16 Mar 2021 04:58:11 -0700 (PDT)
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!fu-berlin.de!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: pl.comp.bazy-danych.msaccess
Date: Tue, 16 Mar 2021 04:58:11 -0700 (PDT)
In-Reply-To: <ff460c04-e64d-4389-aa05-e7ee79618b59n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=78.11.115.26; posting-account=2H1BSAoAAADt5XeMBdV47foqa1rmVY0f
NNTP-Posting-Host: 78.11.115.26
References: <588bae08-f9f2-42fa-8580-0e82f7db332bn@googlegroups.com> <4c00d818-c1f8-40fc-a646-be8fab0fe11bn@googlegroups.com> <6f1ebd5b-e7ac-4d22-bd14-991c0a686580n@googlegroups.com> <783ab691-9250-4b67-952c-31fc971637fcn@googlegroups.com> <ff460c04-e64d-4389-aa05-e7ee79618b59n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <38f55759-73e5-4f37-b078-ac643920fd1fn@googlegroups.com>
Subject: Re: Wartość zwracana przez
 procedurę SQL
From: siwy5 <banasdaniel@poczta.onet.pl>
Injection-Date: Tue, 16 Mar 2021 11:58:11 +0000
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit