- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
This so reminds me of some code from a company I worked for which looked like this (not exact code)
select * from table
while not eof
select * from table2
while not eof
if table1.id=table2.id then getinfo(id)
end
end
getinfo:
select * from table
while not eof
if table.id=id then returnstring=something
end
return returnstring
so... given that the db language in case had joins, indexes, and table1 was already positions.......... and this was being run on like 200k lines long etc..
needless to say, took hours.
Admin
Ouch! Its code like this that makes my eyes bleed!
Admin
There's no problem with this. As this is C#, the record is not an object but rather a reference to an object; no new objects are created. Also, I know the SUN's Java compiler would optimize this out so that the same place in the stack would be used on each iteration; I would assume that the C# compiler would do the same.
Admin
Do'h. This was in response to a previous post about how the ResultRecord record was being created on each iteration through the loop.
Admin
record is a stack variable, no extra space is allocated inside the loop. It only takes a small amount of memory to hold a reference to an object.
Admin
Dude...and I thought some of my jobs were bad. I would tell the CTO to go fuck himself if he asked that. Management that dumb shouldn't be involved in the technical process.
Admin
If you're doing it in c# maybe you don't know that a System.Data.DataSet has a Select() method that will let you get the row(s) you need without a loop.
Admin
I thought you looked familiar!
Admin
bahahahahahahahahahahaha
Admin
You could implement Rijndael in SQL, and of course the rest of that's easy enough with the various SQL extensions vendors have. So no matter how fucked up your comparison is, there's still a way to shoehorn it into a where clause. =D
Admin
...and there's yet another unstructured return statement. WHO is training these people? This is 1960's and 70's style coding. Funny stuff.
Admin
I suggest writing a custom SQL engine in script.
Its syntax would resemble CSS.
Whenever you used it, it would begin by querying the entire database.
This could be its syntax:
It would finally return a pipe-delimited string, all ready for you to parse in your recordset parsing layer:
Then you have a nice array with objects that you can quite easily loop over.
Handy!
If in ASP, you could turn it into a DLL and include it on every single page!
Admin
>> First, I have to admit that on a RARE occasion, I do something kind of like that in C#.
Well, I thought that's why DataView-s are for.
Regards,
:Piki
Admin
Thanks for that. You made my asthma come back and all.
At least that will filter out the IE users :)
Admin
Not only are you quite a bit not wrong, but I don't see wtf that has to do with using select properly.
My opinion is even SQL shouldn't be at the ``application level'' if by application level you mean building queries from string literals directly in the application.
Admin
BigbooTAY! TAY!!