• ThankGodILeft (unregistered) in reply to Drak

    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.
     

  • (cs)

    Ouch! Its code like this that makes my eyes bleed!

  • Joel McNary (unregistered) in reply to clockwise

    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.

  • Joel McNary (unregistered) in reply to Joel McNary

    Anonymous:
    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.

    Do'h.  This was in response to a previous post about how the ResultRecord record was being created on each iteration through the loop.

  • (cs) in reply to clockwise
    clockwise:
    I love how he's declaring a new ResultRecord for each row in the table. (allocate more space on heap, read resultset var into it, compare, remove space from heap, repeat) Or would this not be a problem with todays compilers?

    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.
  • Fregas (unregistered) in reply to DentedHead

    Anonymous:


    When I started working at my first .Com job, our CTO (who started a very famous .com before this one) FORBID us to us joins! His reasons were database indepenancy which kinda was valid, since we had no database abstraction layer, since we had no concept of appliation layers in the code to begin with, all our SQL calls were hand writen into the code.

    I will allso  mention that he frown edon the use of methods since it was inefficient compared to inlining everything. But that's another story for another time.

    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.

  • Baron (unregistered) in reply to Fregas

    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.

  • (cs) in reply to John Smallberries
    John Smallberries:
    oh fer god's sake.
    that's just ridiculous.


    I thought you looked familiar!
  • (cs) in reply to John Bigboote
    John Bigboote:
    John Smallberries:


    bahahahahahahahahahahaha
  • (cs) in reply to Beek

    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

  • LibertyToad (unregistered)

    ...and there's yet another unstructured return statement.  WHO is training these people?  This is 1960's and 70's style coding.  Funny stuff.

  • (cs) in reply to LibertyToad

    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:

    var query = "tableName field { join-padding: inner; join-direction:right; match-field: 'foo'  }"

    var DB = new DatabaseHolder(query)


    It would finally return a pipe-delimited string, all ready for you to parse in your recordset parsing layer:

    parseResults(DB);


    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!
  • :Piki (unregistered) in reply to Fregas

    >> First, I have to admit that on a RARE occasion, I do something kind of like that in C#. 

    If I have a collection, that is ALREADY a subset of the data (Never the entire table--because I DO believe in WHERE clauses),
    and is relatively small (10-300 rows max) i might loop thru it rather than opening another connection to the database. 


    Well, I thought that's why DataView-s are for.

    Regards,
    :Piki
  • Wian Potgieter (unregistered) in reply to James Carr
    Anonymous:
    No.. you should suck in every database on the database server (if more than one), store each in an array, and use custom "search objects" that you coded during college to emulate the data access layer and pull out a single record.

    BTW, I wanted to note this site has given me inspiration. I am currently hard at work on a javascript based database that uses cookies for it's storage.


    Thanks for that.  You made my asthma come back and all.
    At least that will filter out the IE users :)
  • (cs) in reply to Marty Thompson
    Anonymous:
    Everyone knows you don't put business logic at the database level, so I don't see the WTF here.

    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.
  • (cs) in reply to John Bigboote
    John Bigboote:
    John Smallberries:
    oh fer god's sake.
    that's just ridiculous.


    I thought you looked familiar!

    BigbooTAY! TAY!!

Leave a comment on “Where's Rowdo?”

Log In or post as a guest

Replying to comment #:

« Return to Article