Article View: pl.comp.bazy-danych.msaccess
Article #137761Re: Wartość zwracana przez procedurę SQL
From: wardzyn
Date: Fri, 12 Mar 2021 21:17
Date: Fri, 12 Mar 2021 21:17
70 lines
3656 bytes
3656 bytes
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
Technical Details
Message-ID:
<ff460c04-e64d-4389-aa05-e7ee79618b59n@googlegroups.com>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed.pionier.net.pl!goblin2!goblin1!goblin.stu.neva.ru!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mailReferences:
<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>Show Full Headers
Complete Article Headers
X-Received: by 2002:a05:6214:1103:: with SMTP id e3mr210644qvs.12.1615583842082; Fri, 12 Mar 2021 13:17:22 -0800 (PST) X-Received: by 2002:a25:dfd1:: with SMTP id w200mr21706990ybg.362.1615583841873; Fri, 12 Mar 2021 13:17:21 -0800 (PST) Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed.pionier.net.pl!goblin2!goblin1!goblin.stu.neva.ru!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: pl.comp.bazy-danych.msaccess Date: Fri, 12 Mar 2021 13:17:21 -0800 (PST) In-Reply-To: <783ab691-9250-4b67-952c-31fc971637fcn@googlegroups.com> Injection-Info: google-groups.googlegroups.com; posting-host=195.116.75.251; posting-account=Swml4goAAADChmNtrBQ9RwEUf7UIgzZr NNTP-Posting-Host: 195.116.75.251 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> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <ff460c04-e64d-4389-aa05-e7ee79618b59n@googlegroups.com> Subject: Re: Wartość zwracana przez procedurę SQL From: wardzyn <pwardzynski@transroad.com.pl> Injection-Date: Fri, 12 Mar 2021 21:17:22 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit