take a step back you nonce... ;-) its not for any application its for a sample app in-house to generate who makes the tea next.
And personally I would use sp's as much as I can...I hate inline sql (now) -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 17 July 2003 12:45 To: [EMAIL PROTECTED] Subject: RE: [ cf-dev ] random variable selection.. I have to say that's got to be the most pointless use of a stored procedure. This is the reason why I really hate developers using stored procedures in their applications! Nine times out of ten, when you look at what the SP has been set up to do you discover there was really no need to give it to the DB server to do and all they've managed to do is generate code that is virtually unreadable, impossible to move and virtually impossible to use. Just because you can doesn't mean you should! <cfscript> varlist = "varone,vartwo,varthree,varfour"; selectedvar = ListGetAt(varlist,RandRange(1,ListLen(VarList))); varcontent = variables[selectedvar]; </cfscript> Stephen ---- Message from Adrian Lynch <[EMAIL PROTECTED]> at 12:39:15 2003-07-17 ------ >Opps, this will work better... > > > DECLARE > @one INT, > @two INT, > @three INT, > @theChosenOne INT, > @var INT > > SELECT @one = 1, @two = 2, @three = 3 > > SELECT @theChosenOne = > CASE SELECT CAST(RAND() * 3 AS INT) + 1 > WHEN 1 THEN @one > WHEN 2 THEN @two > WHEN 3 THEN @three > END > > SELECT @theChosenOne > >I get back 1, 2 or 3 now > >Enjoi > >Ade > >-----Original Message----- >From: Adrian Lynch [mailto:[EMAIL PROTECTED] >Sent: 17 July 2003 12:37 >To: '[EMAIL PROTECTED]' >Subject: RE: [ cf-dev ] random variable selection.. > > >You'll need to play about with the RAND() bit as I was getting back NULL >some of the time. But this assigns the value of @one, @two or @three to >@theOne. > > DECLARE > @one INT, > @two INT, > @three INT, > @theOne INT > > SELECT > @one = 1, > @two = 2, > @three = 3 > > SELECT @theOne = > CASE CAST(RAND() * 4 AS INT) > WHEN 1 THEN @one > WHEN 2 THEN @two > END > > SELECT @theOne > > >Ade > >-----Original Message----- >From: Robertson-Ravo, Neil (RX) >[mailto:[EMAIL PROTECTED] >Sent: 17 July 2003 12:19 >To: '[EMAIL PROTECTED]' >Subject: [ cf-dev ] random variable selection.. > > >I am having a real brain fuzz this morning.... >anyone got an example of how I can create an sp which has say 10 predefined >vars in it : > >a,b,c,d etc..... and then runs a routine to select a random one? > > >-- >** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ > >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >For human help, e-mail: [EMAIL PROTECTED] > >-- >** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ > >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >For human help, e-mail: [EMAIL PROTECTED] > >-- >** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ > >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >For human help, e-mail: [EMAIL PROTECTED] > -- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED]
