Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

POPULATING TABLE 1

Status
Not open for further replies.

016

Programmer
May 8, 2000
17
US
I have to populate a new table from an old one: the problem is the new columns table do not have the same name than the old one. for example the new table is

iNSERT INTO BILL_TABLE (budget_no, VERSION, FISCAL_YEAR
BILL_SEQ_NO
RATE_01
RATE_02
RATE_03 (UNTIL RATE_12)
SQUARE_FT_01
SQUARE_FT_02
SQUARE_FT_03 (UNTIL SQUARE_FT_12)
TOTAL_01
TOTAL_02
TOTAL_03
COMMENTS_01
COMMENTS_02
COMMENTS_03
select(
REPORTING_YEAR VERSION
EFFECTIVE_DATE, SPACE_TYPE
SQ_FT
RATE AMOUNT budget_no
COMMENTS ) FROM OLD TABLE
The problem I am facing is that the old table column has EFFECTIVE DATE (datatype date) WHICH CAN CORRESPOND TO RATE_01 (datatype number) IF I CAN WRITE A WHERE CLAUSE SAYING THAT WHERE RATE_01 for the EFFECTIVE_DATE= 01-JAN-2000 TO 31-JAN-2000 AND FOR RATE _02 I WILL HAVE 1-FEV-200O TO FEB-2001.... the
SQUARE_FT_01 colum has to correspond to SQ_FT in the second table and here also by month.... could you please help me with this. Do I have to write one first insert statement and update after fort the other column. How can I write the first insert statement. Tahnk you very much in advance
 
Dear 016,
Show us the column names and corresponding datatypes of your two tables, in order. Then one of us will be able to get back to you with an answer.
loren256
 
Loren256. Thank you very much Here are the tables the bill_table is the table I want to populate . the space table contain the data.
thank you again
SQL> desc bill_table;
Name Null? Type
------------------------------- -------- ----
inst_CODE NOT NULL VARCHAR2(2)
build_CODE NOT NULL VARCHAR2(2)
PROP_SEQ_NO NOT NULL NUMBER
SPACE_TYPE NOT NULL VARCHAR2(4)
CBR_NUMBER NOT NULL VARCHAR2(9)
RENT_VERSION NOT NULL VARCHAR2(1)
FISCAL_YEAR NOT NULL NUMBER(4)
BILL_SEQ_NO NOT NULL NUMBER
DATE_REC_ADDED NOT NULL DATE
DATE_REC_LAST_CHG NOT NULL DATE
LAST_OPERATOR_ID NOT NULL VARCHAR2(30)
RATE_01 NUMBER
RATE_02 NUMBER
RATE_03 NUMBER
RATE_04 NUMBER
RATE_05 NUMBER
RATE_06 NUMBER
RATE_07 NUMBER
RATE_08 NUMBER
RATE_09 NUMBER
RATE_10 NUMBER
RATE_11 NUMBER
RATE_12 NUMBER
SQUARE_FT_01 NUMBER
SQUARE_FT_02 NUMBER
SQUARE_FT_03 NUMBER
SQUARE_FT_04 NUMBER
SQUARE_FT_05 NUMBER
SQUARE_FT_06 NUMBER
SQUARE_FT_07 NUMBER
SQUARE_FT_08 NUMBER
SQUARE_FT_09 NUMBER
SQUARE_FT_10 NUMBER
SQUARE_FT_11 NUMBER
SQUARE_FT_12 NUMBER
TOTAL_01 NUMBER
TOTAL_02 NUMBER
TOTAL_03 NUMBER
TOTAL_04 NUMBER
TOTAL_05 NUMBER
TOTAL_06 NUMBER
TOTAL_07 NUMBER
TOTAL_08 NUMBER
TOTAL_09 NUMBER
TOTAL_10 NUMBER
TOTAL_11 NUMBER
TOTAL_12 NUMBER
COMMENTS_01 VARCHAR2(255)
COMMENTS_02 VARCHAR2(255)
COMMENTS_03 VARCHAR2(255)
COMMENTS_04 VARCHAR2(255)
COMMENTS_05 VARCHAR2(255)
COMMENTS_06 VARCHAR2(255)
COMMENTS_07 VARCHAR2(255)
COMMENTS_08 VARCHAR2(255)
COMMENTS_09 VARCHAR2(255)
COMMENTS_10 VARCHAR2(255)
COMMENTS_11 VARCHAR2(255)
COMMENTS_12 VARCHAR2(255)

SQL> desc space_table
Name Null? Type
------------------------------- -------- ----
inst_CODE NOT NULL VARCHAR2(2)
build_CODE NOT NULL VARCHAR2(2)
PROP_SEQ_NO NOT NULL NUMBER
RENT_VERSION NOT NULL VARCHAR2(1)
_EFFECTIVE_DATE NOT NULL DATE
_SPACE_TYPE NOT NULL VARCHAR2(4)
_ASSIGNMENT_SQ_FT NOT NULL NUMBER
_BILL_TYPE NOT NULL VARCHAR2(1)
DATE_REC_ADDED NOT NULL DATE
DATE_REC_LAST_CHG NOT NULL DATE
LAST_OPERATOR_ID NOT NULL VARCHAR2(30)
REPORTING_YEAR NUMBER(4)
_REGION_CODE VARCHAR2(2)
_ADJUST_TO_DATE DATE
_BILL_NUMBER VARCHAR2(10)
TYPE_CODE VARCHAR2(2)
JOINT_USE_SPACE NUMBER(12,2)
RATE NUMBER
ASSIGNMENT_AMOUNT NUMBER
OCCUPANCY_RIGHT_CODE VARCHAR2(2)
ADJ_START_DATE DATE
ADJ_END_DATE DATE
CBR_NUMBER VARCHAR2(9)
TELEPHONE_NUMBER VARCHAR2(14)
YEAR_TO_DATE NUMBER(12,2)
GSA_CONTACT VARCHAR2(30)
SPACE_TYPE_CATEGORY VARCHAR2(55)
SPACE_TYPE_DESCRIPTION VARCHAR2(35)
REASON_FOR_CHARGE VARCHAR2(125)
COMMENTS VARCHAR2(125)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top