Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 1.90 KB | None | 0 0
  1. package graduation.portlet
  2.  
  3. import groovy.sql.GroovyRowResult
  4. import org.springframework.transaction.annotation.Transactional
  5.  
  6. import java.sql.SQLException;
  7.  
  8. class CustomSqlService {
  9.  
  10.     def groovySql
  11.  
  12.     /**
  13.      *
  14.      * @param studentNumber
  15.      * @return
  16.      * @throws SQLException
  17.      */
  18.  
  19.     @Transactional
  20.     List<GroovyRowResult> getPersonByStudentNumber(final String studentNumber) throws SQLException {
  21.         final String stmt = '''
  22. select
  23.  i.spriden_id, i.spriden_pidm, i.spriden_last_name, i.spriden_first_name, i.spriden_mi,
  24.  c.sorlcur_degc_code, c.sorlcur_levl_code, c.sorlcur_coll_code, c.sorlcur_term_code_ctlg, c.SORLCUR_PROGRAM, c.SORLCUR_ACTIVITY_DATE,
  25.  m.SORMAJR_MAJR_CODE_MAJOR, m.SORMAJR_DEGC_CODE, m.SORMAJR_SBGI_CODE, m.SORMAJR_DEGR_SEQ_NO,
  26.  m1.STVMAJR_DESC
  27. from spriden i
  28. left join sorlcur c on i.spriden_pidm = c.SORLCUR_PIDM
  29. left join sormajr m on i.spriden_pidm = m.SORMAJR_PIDM
  30. left join stvmajr m1 on m.SORMAJR_MAJR_CODE_MAJOR = m1.STVMAJR_CODE
  31. where SPRIDEN_ID LIKE :studentNumber
  32. '''ddd
  33.  
  34.         return groovySql.rows(stmt, studentNumber: studentNumber)
  35.     }
  36.  
  37.     /**
  38.      *
  39.      * @param pidm
  40.      * @return
  41.      * @throws SQLException
  42.      */
  43.  
  44.     @Transactional
  45.     List<GroovyRowResult> getMajorsForStudent(final long pidm) throws SQLException {
  46.         final String stmt = '''
  47. select m.*, mm.*
  48. from SORMAJR m
  49. left join SATURN.STVMAJR mm on mm.STVMAJR_CODE = m.SORMAJR_MAJR_CODE_MAJOR
  50. where m.SORMAJR_PIDM = :pidm
  51. '''
  52.  
  53.         return groovySql.rows(stmt, pidm: pidm)
  54.     }
  55.  
  56.     /**
  57.      *
  58.      * @param studentId
  59.      * @return
  60.      * @throws SQLException
  61.      */
  62.  
  63.  
  64.     @Transactional
  65.     GroovyRowResult getPersonByStudentId(final String studentId) throws SQLException {
  66.         final sql = '''
  67. select *
  68. from SPRIDEN
  69. where SPRIDEN_ID like :studentId
  70. '''
  71.  
  72.         return groovySql.firstRow(sql, studentId: studentId)
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement