LogicallySkewed
Programmer
Hi,
I am new to SQL. I wrote a query to pull data from an Oracle database and can't get it to work. When I run it I get two error messages:
ERROR: ORACLE prepare error: ORA-00918: column ambiguously defined.
ERROR: SQL View WORK.ADM could not be processed because at least one of the data sets, or views, referenced directly (or indirectly) by it could not be located, or opened successfully.
Here is my code:
PROC SQL;
CONNECT TO oracle (user=SOCHA orapw=westwind02 path=PPRD);
CREATE VIEW Adm AS
SELECT * FROM connection to oracle
(SELECT saradap.saradap_pidm,
saradap.saradap_term_code_entry,
stvlevl.stvlevl_desc,
saradap.saradap_appl_date,
stvapst.stvapst_desc,
stvadmt.stvadmt_desc,
stvstyp.stvstyp_desc,
stvcoll.stvcoll_desc,
stvdegc.stvdegc_desc,
stvmajr.stvmajr_desc,
stvmajr.stvmajr_cipc_code,
stvresd.stvresd_desc,
stvresd.stvresd_in_state_ind,
stvterm.stvterm_desc,
stvacyr.stvacyr_desc,
saradap.saradap_full_part_ind,
stvapdc.stvapdc_desc,
stvsite.stvsite_desc,
stvsbgi.stvsbgi_type_ind,
stvsbgi.stvsbgi_srce_ind,
stvsbgi.stvsbgi_desc,
stvcamp.stvcamp_desc,
stvdept.stvdept_desc
FROM SATURN.saradap LEFT JOIN SATURN.sabsupl ON saradap.saradap_pidm=sabsupl.sabsupl_pidm AND saradap.saradap_term_code_entry=sabsupl.sabsupl_term_code_entry,
SATURN.sabsupl LEFT JOIN SATURN.sarappd ON sabsupl_pidm=sarappd_pidm AND sabsupl.sabsupl_term_code_entry=sarappd.sarappd_term_code_entry,
SATURN.saradap RIGHT JOIN SATURN.stvlevl ON saradap.saradap_levl_code=stvlevl.stvlevl_code,
SATURN.saradap RIGHT JOIN SATURN.stvapst ON saradap.saradap_apst_code=stvapst.stvapst_code,
SATURN.saradap RIGHT JOIN SATURN.stvadmt ON saradap.saradap_admt_code=stvadmt.stvadmt_code,
SATURN.saradap RIGHT JOIN SATURN.stvstyp ON saradap.saradap_styp_code=stvstyp.stvstyp_code,
SATURN.saradap RIGHT JOIN SATURN.stvcoll ON saradap.saradap_coll_code_1=stvcoll.stvcoll_code,
SATURN.saradap RIGHT JOIN SATURN.stvdegc ON saradap.saradap_degc_code_1=stvdegc.stvdegc_code,
SATURN.saradap RIGHT JOIN SATURN.stvmajr ON saradap.saradap_majr_code_1=stvmajr.stvmajr_code,
SATURN.saradap RIGHT JOIN SATURN.stvresd ON saradap.saradap_resd_code=stvresd.stvresd_code,
SATURN.stvterm RIGHT JOIN SATURN.stvacyr ON stvterm.stvterm_acyr_code=stvacyr.stvacyr_code,
SATURN.stvterm LEFT JOIN SATURN.saradap ON stvterm.stvterm_code=saradap.saradap_term_code_entry,
SATURN.sarappd LEFT JOIN SATURN.stvapdc ON sarappd.sarappd_apdc_code=stvapdc.stvapdc_code,
SATURN.saradap RIGHT JOIN SATURN.stvsite ON saradap.saradap_site_code=stvsite.stvsite_code,
SATURN.saradap RIGHT JOIN SATURN.stvsbgi ON saradap.saradap_sbgi_code=stvsbgi.stvsbgi_code,
SATURN.saradap RIGHT JOIN SATURN.stvcamp ON saradap.saradap_camp_code=stvcamp.stvcamp_code,
SATURN.saradap RIGHT JOIN SATURN.stvdept ON saradap.saradap_dept_code=stvdept.stvdept_code
GROUP BY saradap.saradap_pidm,
saradap.saradap_term_code_entry,
stvlevl.stvlevl_desc,
saradap.saradap_appl_date,
stvapst.stvapst_desc,
stvadmt.stvadmt_desc,
stvstyp.stvstyp_desc,
stvcoll.stvcoll_desc,
stvdegc.stvdegc_desc,
stvmajr.stvmajr_desc,
stvmajr.stvmajr_cipc_code,
stvresd.stvresd_desc,
stvresd.stvresd_in_state_ind,
stvterm.stvterm_desc,
stvacyr.stvacyr_desc,
saradap.saradap_full_part_ind,
stvapdc.stvapdc_desc,
stvsite.stvsite_desc,
stvsbgi.stvsbgi_type_ind,
stvsbgi.stvsbgi_srce_ind,
stvsbgi.stvsbgi_desc,
stvcamp.stvcamp_desc,
stvdept.stvdept_desc
ORDER BY saradap_pidm ASC);
DISCONNECT FROM oracle;
QUIT;
DATA Admissions;
SET Adm;
PROC CONTENTS DATA=Admissions;
RUN;
What am I doing wrong? Thanks in advanced.
I am new to SQL. I wrote a query to pull data from an Oracle database and can't get it to work. When I run it I get two error messages:
ERROR: ORACLE prepare error: ORA-00918: column ambiguously defined.
ERROR: SQL View WORK.ADM could not be processed because at least one of the data sets, or views, referenced directly (or indirectly) by it could not be located, or opened successfully.
Here is my code:
PROC SQL;
CONNECT TO oracle (user=SOCHA orapw=westwind02 path=PPRD);
CREATE VIEW Adm AS
SELECT * FROM connection to oracle
(SELECT saradap.saradap_pidm,
saradap.saradap_term_code_entry,
stvlevl.stvlevl_desc,
saradap.saradap_appl_date,
stvapst.stvapst_desc,
stvadmt.stvadmt_desc,
stvstyp.stvstyp_desc,
stvcoll.stvcoll_desc,
stvdegc.stvdegc_desc,
stvmajr.stvmajr_desc,
stvmajr.stvmajr_cipc_code,
stvresd.stvresd_desc,
stvresd.stvresd_in_state_ind,
stvterm.stvterm_desc,
stvacyr.stvacyr_desc,
saradap.saradap_full_part_ind,
stvapdc.stvapdc_desc,
stvsite.stvsite_desc,
stvsbgi.stvsbgi_type_ind,
stvsbgi.stvsbgi_srce_ind,
stvsbgi.stvsbgi_desc,
stvcamp.stvcamp_desc,
stvdept.stvdept_desc
FROM SATURN.saradap LEFT JOIN SATURN.sabsupl ON saradap.saradap_pidm=sabsupl.sabsupl_pidm AND saradap.saradap_term_code_entry=sabsupl.sabsupl_term_code_entry,
SATURN.sabsupl LEFT JOIN SATURN.sarappd ON sabsupl_pidm=sarappd_pidm AND sabsupl.sabsupl_term_code_entry=sarappd.sarappd_term_code_entry,
SATURN.saradap RIGHT JOIN SATURN.stvlevl ON saradap.saradap_levl_code=stvlevl.stvlevl_code,
SATURN.saradap RIGHT JOIN SATURN.stvapst ON saradap.saradap_apst_code=stvapst.stvapst_code,
SATURN.saradap RIGHT JOIN SATURN.stvadmt ON saradap.saradap_admt_code=stvadmt.stvadmt_code,
SATURN.saradap RIGHT JOIN SATURN.stvstyp ON saradap.saradap_styp_code=stvstyp.stvstyp_code,
SATURN.saradap RIGHT JOIN SATURN.stvcoll ON saradap.saradap_coll_code_1=stvcoll.stvcoll_code,
SATURN.saradap RIGHT JOIN SATURN.stvdegc ON saradap.saradap_degc_code_1=stvdegc.stvdegc_code,
SATURN.saradap RIGHT JOIN SATURN.stvmajr ON saradap.saradap_majr_code_1=stvmajr.stvmajr_code,
SATURN.saradap RIGHT JOIN SATURN.stvresd ON saradap.saradap_resd_code=stvresd.stvresd_code,
SATURN.stvterm RIGHT JOIN SATURN.stvacyr ON stvterm.stvterm_acyr_code=stvacyr.stvacyr_code,
SATURN.stvterm LEFT JOIN SATURN.saradap ON stvterm.stvterm_code=saradap.saradap_term_code_entry,
SATURN.sarappd LEFT JOIN SATURN.stvapdc ON sarappd.sarappd_apdc_code=stvapdc.stvapdc_code,
SATURN.saradap RIGHT JOIN SATURN.stvsite ON saradap.saradap_site_code=stvsite.stvsite_code,
SATURN.saradap RIGHT JOIN SATURN.stvsbgi ON saradap.saradap_sbgi_code=stvsbgi.stvsbgi_code,
SATURN.saradap RIGHT JOIN SATURN.stvcamp ON saradap.saradap_camp_code=stvcamp.stvcamp_code,
SATURN.saradap RIGHT JOIN SATURN.stvdept ON saradap.saradap_dept_code=stvdept.stvdept_code
GROUP BY saradap.saradap_pidm,
saradap.saradap_term_code_entry,
stvlevl.stvlevl_desc,
saradap.saradap_appl_date,
stvapst.stvapst_desc,
stvadmt.stvadmt_desc,
stvstyp.stvstyp_desc,
stvcoll.stvcoll_desc,
stvdegc.stvdegc_desc,
stvmajr.stvmajr_desc,
stvmajr.stvmajr_cipc_code,
stvresd.stvresd_desc,
stvresd.stvresd_in_state_ind,
stvterm.stvterm_desc,
stvacyr.stvacyr_desc,
saradap.saradap_full_part_ind,
stvapdc.stvapdc_desc,
stvsite.stvsite_desc,
stvsbgi.stvsbgi_type_ind,
stvsbgi.stvsbgi_srce_ind,
stvsbgi.stvsbgi_desc,
stvcamp.stvcamp_desc,
stvdept.stvdept_desc
ORDER BY saradap_pidm ASC);
DISCONNECT FROM oracle;
QUIT;
DATA Admissions;
SET Adm;
PROC CONTENTS DATA=Admissions;
RUN;
What am I doing wrong? Thanks in advanced.