I have a question for generating a report, I need it to get the data from an SQL table and instead the name of the precise table of its ID, below the data that the query generates
COD_CLIENTE NOME ENDERECO CPF
-----------------------------------------------------------------------
2 Fulano Av. Rio Branco 2837462890
3 Ciclano Rua Zero 4625427282
4 Beltrano Rua Doze 2634623637
I created this procedure
create or replace PROCEDURE COLUNAS_TESTE AS
Cursor linha is
Select cod_cliente, nome, endereco, cpf from clientes where rownum < 4;
rLin linha%rowtype;
BEGIN
Open linha;
Loop
Fetch linha into rLin;
Exit when linha%notFound;
dbms_output.put_line('Linha: '||rLin.cod_cliente||' Coluna: 2'||' Valor: '||rLin.Nome);
dbms_output.put_line('Linha: '||rLin.cod_cliente||' Coluna: 3'||' Valor: '||rLin.Endereco);
dbms_output.put_line('Linha: '||rLin.cod_cliente||' Coluna: 4'||' Valor: '||rLin.CPF);
End loop;
Close linha;
END;
That generates this result
Linha: 2 Coluna: 2 Valor: Fulano
Linha: 2 Coluna: 3 Valor: Av. Rio Branco
Linha: 2 Coluna: 4 Valor: 2837462890
Linha: 3 Coluna: 2 Valor: Ciclano
Linha: 3 Coluna: 3 Valor: Rua Zero
Linha: 3 Coluna: 4 Valor: 4625427282
Linha: 4 Coluna: 2 Valor: Beltrano
Linha: 4 Coluna: 3 Valor: Rua Doze
Linha: 4 Coluna: 4 Valor: 2634623637
Line and value OK, it takes the code, but I need 2 reports, one that in the place of the column he put the name of the field, and another that puts the index of the column, there I made the gambiarra to put the "fixed "but I need it dynamically, I hope it has been able to explain.
I even managed to do a select one that searches for this data, but I could not relate it to my column if someone can help and I have been able to explain the problem.
select COLUNAS.COLUMN_ID AS COLUNAS_ID ,COLUNAS.COLUMN_NAME AS COLUNAS_NOME
from USER_TAB_COLUMNS COLUNAS
where COLUNAS.TABLE_NAME = 'CLIENTES';