Advertisement
leversandpulleys

Untitled

Aug 15th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 7.20 KB | None | 0 0
  1. /* Formatted on 8/15/2018 8:56:52 AM (QP5 v5.265.14096.38000) */
  2. SET DEFINE OFF;
  3.  
  4. CREATE OR REPLACE TRIGGER SATURN.TBRCBRQ_POST_INSERT_ROW
  5.    AFTER INSERT
  6.    ON "TAISMGR"."TBRCBRQ"
  7.    FOR EACH ROW
  8. BEGIN
  9.    DECLARE
  10.       w_one_up_no      NUMBER (9) := 0;
  11.       w_gjbpdft_row    gjbpdft%ROWTYPE;
  12.       student_id       VARCHAR2 (9);
  13.       billing_rule     VARCHAR2 (30);
  14.       billing_date     VARCHAR2 (30);
  15.       job_printer      VARCHAR2 (30);
  16.       gtvsdax_status   gtvsdax.gtvsdax_internal_code%TYPE;
  17.  
  18.       --cursor to grab the trigger status from gtvsdax
  19.       CURSOR get_gtvsdax_status
  20.       IS
  21.          SELECT gtvsdax_external_code
  22.            FROM gtvsdax
  23.           WHERE     gtvsdax_internal_code = 'SCHEDINV'
  24.                 AND gtvsdax_internal_code_group = 'NOSLEEP';
  25.  
  26.  
  27.       PROCEDURE load_gjbprun
  28.       IS
  29.          CURSOR one_up_c
  30.          IS
  31.             SELECT gjbpseq.NEXTVAL FROM DUAL;
  32.  
  33.          CURSOR gjbpdft_c
  34.          IS
  35.             SELECT *
  36.               FROM gjbpdft
  37.              WHERE     gjbpdft_job = 'TSRCBIL'
  38.                    AND gjbpdft_jprm_code = 'TRIGGER'
  39.                    AND gjbpdft_user_id = 'NOSLEEP';
  40.  
  41.          --cursor to grab the students ID number
  42.          CURSOR spriden_c
  43.          IS
  44.             SELECT spriden_id
  45.               FROM spriden
  46.              WHERE     spriden_pidm = :NEW.tbrcbrq_pidm
  47.                    AND spriden_change_ind IS NULL;
  48.  
  49.  
  50.          --cursor to grab the billing rule from gtvsdax
  51.          CURSOR gtvsdax_rule_c
  52.          IS
  53.             SELECT gtvsdax_external_code
  54.               FROM gtvsdax
  55.              WHERE     gtvsdax_internal_code = :NEW.tbrcbrq_term_code
  56.                    AND gtvsdax_translation_code = 'RULE';
  57.  
  58.          --cursor to grab the billing date from gtvsdax
  59.          CURSOR gtvsdax_date_c
  60.          IS
  61.             SELECT gtvsdax_external_code
  62.               FROM gtvsdax
  63.              WHERE     gtvsdax_internal_code = :NEW.tbrcbrq_term_code
  64.                    AND gtvsdax_translation_code = 'DATE';
  65.       BEGIN
  66.          OPEN one_up_c;
  67.  
  68.          FETCH one_up_c INTO w_one_up_no;
  69.  
  70.          CLOSE one_up_c;
  71.  
  72.          BEGIN
  73.             DELETE FROM gjbprun
  74.                   WHERE     gjbprun_job = 'TSRCBIL'
  75.                         AND gjbprun_one_up_no = w_one_up_no;
  76.          END;
  77.  
  78.  
  79.          --fetch the students ID
  80.          OPEN spriden_c;
  81.  
  82.          FETCH spriden_c INTO student_id;
  83.  
  84.          CLOSE spriden_c;
  85.  
  86.          --fetch the rule
  87.          OPEN gtvsdax_rule_c;
  88.  
  89.          FETCH gtvsdax_rule_c INTO billing_rule;
  90.  
  91.          CLOSE gtvsdax_rule_c;
  92.  
  93.          --fetch the billing date
  94.          OPEN gtvsdax_date_c;
  95.  
  96.          FETCH gtvsdax_date_c INTO billing_date;
  97.  
  98.          CLOSE gtvsdax_date_c;
  99.  
  100.          OPEN gjbpdft_c;
  101.  
  102.          LOOP
  103.             FETCH gjbpdft_c INTO w_gjbpdft_row;
  104.  
  105.             EXIT WHEN gjbpdft_c%NOTFOUND;
  106.  
  107.             --loop below takes the settings from the actual bill
  108.             --request in TBRCBRQ and overrides NOSLEEP's default parameters
  109.             --in gjbpdft so that the final parameter set placed in gjbprun
  110.             --will launch a no-sleep instance of TSRCBIL that catches
  111.             --the new bill request
  112.  
  113.             IF w_gjbpdft_row.gjbpdft_number = '01'
  114.             THEN
  115.                w_gjbpdft_row.gjbpdft_value := :NEW.tbrcbrq_term_code;
  116.             END IF;
  117.  
  118.             IF w_gjbpdft_row.gjbpdft_number = '04'
  119.             THEN
  120.                w_gjbpdft_row.gjbpdft_value := student_id;
  121.             END IF;
  122.  
  123.             IF w_gjbpdft_row.gjbpdft_number = '05'
  124.             THEN
  125.                w_gjbpdft_row.gjbpdft_value := :NEW.tbrcbrq_printer;
  126.             END IF;
  127.  
  128.             IF w_gjbpdft_row.gjbpdft_number = '12'
  129.             THEN
  130.                w_gjbpdft_row.gjbpdft_value := billing_rule;
  131.             END IF;
  132.  
  133.             --tsrcbil.pc generates an error when sysdate comes from the stored parm set
  134.             --the same does not occur for parm 2 address sel date
  135.             IF w_gjbpdft_row.gjbpdft_number = '17'
  136.             THEN
  137.                w_gjbpdft_row.gjbpdft_value :=
  138.                   TO_CHAR (TO_DATE (SYSDATE, 'DD-MON-YYYY'));
  139.             END IF;
  140.  
  141.             IF w_gjbpdft_row.gjbpdft_number = '18'
  142.             THEN
  143.                w_gjbpdft_row.gjbpdft_value := billing_date;
  144.             END IF;
  145.  
  146.             --inserts the row value for this pass through the loop
  147.  
  148.             BEGIN
  149.                INSERT INTO gjbprun (gjbprun_job,
  150.                                     gjbprun_one_up_no,
  151.                                     gjbprun_number,
  152.                                     gjbprun_activity_date,
  153.                                     gjbprun_value)
  154.                     VALUES ('TSRCBIL',
  155.                             w_one_up_no,
  156.                             w_gjbpdft_row.gjbpdft_number,
  157.                             SYSDATE,
  158.                             w_gjbpdft_row.gjbpdft_value);
  159.             END;
  160.          END LOOP;
  161.  
  162.          CLOSE gjbpdft_c;
  163.       END load_gjbprun;
  164.    BEGIN
  165.       --fetch the gtvsdax status
  166.       OPEN get_gtvsdax_status;
  167.  
  168.       FETCH get_gtvsdax_status INTO gtvsdax_status;
  169.  
  170.       CLOSE get_gtvsdax_status;
  171.  
  172.       --   IF :new.tbrcbrq_printer = 'sc_burp09' or :new.tbrcbrq_printer = 'sc_onecard_cir210_1G' or :new.tbrcbrq_printer = 'sc_onecard_cir210_1' or :new.tbrcbrq_printer = 'sc_oitp10' or :new.tbrcbrq_printer = 'sc_bursar_hp4050_1' or :new.tbrcbrq_printer = 'sc_bursar_hp4050_2' or :new.tbrcbrq_printer = 'sc_bursar_hp4050_3' or :new.tbrcbrq_printer = 'sc_bursar_hp4050_4' or :new.tbrcbrq_printer = 'sc_bursar_hp4000_1' or :new.tbrcbrq_printer = 'sc_bursar_hp5_1' or :new.tbrcbrq_printer = 'sc_finaid_hp4000_1' or :new.tbrcbrq_printer = 'sc_onecard_hp2200_1' or :new.tbrcbrq_printer = 'sc_regist_hp4050_1' or :new.tbrcbrq_printer = 'sc_regist_hp4050_2' or :new.tbrcbrq_printer = 'sc_regp03' or :new.tbrcbrq_printer = 'sc_regp04' or :new.tbrcbrq_printer = 'sc_resp05' or :new.tbrcbrq_printer = 'sc_stdsupsr_hp2100_1' THEN
  173.  
  174.       --translate problem queues to correct printcap entry
  175.  
  176.       job_printer := :NEW.tbrcbrq_printer;
  177.  
  178.       IF job_printer = 'sc_onecard_cir210_1G'
  179.       THEN
  180.          job_printer := 'sc_onecard_cir210_1';
  181.       END IF;
  182.  
  183.       IF gtvsdax_status = 'Y'
  184.       THEN
  185.          load_gjbprun;
  186.  
  187.          baninst1.gp_submit_gjajobs ('TSRCBIL',
  188.                                      'C',
  189.                                      '',
  190.                                      '',
  191.                                      w_one_up_no || '04',
  192.                                      --         'DATABASE',
  193.                                      --     :new.tbrcbrq_printer,
  194.                                      job_printer,
  195.                                      -- line below is for evisions form
  196.                                      'SCHEDBILL',
  197.                                      '',
  198.                                      '',
  199.                                      '',
  200.                                      w_one_up_no);
  201.       --   END IF;
  202.       END IF;
  203.    END;
  204. --         BEGIN
  205. --            delete
  206. --              from tbrcbrq
  207. --             where tbrcbrq_pidm       = :new.tbrcbrq_pidm
  208. --               and tbrcbrq_printer    = :new.tbrcbrq_printer;
  209. --         END;
  210.  
  211. END;
  212. /
  213.  
  214. SHOW ERRORS;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement