I have this api_call in oracle sql like this:
select sb_transfer_crse.f_query_all('000497') from dual;
The response looks like this:
SHBTATC_SBGI_CODE SHBTATC_PROGRAM SHBTATC_TLVL_CODE SHBTATC_SUBJ_CODE_TRNS SHBTATC_CRSE_NUMB_TRNS SHBTATC_TRNS_TITLE
------ ------------ -- ---------------------------------------------------------------------------------
000497 ...... UG AAA 010 Acad Achievement Pre-College
000497 ...... UG AAA 050 Semester Survival
000497 ...... UG AAA 070 Special Topics
000497 ...... UG AAA 071 Special Topics
000497 ...... UG AAA 072 Special Topics
000497 ...... UG AAA 073 Special Topics
I am trying to pass the response data into variables either to handle one a time in a loop or if possible take them all and export to a temp/new table
What i have so far looks like this:
Declare
--variables for query
VAR_p_sbgi_code shbtatc.shbtatc_sbgi_code%TYPE;
--Variables for Data being returned
VAR_r_sbgi_code shbtatc.shbtatc_sbgi_code%TYPE;
VAR_r_program shbtatc.shbtatc_program%TYPE;
VAR_r_tlvl_code shbtatc.shbtatc_tlvl_code%TYPE;
VAR_r_subj_code_trns shbtatc.shbtatc_subj_code_trns%TYPE;
VAR_r_crse_numb_trns shbtatc.shbtatc_crse_numb_trns%TYPE;
VAR_r_trns_title shbtatc.shbtatc_trns_title%TYPE;
Begin
select sb_transfer_crse.f_query_all(p_sbgi_code => VAR_p_sbgi_code)
INTO VAR_r_sbgi_code,VAR_r_program,VAR_r_tlvl_code,VAR_r_subj_code_trns,VAR_r_crse_numb_trns,VAR_r_trns_title
From Dual;
End;
The problem is I am used to dealing with getting one result/response, not 6. and I'm not sure how to loop through the results?
Any help would be appreciated.
This is the function:
Function f_query_all(p_sbgi_code shbtatc.shbtatc_sbgi_code%TYPE,
p_program shbtatc.shbtatc_program%TYPE DEFAULT NULL)
RETURN transfer_crse_ref
This is what transfer_crse_ref is:
transfer_crse_ref
TYPE transfer_crse_ref IS REF CURSOR RETURN transfer_crse_rec;
Entity cursor variable type
and this is what transfer_crse_rec looks like:
transfer_crse_rec
TYPE transfer_crse_rec IS RECORD (
r_sbgi_code shbtatc.shbtatc_sbgi_code%TYPE,
r_program shbtatc.shbtatc_program%TYPE,
r_tlvl_code shbtatc.shbtatc_tlvl_code%TYPE,
r_subj_code_trns shbtatc.shbtatc_subj_code_trns%TYPE,
r_crse_numb_trns shbtatc.shbtatc_crse_numb_trns%TYPE,
r_term_code_eff_trns shbtatc.shbtatc_term_code_eff_trns%TYPE,
r_trns_title shbtatc.shbtatc_trns_title%TYPE,
r_trns_low_hrs shbtatc.shbtatc_trns_low_hrs%TYPE,
r_trns_high_hrs shbtatc.shbtatc_trns_high_hrs%TYPE,
r_trns_review_ind shbtatc.shbtatc_trns_review_ind%TYPE,
r_tast_code shbtatc.shbtatc_tast_code%TYPE,
r_trns_catalog shbtatc.shbtatc_trns_catalog%TYPE,
r_tgrd_code_min shbtatc.shbtatc_tgrd_code_min%TYPE,
r_group shbtatc.shbtatc_group%TYPE,
r_group_primary_ind shbtatc.shbtatc_group_primary_ind%TYPE,
r_protect_ind shbtatc.shbtatc_protect_ind%TYPE,
r_crse_desc shbtatc.shbtatc_crse_desc%TYPE,
r_user_id shbtatc.shbtatc_user_id%TYPE,
r_data_origin shbtatc.shbtatc_data_origin%TYPE,
r_internal_record_id gb_common.internal_record_id_type);
Business Entity record type
Ok with the help of @justinCave when they mentioned the ref_cursor i was able to figure out a solution that gives me the results in a way I can get the data to variables: