1. SQL / Говнокод #3782

    −861

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    /* Ask Dian for changing this enormous DECODE */
          sprintf( ranges_sort_condition,
                   "DECODE(CONTRACT_ID, '%s', 1, 0) + "
                   "DECODE(ISS_INST, '%s', 2, 0) + "
                   "DECODE(ACQ_INST, '%s', 4, 0) + "
                   "DECODE(ISS_BIN, '%s', 8, 0) + "
                   "DECODE(TERM_TYPE, %d, 16, 0) + "
                   "DECODE(IS_PRIMARY_CARD, %d, 32, 0), "
                   "  0,  1,  64,  2,  32,  3,  16,  4,   4,  5,   8,  6,  96,  7,  80,  8,"
                   " 68,  9,  72, 10,  40, 11,  24, 12,  12, 13,   2, 14,  10, 15,  48, 16,"
                   " 36, 17, 104, 18,  88, 19,  76, 20,  66, 21,  74, 22, 112, 23, 100, 24,"
                   " 56, 25,  44, 26,  34, 27,  42, 28,  20, 29,  28, 30,  18, 31,   6, 32,"
                   " 26, 33,  14, 34,  52, 35,  60, 36, 124, 37,  50, 38,  38, 39,  22, 40,"
                   "118, 41, 122, 42, 110, 43,  94, 44, 126, 45,   1, 46,  65, 47,  97, 48,"
                   " 81, 49,   5, 50,  73, 51, 105, 52,  89, 53,  77, 54,  67, 55,  75, 56,"
                   "113, 57, 121, 58, 101, 59, 109, 60,  99, 61, 107, 62,  85, 63,  93, 64,"
                   " 83, 65,  71, 66,  91, 67,  79, 68, 117, 69, 125, 70, 115, 71, 103, 72,"
                   " 87, 73, 119, 74,  59, 75,  47, 76,  95, 77,  63, 78, 127, 79, 999",
                   "-1", DEFAULT_INST_ID, DEFAULT_INST_ID, "-1", TERM_TYPE_DEF, IS_PRIMARY_DEF );
    
          ora_sql_stmt_buff.len = sprintf( (char*)ora_sql_stmt_buff.arr, 
                                           "SELECT ACQ_INST, "
                                           "       ISS_INST, "
                                           "       ISS_BIN,  "
                                           "       TERM_TYPE, "
                                           "       MSGTYPE,  "
                                           "       TASK,     "
                                           "       REVERSAL, "
                                           "       CONTRACT_ID, "
                                           "       IS_PRIMARY_CARD, "
                                           "       TMPL_ID   "
                                           "  FROM T_TRANS_AUTH_ALG "
                                           " WHERE TRANS_TYPE = :ora_trans_type "
                                           " ORDER BY DECODE(%s)", ranges_sort_condition );

    Это хоть и на Си, но формирование запроса SQL, так что попадает сюда.
    Хоть бы комментарий какой написали, демоны!

    Запостил: nil, 26 Июля 2010

    Комментарии (3) RSS

    Добавить комментарий