9
I have a question to generate a report, I need it to take the data of an SQL table and in the place in 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 trial
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, he 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 put the column Dice, there I did the gambiarra to put the "fixed", but I need it dynamically, I hope you have been able to explain.
I even managed to make a select that searches for this data, but did not know how to relate it to my column, if anyone 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';
A trial by returning a select was no longer enough? Do you really need to do all that you did at Trial? one report is different from the other, so it is natural that there is a precedent for each report. Just create other procedures with the same format and modify the data you want different.
– Marciano.Andrade
yes, will be made 2 Precedent, 1 for each report, I just want to know, how do I for those values that are in the column are filled dynamically, today they are fixed, and for the other proc, how to do to fill the column field with the column name, I hope you’ve been able to explain it correctly. As for the final result, the client wants it to be presented in this way that it is on the screen, as it generates result. Thank you
– Jaqueson
See if Asktom helps https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2170326695312 https://asktom.oracle.com/pls/apex/f?p=100:11:0:::::P11_QUESTON_ID:470474702614
– Motta
I don’t have an environment to test, but it seems to me that what you need is a query using the UNPIVOT command.
– Pagotti