Ask a Question related to ASP Database, Design and Development.
-
Ray at #1
Stored procs and command objects
Person asks:
I've been coding up a storm for a project the last couple weeks and
have been looking for unrelated information - when I discovered that
the folks at [url]www.aspfaq.com[/url] recommend against using the command object
to do stored procedures. No 'meat and potatoes' explanation is given
other than "it's another object you have to deal with" and "it can be
done more simply using rs.execute"
I try pretty hard to code according to the recommendations of those
people I respect, like Adrian, but this just seems 'out there.'
The SP's I'm dealing with take as many as 20 parameters and I just
don't see how using cn.execute would be easier, or eliminating that
single object could reduce the code complexity. Am I just missing
something or is this just a bad example of where it doesn't really
apply to my use.
[member of active-server-pages group at Yahoo groups]
My response:
I've always taken it to be suggested simply for the sake of not creating
unnecessary overhead.
Is there more to it than that though?
Thanks,
Ray at home
Ray at Guest
-
Stored Procs
What are the different ways to fire stored procedures in a SQL 2000 server? Which is better? I have seen simply: set rs = conn.execute("sproc") ... -
Stored Procs Compiling
I'm using db2 8.1 with the latest service pack on Windows 2k and XP, both with latest service packs. I have Visual Studio 6 installed with latest... -
SQL stored procs in 8.1
I was told ver DB2 8.1 has got SQL stored proc support (unlike earlier versions where we had only the concept of expternal stored procs which need... -
Help Managing Java Stored Procs
This is sort of a followup to my last post about applicatino best practices using DB2 as a back end. Since it looks like I'm not going to get rid... -
Stored Outlines For Queries In PL/SQL Stored Procs
Hi, Oracle 8.1.7.3 SunOS 5.7 I would like to know how to create stored outlines for some queries I have in stored procedures. The queries may... -
Ken Schaefer #2
Re: Stored procs and command objects
Personally I think you should use Command objects. I believe it makes for
more robust, and more readable code.
On the other hand, Aaron disagrees...
I also think you should use named ADO constants, rather than "magic numbers"
Aaron disagrees with this too.
Cheers
Ken
"Ray at <%=sLocation%>" <myfirstname at lane 34 . komm> wrote in message
news:OXureWqkDHA.1728@TK2MSFTNGP11.phx.gbl...
: Person asks:
:
: I've been coding up a storm for a project the last couple weeks and
: have been looking for unrelated information - when I discovered that
: the folks at [url]www.aspfaq.com[/url] recommend against using the command object
: to do stored procedures. No 'meat and potatoes' explanation is given
: other than "it's another object you have to deal with" and "it can be
: done more simply using rs.execute"
:
: I try pretty hard to code according to the recommendations of those
: people I respect, like Adrian, but this just seems 'out there.'
:
: The SP's I'm dealing with take as many as 20 parameters and I just
: don't see how using cn.execute would be easier, or eliminating that
: single object could reduce the code complexity. Am I just missing
: something or is this just a bad example of where it doesn't really
: apply to my use.
:
: [member of active-server-pages group at Yahoo groups]
:
:
: My response:
: I've always taken it to be suggested simply for the sake of not creating
: unnecessary overhead.
:
:
: Is there more to it than that though?
:
: Thanks,
:
: Ray at home
:
:
Ken Schaefer Guest
-
Ray at #3
Re: Stored procs and command objects
"Ken Schaefer" <kenREMOVE@THISadOpenStatic.com> wrote in message
news:eeW5WDtkDHA.2272@tk2msftngp13.phx.gbl...That is funny.> Personally I think you should use Command objects. I believe it makes for
> more robust, and more readable code.
>
> On the other hand, Aaron disagrees...
I go both ways (like, on this matter, not in any other way). There are
times that I will sacrifice efficiency for readability, and sometimes I
won't. I tend to only code explicitly if I am still unfamiliar with the
technology. Once I get familiar with it, I sacrifice readability. Then I
don't use it for a year, go back to change something, and have no idea what
the hell my code is doing. ;]
numbers">
> I also think you should use named ADO constants, rather than "magicI'll have to go with Aaron on this one. IMO, it's best to memorize all the>
> Aaron disagrees with this too.
constants, just like you should have the ascii chart memorized.
Ray at home
Ray at Guest
-
Ken Schaefer #4
Re: Stored procs and command objects
"Ray at <%=sLocation%>" <myfirstname at lane 34 . komm> wrote in message
news:e4KSjHtkDHA.3316@tk2msftngp13.phx.gbl...
:
: > I also think you should use named ADO constants, rather than "magic
: numbers"
: >
: > Aaron disagrees with this too.
:
: I'll have to go with Aaron on this one. IMO, it's best to memorize
: all the constants, just like you should have the ascii chart
: memorized.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
That's nonsense. (both the bit about memorising constants, and the bit about
knowing the ASCII chart).
I'm supposed to have memorised every single constant value for every single
piece of code that I write -or- that I review? What about projects where I'm
pulled in to do maintenance work? (I had to do some code for a project
produces reports in Microsoft Word - do you know how many constants there
are in Word VBA?). Imagine if the original developer had decided to use
"magic numbers" for everything. I'd be spending half my time looking in MSDN
trying to find out what they meant.
ANY programming course that you do tells you not to use "magic numbers"
(that's why they are called "magic numbers"). And that rule's been around
for a lot longer than ADO.
Things that should be memorised are things that you need to use often (for
example, I have lots of details of the TCP/IP protocol memorised, as well as
the ISO OSI model etc - doesn't mean everyone should. Nor should everyone
have to memorise the ACSII chart) . Furthermore, that doesn't mean that you
should use the numbers in code.
Cheers
Ken
Ken Schaefer Guest
-
Ray at #5
Re: Stored procs and command objects
"Ken Schaefer" <kenREMOVE@THISadOpenStatic.com> wrote in message
news:%23bUF6OtkDHA.1800@TK2MSFTNGP10.phx.gbl...about>
> "Ray at <%=sLocation%>" <myfirstname at lane 34 . komm> wrote in message
> news:e4KSjHtkDHA.3316@tk2msftngp13.phx.gbl...
> :
> : > I also think you should use named ADO constants, rather than "magic
> : numbers"
> : >
> : > Aaron disagrees with this too.
> :
> : I'll have to go with Aaron on this one. IMO, it's best to memorize
> : all the constants, just like you should have the ascii chart
> : memorized.
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> That's nonsense. (both the bit about memorising constants, and the bitWhen I got my first computer and a copy of VB, I read "Visual Basic 5 for> knowing the ASCII chart).
>
Dummies." I think in the first chapter, it said something about memorizing
the ASCII chart. I thought it was nonsense too, but the book was right; I
was wrong. I'm still working on memorizing it though. ;] But, I know the
ones I use often like ®, °, ß, ×, etc.
single> I'm supposed to have memorised every single constant value for everyYes. Okay, kidding. But, for the things that you work with often, like> piece of code that I write -or- that I review?
ForReading, ForWriting, etc.But if you were a Word programmer, you'd know many of them. I think I went> What about projects where I'm
> pulled in to do maintenance work? (I had to do some code for a project
> produces reports in Microsoft Word - do you know how many constants there
> are in Word VBA?).
wrong when I said memorize "all" the constants. Let me take that back and
say that you should memorize the ones you use often.
Imagine if the original developer had decided to useMSDN> "magic numbers" for everything. I'd be spending half my time looking inThat's true, but if you have reference materials, it only takes a second to> trying to find out what they meant.
look at what values are expected, and what they mean.
Rules. Pffft.>
> ANY programming course that you do tells you not to use "magic numbers"
> (that's why they are called "magic numbers"). And that rule's been around
> for a lot longer than ADO.
as>
> Things that should be memorised are things that you need to use often (for
> example, I have lots of details of the TCP/IP protocol memorised, as wellUnless they have the need.> the ISO OSI model etc - doesn't mean everyone should.
you> Nor should everyone
> have to memorise the ACSII chart) . Furthermore, that doesn't mean that~I~ should. But one should use whatever he prefers. I prefer numbers.> should use the numbers in code.
Ray at home
Ray at Guest
-
Bob Barrows #6
Re: Stored procs and command objects
Ray at <%=sLocation%> wrote:
If you want to use output parameters, or you need to read the value of the> Person asks:
>
> I've been coding up a storm for a project the last couple weeks and
> have been looking for unrelated information - when I discovered that
> the folks at [url]www.aspfaq.com[/url] recommend against using the command object
> to do stored procedures. No 'meat and potatoes' explanation is given
> other than "it's another object you have to deal with" and "it can be
> done more simply using rs.execute"
>
> I try pretty hard to code according to the recommendations of those
> people I respect, like Adrian, but this just seems 'out there.'
>
> The SP's I'm dealing with take as many as 20 parameters and I just
> don't see how using cn.execute would be easier, or eliminating that
> single object could reduce the code complexity. Am I just missing
> something or is this just a bad example of where it doesn't really
> apply to my use.
>
> [member of active-server-pages group at Yahoo groups]
>
>
> My response:
> I've always taken it to be suggested simply for the sake of not
> creating unnecessary overhead.
>
>
> Is there more to it than that though?
>
return parameter, you HAVE to use a Command object. I am a strong advocate
of using output parameters as opposed to returning values in recordsets when
cursor functionality is not needed. It cuts down on network traffic due to
not needing to pass metadata as well as data to the client, and resource
utilization, due to not requiring a cursor to be built to process the
returned data.
If that functionality (output/return parameters) is not required, then I
would still prefer a Command object if the procedure-as-connection-method
technique was not supported, due to the strong parameter typing provided by
the Parameters collection (bulletproof protection against sql injection) and
the avoidance of the need to escape certain string characters in the
parameter values being passed.
I think everyone here knows my preference for the
procedure-as-connection-method technique.
Aaron prefers the dynamic sql technique due to the ability to resonse.write
it if there are problems, making it easier to troubleshoot. I admit he has a
point here: I have to fire up SQL Profiler if I'm having a problem (which is
rare <grin> ). But I still prefer to avoid the overhead of string
concatenation and Replace statements required to build these strings.
Bob Barrows
--
HTH,
Bob Barrows - ASP MVP
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.
Bob Barrows Guest
-
Bob Barrows #7
Re: Stored procs and command objects
Ray at <%=sLocation%> wrote:
LOL>
> I'll have to go with Aaron on this one. IMO, it's best to memorize
> all the constants, just like you should have the ascii chart
> memorized.
>
Right! And comments!!! Comments are for sissies! No real programmer comments
his code. :-)
--
HTH,
Bob Barrows - ASP MVP
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.
Bob Barrows Guest
-
Ray at #8
Re: Stored procs and command objects
"Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
news:ON73BuxkDHA.2216@TK2MSFTNGP12.phx.gbl...comments> Ray at <%=sLocation%> wrote:> LOL> >
> > I'll have to go with Aaron on this one. IMO, it's best to memorize
> > all the constants, just like you should have the ascii chart
> > memorized.
> >
> Right! And comments!!! Comments are for sissies! No real programmerHey now, comment are a whole other story. I comment man!> his code. :-)
>
Do you have to go to the phone book to call your mother, or do you just know
her number?
Ray at work
Ray at Guest
-
Bob Barrows #9
Re: Stored procs and command objects
Ray at <%=sLocation%> wrote:
You ARE serious! :-0> "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
> news:ON73BuxkDHA.2216@TK2MSFTNGP12.phx.gbl...>>> Ray at <%=sLocation%> wrote:>> LOL>>>
>>> I'll have to go with Aaron on this one. IMO, it's best to memorize
>>> all the constants, just like you should have the ascii chart
>>> memorized.
>>>
>> Right! And comments!!! Comments are for sissies! No real programmer
>> comments his code. :-)
>>
> Hey now, comment are a whole other story. I comment man!
>
> Do you have to go to the phone book to call your mother, or do you
> just know her number?
>
No, I did not have to go to the phone book for my mother's number, but
neither did I tell somebody who asked for her number to go look it up :-)
Or, better analogy: I never sent somebody a phone number and told them to
look up the name of the person in the phone book.
I use constants all the time. Not only are they helpful for me, but they
will help the guy who has to maintain my code when I leave. Personally, I
hate maintaining/reading code that contains magic numbers.
Besides, I've got better use for my brainpower than memorizing a lot of
magic numbers. Maybe if I wasn't using VID for development, where the
intellisense autocompletes all my constants, in addition to giving me lists
to pick from ... but even then, I would still use constants. It's not like
they're impacting performance: the compiler resolves all constants at
compile-time, so they do not affect performance at run-time.
--
HTH,
Bob Barrows - ASP MVP
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.
Bob Barrows Guest
-
Ray at #10
Re: Stored procs and command objects
> You ARE serious! :-0
Yeah.
That's funny. :] Point well taken.>
> I never sent somebody a phone number and told them to
> look up the name of the person in the phone book.
Ray at work
Ray at Guest
-
Ray at #11
Re: Stored procs and command objects
You know, if I didn't suck at analogies, I'd be able to argue my point
better. Here is my weak attempt.
Prior to life as a programmer, I spent the majority of my time working on my
cars. I never complained about bolts not being labeled as to their size.
At first, you'd just grab a few sockets that looked close to the size, or if
you really wanted to waste time, you'd look up the size in a Chilton's
manual or something. But, after time, you get to know the size just by
looking at it. Either that, are you remember what bolts are what size, and
if they're metric or SAE. Like I said, I suck at analogies. But I guess
what I'm saying is I'm more interested in knowing the values and having
those values be in my head as second nature.
00820097012100320097011600320119011101140107
"Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
news:uQRBStykDHA.2012@TK2MSFTNGP12.phx.gbl...
lists>
> No, I did not have to go to the phone book for my mother's number, but
> neither did I tell somebody who asked for her number to go look it up :-)
> Or, better analogy: I never sent somebody a phone number and told them to
> look up the name of the person in the phone book.
>
> I use constants all the time. Not only are they helpful for me, but they
> will help the guy who has to maintain my code when I leave. Personally, I
> hate maintaining/reading code that contains magic numbers.
>
> Besides, I've got better use for my brainpower than memorizing a lot of
> magic numbers. Maybe if I wasn't using VID for development, where the
> intellisense autocompletes all my constants, in addition to giving me> to pick from ... but even then, I would still use constants. It's not like
> they're impacting performance: the compiler resolves all constants at
> compile-time, so they do not affect performance at run-time.
>
> --
> HTH,
> Bob Barrows - ASP MVP
> 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.
>
>
Ray at Guest



Reply With Quote

