In Oracle, the dataset is merged (multiple rows and one row), and the relationship between table A and table B is one-to-many. Query all the data in Table A and merge A project in Table B corresponding to Table A into one row,
In Oracle, the dataset is merged (multiple rows and one row), and the relationship between table A and table B is one-to-many. Query all the data in Table A and merge A project in Table B corresponding to Table A into one row,
In Oracle, the dataset is merged (multiple rows and one row), and the relationship between table A and table B is one-to-many.
Requirements:
Query all the data in Table A and merge A project in Table B corresponding to Table A into A row separated.
ORACLE FUNCTION
Create or replace function FUN_GETNAME (
ID IN NUMBER
) RETURN VARCHAR2
IS
RESULT_OUT VARCHAR2 (20000 );
BEGIN
Declare cursor C_CUR is select ctaskid from TABLE_ B WHERE CID = ID ORDER BY CTASKID;
BEGIN
For rowstr in C_CUR LOOP
RESULT_OUT: = RESULT_OUT | ',' | ROWSTR. CTASKID;
End loop;
END;
RESULT_OUT: = SUBSTR (RESULT_OUT, 2 );
RETURN RESULT_OUT;
END;
/
SQL statement for Data Query:
Select a. ID, A. NAME, A. FLAG, A. DELETE_FLAG, FUN_GETNAME (A. CODE) as sch from TABLE_A order by a. ID, SCH
Same data in Oracle merge tables