[thelist] cfprocparam

Rory.Plaire at wahchang.com Rory.Plaire at wahchang.com
Thu Oct 18 13:32:18 CDT 2001


Raymond replied:

| Actually, you don't if your using CF5. You can use the connectstring
| attribute instead. I haven't use this, but it should work.
| 
| Should. ;)

Right, but the connectionstring is also passed to an ODBC handler, right? In
the documentation it is. It is in ODBC format (i.e. like, {driver=SQL
Server; server=serverName; database=databaseName; uid=noo; pwd=buz;}). 

An OLEDB connection looks different, like: "Provider=SQLOLEDB;Data
Source=serverName;Initial Catalog=databaseName; User ID=noo;Password=buz;"

Could I, perhaps, pass either? I guess, likely without need, I'm just
concerned that CF needs to use ODBC or access the registry or some other
performance killing fixation.

| Evolt is, without a doubt, the best list I've ever been on. 
| In fact, I'm
| kinda shy about telling others since I don't want the list get _too_
| popular. ;)

+1

Systems dynamics modelers consider what happens to whole systems and model
it. One of the patterns, or archetypes, which is prevalent among most
systems is the "Tragedy of the Commons" archetype. Really the only way to
offset the dynamics of diminishing shared resources is fair legislation, an
understanding moderation, and universal participation. I think about this in
the car while commuting, and then hold hope, too, that the quality of the
evolt community remains, or even increases.

For instance, that should have been on thechat.

So, a tip:

<tip type="Effective SQL Server Stored Procedures" author="rory">

When performing an insert, update, or delete in a Stored Procedure with MS
SQL Server (similar techniques should be available for most DBMSs), you can
check if any rows were affected, and thus the success of the operation, my
the following line, at the end of the SP.

SELECT @@rowcount as Success

This returns a result set, which looks like this:

Success
-------
1

@@rowcount is the number of rows affected by the last operation.

*BE CAREFUL*, though, of this:

----------------------------
DELETE FROM	tblStuff
WHERE		Stuff
=			@mystuff

IF(@anotherparam IS NOT NULL)
	SELECT	Somewhere
	FROM		Anywhere
	WHERE	Somewhere
	<>		'here'

SELECT	@@rowcount AS Success
----------------------------

since @@rowcount will report the number of rows affected by a SELECT
statement, too. IF is internally treated like a SELECT statement in SQL
Server, so even checking the variable will result in corruption of the
@@rowcount you wanted.

Instead, assign @@rowcount to a local variable, and then SELECT that as
Success.

Like this:
----------------------------
DECLARE @success

DELETE FROM	tblStuff
WHERE		Stuff
=			@mystuff

SET	@success = @@rowcount

IF(@anotherparam IS NOT NULL)
	SELECT	Somewhere
	FROM		Anywhere
	WHERE	Somewhere
	<>		'here'

SELECT	@success AS Success
----------------------------
</tip>

<rory disposition="happy and content (I can fake it till I make it)"
alt="8)"/>




More information about the thelist mailing list