Home » SQL & PL/SQL » SQL & PL/SQL » What is the best way to do this???
What is the best way to do this??? [message #190223] Tue, 29 August 2006 15:42 Go to next message
Rogelio
Messages: 3
Registered: October 2005
Location: CT
Junior Member
I am writing a plsql package that is going to create a custom table everything is going fine EXCEPT that I don’t know what will be the best way to do this. Please point me in the right direction a function or something:

I have three tables:
My custom table SZSLIFE
Two existing tables in my DATABASE:
SGBSTDN,
SLRRASG

For this pidm (primary key). I have the following records in the SLRRASG table:
SLRRASG_PIDM SLRRASG_BLDG_CODE SLRRASG_ROOM_NUMBER SLRRASG_TERM_CODE SLRRASG_RRCD_CODE SLRRASG_BEGIN_DATE
139203 ADD 103 200490 RCOM 09/02/2004
139203 ADD 103 200510 RCOM 01/24/2005
139203 BLA 001 200390 RCOM 09/03/2003
139203 BLA 001 200410 RCOM 01/25/2004
139203 HRK 101 200690 RCOM 08/31/2006
139203 RIV 11 200590 RCOM 09/01/2005

And I have the following records in the SGBSTDN table.

SGBSTDN_PIDM SGBSTDN_TERM_CODE_EFF SGBSTDN_STST_CODE SGBSTDN_LEVL_CODE SGBSTDN_STYP_CODE SGBSTDN_TERM_CODE_MATRIC
139203 200390 AS UG C 200390
139203 200410 AS UG C 200390
139203 200590 DW UG C 200390
139203 200610 IS UG C 200390
139203 200660 AS UG C 200390
139203 200690 AS UG E 200390
139203 200710 IS UG C 200390

So far I have been able to insert the following records in my custom table. This data is coming from the sgbstdn table

SZSLIFE_PIDM SZSLIFE_SLRRASG_TERM_CODE SZSLIFE_STUDENT_STATUS_CODE SZSLIFE_STUDENT_STATUS_DESC SZSLIFE_STUDENT_TYPE_CODE SZSLIFE_STUDENT_TYPE_DESC SZSLIFE_STUDENT_LEVEL_CODE SZSLIFE_STUDENT_LEVEL_DESC


139203 200390 AS Active C Continuing UG Undergraduate
139203 200410 AS Active C Continuing UG Undergraduate
139203 200590 DW Directed to Withdraw C Continuing UG Undergraduate
139203 200610 IS Inactive C Continuing UG Undergraduate
139203 200660 AS Active C Continuing UG Undergraduate
139203 200690 AS Active E Readmit/Re-entry UG Undergraduate
139203 200710 IS Inactive C Continuing UG Undergraduate

NOW the question is: I need to insert the rows from the term 200490 and 200510 because there is data in the slrrasg table for those terms BUT the data that I need to insert is coming from the SGBSTDN table and there is not data for those terms in sgbstdn, so my user is telling my that it is okay to insert the previous term from sgbstdn for example: for the term 200490 I need to insert trhe 200490 in the szslife_slrrasg_term_code but I also need to insert the row from the 200390(previous one) from SGBSTDN.
The same for 200510 insert 200510 in szslife_slrrasg_term_code but the rows from the term 200410 in SGBSTDN.

Please give some ideas of how to do this. I will highly appreciate.

Tables
SLRRASG:

SLRRASG_PIDM
SLRRASG_BLDG_CODE
SLRRASG_ROOM_NUMBER
SLRRASG_TERM_CODE
SLRRASG_RRCD_CODE
SLRRASG_BEGIN_DATE

sgbstdn
SGBSTDN_PIDM
SGBSTDN_TERM_CODE_EFF
SGBSTDN_STST_CODE
SGBSTDN_LEVL_CODE
SGBSTDN_STYP_CODE
SGBSTDN_TERM_CODE_MATRI

CUSTOM TABLE
SZSLIFE_PIDM
SZSLIFE_SLRRASG_TERM_CODE
SZSLIFE_STUDENT_STATUS_CODE
SZSLIFE_STUDENT_STATUS_DESC
SZSLIFE_STUDENT_TYPE_CODE
SZSLIFE_STUDENT_TYPE_DESC
SZSLIFE_STUDENT_LEVEL_CODE
SZSLIFE_STUDENT_LEVEL_DESC





Re: What is the best way to do this??? [message #190328 is a reply to message #190223] Wed, 30 August 2006 04:14 Go to previous message
kimant
Messages: 201
Registered: August 2006
Location: Denmark
Senior Member
Hi

It would be much easier to help You, if You come up with scripts to create tables and insert data.

Br
Kim

Previous Topic: Recover more than one row in a function
Next Topic: Sending data from Forms and reports to MS-Word
Goto Forum:
  


Current Time: Tue Dec 06 10:25:48 CST 2016

Total time taken to generate the page: 0.11000 seconds