Democratic Underground Latest Greatest Lobby Journals Search Options Help Login
Google

ok, whats wrong with this?

Printer-friendly format Printer-friendly format
Printer-friendly format Email this thread to a friend
Printer-friendly format Bookmark this thread
This topic is archived.
Home » Discuss » The DU Lounge Donate to DU
 
LSK Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Mar-20-06 06:23 PM
Original message
ok, whats wrong with this?
CASE WHEN ( PODT00 > 0 ) THEN
CASE WHEN ( PODT00 - SDDT00 ) < 0 THEN 0
WHEN SDTM00 = 1700 THEN 0
WHEN SDTM00 < POTM00 THEN CAST ((CAST(CAST(CONCAT(CONCAT(CONCAT(SUBSTRING(CAST((CASE WHEN SDTM00 > 1259 THEN (CAST(CONCAT(SUBSTR(CAST(SDTM00 AS VARCHAR ( 4 ) ) , 1 , 2 ) , SUBSTR ( CAST ( SDTM00 AS VARCHAR ( 4 ) ) , 3 , 2 ) ) AS NUMERIC ( 4 , 0 ) ) - 1200 ) ELSE SDTM00 END )
AS VARCHAR ( 4 ) ) , 1 , ( CASE WHEN LENGTH ( CAST ( ( CASE WHEN SDTM00 > 1259 THEN ( CAST ( CONCAT ( SUBSTR ( CAST ( SDTM00 AS VARCHAR ( 4 ) ) , 1 , 2 ) , SUBSTR ( CAST ( SDTM00 AS VARCHAR ( 4 ) ) , 3 , 2 ) ) AS NUMERIC ( 4 , 0 ) ) - 1200 ) ELSE SDTM00 END ) AS VARCHAR ( 4 ) ) ) = 3 THEN 1 ELSE 2 END ) ) , ':' ) , SUBSTRING ( CAST ( SDTM00 AS VARCHAR ( 4 ) ) , ( CASE WHEN LENGTH ( CAST ( SDTM00 AS VARCHAR ( 4 ) ) ) = 3 THEN 2 ELSE 3 END ) , 2 ) ) , ( CASE WHEN SDTM00 < 1200 THEN ' AM' ELSE ' PM' END ) ) AS TIME )
- CAST ( CONCAT ( CONCAT ( CONCAT ( SUBSTRING ( CAST ( ( CASE WHEN POTM00 > 1259 THEN ( CAST ( CONCAT ( SUBSTR ( CAST ( POTM00 AS VARCHAR ( 4 ) ) , 1 , 2 ) , SUBSTR ( CAST ( POTM00 AS VARCHAR ( 4 ) ) , 3 , 2 ) ) AS NUMERIC ( 4 , 0 ) ) - 1200 ) ELSE POTM00 END ) AS VARCHAR ( 4 ) ) , 1 , ( CASE WHEN LENGTH ( CAST ( ( CASE WHEN POTM00 > 1259 THEN ( CAST ( CONCAT ( SUBSTR ( CAST ( POTM00 AS VARCHAR ( 4 ) ) , 1 , 2 ) , SUBSTR ( CAST ( POTM00 AS VARCHAR ( 4 ) ) , 3 , 2 ) ) AS NUMERIC ( 4 , 0 ) ) - 1200 ) ELSE POTM00 END ) AS VARCHAR ( 4 ) ) ) = 3 THEN 1 ELSE 2 END ) ) , ':' ) , SUBSTRING ( CAST ( POTM00 AS VARCHAR ( 4 ) ) , ( CASE WHEN LENGTH ( CAST ( POTM00 AS VARCHAR ( 4 ) ) ) = 3 THEN 2 ELSE 3 END ) , 2 ) ) , ( CASE WHEN POTM00 < 1200 THEN 'AM' ELSE ' PM' END ) ) AS TIME ) AS NUMERIC ( 8 , 0 ) ) / 100 ) AS NUMERIC ( 8 , 0 ) ) ELSE 0 END WHEN ADTM00 > 0 THEN CASE WHEN ( ADDT00 - SDDT00 ) < 0 THEN 0 WHEN SDTM00 = 1700 THEN 0 WHEN SDTM00 < ADTM00 THEN CAST ( ( CAST ( CAST ( CONCAT ( CONCAT( CONCAT ( SUBSTRING ( CAST ( ( CASE WHEN SDTM00 > 1259 THEN ( CAST ( CONCAT ( SUBSTR ( CAST ( SDTM00 AS VARCHAR ( 4 ) ) , 1 , 2 ) , SUBSTR ( CAST ( SDTM00 AS VARCHAR ( 4 ) ) , 3 , 2 ) ) AS NUMERIC ( 4 , 0 ) ) - 1200 ) ELSE SDTM00 END ) AS VARCHAR ( 4 ) ) , 1 , ( CASE WHEN LENGTH ( CAST ( ( CASE WHEN SDTM00 > 1259 THEN ( CAST ( CONCAT ( SUBSTR ( CAST ( SDTM00 AS VARCHAR ( 4 ) ) , 1 , 2 ) , SUBSTR ( CAST ( SDTM00 AS VARCHAR ( 4 ) ) , 3 , 2 ) ) AS NUMERIC ( 4 , 0 ) ) - 1200 ) ELSE SDTM00 END ) AS VARCHAR ( 4 ) ) ) = 3 THEN 1 ELSE 2 END ) ) , ':' ) , SUBSTRING ( CAST ( SDTM00 AS VARCHAR ( 4 ) ) , ( CASE WHEN LENGTH ( CAST ( SDTM00 AS VARCHAR ( 4 ) ) ) = 3 THEN 2 ELSE 3 END ) , 2 ) ) , ( CASE WHEN SDTM00 < 1200 THEN ' AM' ELSE ' PM' END ) ) AS TIME ) - CAST ( CONCAT ( CONCAT ( CONCAT ( SUBSTRING ( CAST ( ( CASE WHEN ADTM00 > 1259 THEN ( CAST ( CONCAT ( SUBSTR ( CAST ( ADTM00 AS VARCHAR ( 4 ) ) , 1 , 2 ) , SUBSTR ( CAST ( ADTM00 AS VARCHAR ( 4 ) ) , 3 , 2 ) ) AS NUMERIC ( 4 , 0 ) ) - 1200 ) ELSE ADTM00 END ) AS VARCHAR ( 4 ) ) , 1 , ( CASE WHEN LENGTH ( CAST ( ( CASE WHEN ADTM00 > 1259 THEN ( CAST ( CONCAT ( SUBSTR ( CAST ( ADTM00 AS VARCHAR ( 4 ) ) , 1 , 2 ) , SUBSTR ( CAST ( ADTM00 AS VARCHAR ( 4 ) ) , 3 , 2 ) ) AS NUMERIC ( 4 , 0 ) ) - 1200 ) ELSE ADTM00 END ) AS VARCHAR ( 4 ) ) ) = 3 THEN 1 ELSE 2 END ) ) , ':' ) , SUBSTRING ( CAST ( ADTM00 AS VARCHAR ( 4 ) ) , ( CASE WHEN LENGTH ( CAST ( ADTM00 AS VARCHAR ( 4 ) ) ) = 3 THEN 2 ELSE 3 END ) , 2 ) ) , ( CASE WHEN ADTM00 < 1200 THEN ' AM' ELSE ' PM' END ) ) AS TIME ) AS NUMERIC ( 8 , 0 ) ) / 100 ) AS NUMERIC ( 8 , 0 ) ) ELSE 0 END ELSE 0 END AS TIMEDIF
Printer Friendly | Permalink |  | Top
LaurenG Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Mar-20-06 06:24 PM
Response to Original message
1. endless loop?
it's too hard for me to tell.:shrug:
Printer Friendly | Permalink |  | Top
 
flvegan Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Mar-20-06 06:25 PM
Response to Original message
2. It's all in caps, which is poor netiquette.
I'm an idiot.
Printer Friendly | Permalink |  | Top
 
Misunderestimator Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Mar-20-06 06:26 PM
Response to Original message
3. First, you need to format it so that it's readable.
Printer Friendly | Permalink |  | Top
 
LSK Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Mar-20-06 06:28 PM
Response to Reply #3
4. that would be half the battle
unfornately thats how i got it
Printer Friendly | Permalink |  | Top
 
Misunderestimator Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Mar-20-06 06:32 PM
Response to Reply #4
6. That would be my first step.
There would be no way to even approach it without formatting with returns and indents first. I do that all the time when evaluating system generated errors that contain SQL or Cobol statements that fail. They are usually not formatted after compilation, even when the actual program is.
Printer Friendly | Permalink |  | Top
 
Misunderestimator Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Mar-20-06 06:46 PM
Response to Reply #4
12. Oh man.... That sucks... Too many nested "cases" to start with.
Edited on Mon Mar-20-06 06:47 PM by Misunderestimator
That's nearly impossible to even make readable. Holy crap. What crap SQL did that come from? And why does it use both SUBSTR and SUBSTRING as functions?
Printer Friendly | Permalink |  | Top
 
LSK Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Mar-20-06 06:48 PM
Response to Reply #12
13. someone else wrote it (who no longer works here)
It errors out occasinally.
Printer Friendly | Permalink |  | Top
 
Misunderestimator Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Mar-20-06 06:56 PM
Response to Reply #13
14. Of course it does... it errors whenever it evaluates to the case statement
Edited on Mon Mar-20-06 07:00 PM by Misunderestimator
that sucks worse than all the others. Holy shit, man... that code really really really sucks. I would throw it out and start from scratch from the requirement. That would be nearly impossible to figure out. All the substrings and casts which should be call outs from the main program... It just plain sucks.

Under what conditions does it fail? What's the value of SDTM00, POTM00 and ADTM00 when it fails? That's the place to start so you can narrow it down to the exact location of the sucky code.

On edit... just had a thought... maybe SUBSTRING is not a valid function? There are more SUBSTRs than SUBSTRINGs in the code, so it's possible it fails whenever it evaluates to a portion of the code that uses the SUBSTRING function.
Printer Friendly | Permalink |  | Top
 
EstimatedProphet Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Mar-20-06 06:31 PM
Response to Original message
5. You forgot a comma
Printer Friendly | Permalink |  | Top
 
Rabrrrrrr Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Mar-20-06 06:33 PM
Response to Original message
7. What language is that?
Even cobol isn't that ugly.
Printer Friendly | Permalink |  | Top
 
salvorhardin Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Mar-20-06 06:34 PM
Response to Reply #7
8. It looks like really horrible C code n/t
Printer Friendly | Permalink |  | Top
 
Rabrrrrrr Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Mar-20-06 06:35 PM
Response to Reply #8
10. I would bet good money that's not C
I've done C, and it doesn't look familiar, and there're no brackets and no semi-colons.
Printer Friendly | Permalink |  | Top
 
salvorhardin Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Mar-20-06 07:04 PM
Response to Reply #10
15. No.. I didn't mean to imply that it WAS C code
I just meant to say it LOOKED like really horrible C code. In particular all those type castings -- ugh! I should have clarified in the body of my message.

Got to love the meaningless identifiers too.
Printer Friendly | Permalink |  | Top
 
LSK Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Mar-20-06 06:41 PM
Response to Reply #7
11. SQL
Printer Friendly | Permalink |  | Top
 
salvorhardin Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Mar-20-06 07:06 PM
Response to Reply #11
16. Really!?
Wow. I've never seen SQL like that before. What kind of system is it from?

Just curious. I certainly don't envy you.
Printer Friendly | Permalink |  | Top
 
LSK Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Mar-20-06 08:52 PM
Response to Reply #16
17. its part of a select statement
Its DB2.
Printer Friendly | Permalink |  | Top
 
Orsino Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Mar-20-06 06:35 PM
Response to Original message
9. I see the mistake.
You misspelled "* is a spoiled brat whose strings are pulled by dangerous ideologue cronies who are wrecking our economy and culture as they kill thousands."
Printer Friendly | Permalink |  | Top
 
LynzM Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Mar-20-06 08:56 PM
Response to Original message
18. Holy shit, dude.
I've written some messy SQL in my learning of it, but that's a fucking disaster. Wow. Good luck. I agree with MisU's suggestion to figure out what it's supposed to do and rewrite it, I think. Ugh.
Printer Friendly | Permalink |  | Top
 
DU AdBot (1000+ posts) Click to send private message to this author Click to view 
this author's profile Click to add 
this author to your buddy list Click to add 
this author to your Ignore list Thu Dec 26th 2024, 10:32 AM
Response to Original message
Advertisements [?]
 Top

Home » Discuss » The DU Lounge Donate to DU

Powered by DCForum+ Version 1.1 Copyright 1997-2002 DCScripts.com
Software has been extensively modified by the DU administrators


Important Notices: By participating on this discussion board, visitors agree to abide by the rules outlined on our Rules page. Messages posted on the Democratic Underground Discussion Forums are the opinions of the individuals who post them, and do not necessarily represent the opinions of Democratic Underground, LLC.

Home  |  Discussion Forums  |  Journals |  Store  |  Donate

About DU  |  Contact Us  |  Privacy Policy

Got a message for Democratic Underground? Click here to send us a message.

© 2001 - 2011 Democratic Underground, LLC