Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Kako prikazati podatke iz tabele

[es] :: Oracle :: Kako prikazati podatke iz tabele

[ Pregleda: 884 | Odgovora: 9 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Kety

Član broj: 49094
Poruke: 53
*.dynamic.isp.telekom.rs.



+8 Profil

icon Kako prikazati podatke iz tabele12.10.2018. u 10:48 - pre 21 meseci
U tabelu se unose boje (pored ostalih podataka) tako da se u svako polje unese samo jedna boja.
U tabeli to treba da izgleda ovako:

ime boja1 boja2 boja3 boja4
_______________________________________
pera bela zuta plava zelena
mika zuta zelena
laza crvena
zika bela crvena zelena

Za prikaz sam koristila:

Code:
boja1||'/'||boja2||'/'||boja3||'/'||boja4 as boja


i tad dobijam:

pera bela/zuta/plava/zelena
mika zuta/zelena//
laza crvena///
zika bela/crvena/zelena/

ali to mi neje ok.

Zamolila bi ako neko ima ideju kako da
prikaz izgleda ovako:

pera bela/zuta/plava/zelena
mika zuta/zelena
laza crvena
zika bela/crvena/zelena
 
Odgovor na temu

djoka_l
Beograd

Član broj: 56075
Poruke: 2861



+1162 Profil

icon Re: Kako prikazati podatke iz tabele12.10.2018. u 11:34 - pre 21 meseci
Code (sql):
SELECT RTRIM(LTRIM(regexp_replace('//1//2////3//', '[/]+','/'), '/'),'/')
FROM DUAL


RTRIM skida '/' sa kraja
LTRIM skida '/' sa početka
regexp_replace zamenjuje jednu ili više pojava znaka '/' jednim znakom '/'

tvoju konkatenaciju stavi na mesto gde sam napisao '//1//2////3//'
 
Odgovor na temu

Kety

Član broj: 49094
Poruke: 53
*.dynamic.isp.telekom.rs.



+8 Profil

icon Re: Kako prikazati podatke iz tabele15.10.2018. u 11:19 - pre 20 meseci
Mozda nisam lepo objasnila, ustvari pokušala sam da pojednostavim.
U poljima boja1, boja2, boja3, boja4 unosi se rgb boje (kombinacija je baš mnogo).
Tvoj upit je odličan kad bi imala par naziva i upisala ih u deo gde je 1,2,3..
Umesto 1,2,3... unela sam nazive kolona ali on ne čita njihov sadrzaj.
 
Odgovor na temu

djoka_l
Beograd

Član broj: 56075
Poruke: 2861



+1162 Profil

icon Re: Kako prikazati podatke iz tabele15.10.2018. u 11:28 - pre 20 meseci
Pa unesi
boja1||'/'||boja2||'/'||boja3||'/'||boja4
umesto
'//1//2////3//'

Ako ti ovo ne rešava problem, daj CREATE naredbu za testnu tabelu, INSERT za nekoliko redova, pa ćemo bolje da se razumemo.
 
Odgovor na temu

bokinet

Član broj: 29844
Poruke: 413



+35 Profil

icon Re: Kako prikazati podatke iz tabele15.10.2018. u 12:12 - pre 20 meseci
Mozda ovo moze da pomogne

https://blogs.oracle.com/sql/h...with-sql-aka-pivot-and-unpivot

https://www.techonthenet.com/oracle/pivot.php

p.s. nisam odavno radio s' oracle dbms
 
Odgovor na temu

Kety

Član broj: 49094
Poruke: 53
*.dynamic.isp.telekom.rs.



+8 Profil

icon Re: Kako prikazati podatke iz tabele15.10.2018. u 12:26 - pre 20 meseci
Kad zamenim ovako:

Code:
SELECT RTRIM(LTRIM(regexp_replace('boja1||'/'||boja2||'/'||boja3||'/'||boja4', '[/]+','/'), '/'),'/')
FROM BOJE


dobijem:

RTRIM(LTRIM(regexp_replace('boja1||'/'||boja2||'/'||boja3||'/'||boja4', '[/]+','/'), '/'),'/')
-------------------------------------------------------------------------------------------------
boja1/boja2/boja3/boja4


Code:
CREATE TABLE BOJE (IDB, IME, BOJA1, BOJA2, BOJA3, BOJA4);


Code:
INSERT INTO BOJE (IDB, IME, BOJA1, BOJA2, BOJA3, BOJA4)
VLUES (1,'PERA PERIC','ff0000','ff0250','ff0245','9e2323');
INSERT INTO BOJE (IDB, IME, BOJA1, BOJA2, BOJA3, BOJA4)
VLUES (1,'MIKA MIKIC','8a96af','16336f','17536f','36336f');
INSERT INTO BOJE (IDB, IME, BOJA1, BOJA2, BOJA3, BOJA4)
VLUES (1,'ZIKA ZIKIC','b0c3ae','163c11');
INSERT INTO BOJE (IDB, IME, BOJA1, BOJA2, BOJA3, BOJA4)
VLUES (1,'LAZA LAZIC','002200');
INSERT INTO BOJE (IDB, IME, BOJA1, BOJA2, BOJA3, BOJA4)
VLUES (1,'MIKA MIKIC','86804a','bfaf28','69685f');




 
Odgovor na temu

Kety

Član broj: 49094
Poruke: 53
*.dynamic.isp.telekom.rs.



+8 Profil

icon Re: Kako prikazati podatke iz tabele15.10.2018. u 13:02 - pre 20 meseci
@bokinet hvala ti na trudu ali mi pivot ne resava problem.
Ja imam ok prikaz iz tabele:
pera bela zuta plava zelena
mika zuta zelena
laza crvena
zika bela crvena zelena

ali bi htela izmedju boja da postoji crtica, a to onda izgleda ovako:
pera bela/zuta/plava/zelena
mika zuta/zelena//
laza crvena///
zika bela/crvena/zelena/

a trebalo bi:
pera bela/zuta/plava/zelena
mika zuta/zelena
laza crvena
zika bela/crvena/zelena
 
Odgovor na temu

djoka_l
Beograd

Član broj: 56075
Poruke: 2861



+1162 Profil

icon Re: Kako prikazati podatke iz tabele15.10.2018. u 14:00 - pre 20 meseci
Citat:
Kety:
Kad zamenim ovako:

Code:
SELECT RTRIM(LTRIM(regexp_replace('boja1||'/'||boja2||'/'||boja3||'/'||boja4', '[/]+','/'), '/'),'/')
FROM BOJE


dobijem:

RTRIM(LTRIM(regexp_replace('boja1||'/'||boja2||'/'||boja3||'/'||boja4', '[/]+','/'), '/'),'/')
-------------------------------------------------------------------------------------------------
boja1/boja2/boja3/boja4



Pa, skloni navodnike oko konkatenacije polja, dakle NE:
'boja1||'/'||boja2||'/'||boja3||'/'||boja4'

NEGO:
boja1||'/'||boja2||'/'||boja3||'/'||boja4
 
Odgovor na temu

djoka_l
Beograd

Član broj: 56075
Poruke: 2861



+1162 Profil

icon Re: Kako prikazati podatke iz tabele15.10.2018. u 14:07 - pre 20 meseci
Stvarno, Kety, ni test primer nisi napravila da bude sintaksno ispravan:

Code (sql):

CREATE TABLE BOJE (IDB NUMBER, IME varchar2(50), BOJA1 varchar2(50), BOJA2 varchar2(50), BOJA3 varchar2(50), BOJA4 varchar2(50));
INSERT INTO BOJE (IDB, IME, BOJA1, BOJA2, BOJA3, BOJA4)
VALUES (1,'PERA PERIC','ff0000','ff0250','ff0245','9e2323');
INSERT INTO BOJE (IDB, IME, BOJA1, BOJA2, BOJA3, BOJA4)
VALUES (1,'MIKA MIKIC','8a96af','16336f','17536f','36336f');
INSERT INTO BOJE (IDB, IME, BOJA1, BOJA2, BOJA3, BOJA4)
VALUES (1,'ZIKA ZIKIC','b0c3ae','163c11',NULL,NULL);
INSERT INTO BOJE (IDB, IME, BOJA1, BOJA2, BOJA3, BOJA4)
VALUES (1,'LAZA LAZIC','002200',NULL,NULL,NULL);
INSERT INTO BOJE (IDB, IME, BOJA1, BOJA2, BOJA3, BOJA4)
VALUES (1,'MIKA MIKIC','86804a','bfaf28','69685f',NULL);

SELECT RTRIM(LTRIM(regexp_replace(boja1||'/'||boja2||'/'||boja3||'/'||boja4, '[/]+','/'), '/'),'/')
FROM BOJE;

DROP TABLE boje;
 


Code:

Table BOJE created.


1 row inserted.


1 row inserted.

1 row inserted.


1 row inserted.


1 row inserted.

RTRIM(LTRIM(REGEXP_REPLACE(BOJA1||'/'||BOJA2||'/'||BOJA3||'/'||BOJA4,'[/]+','/'),'/'),'/')                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
-------------------------------------------------------------------------------------------------------
ff0000/ff0250/ff0245/9e2323                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
8a96af/16336f/17536f/36336f                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
b0c3ae/163c11                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
002200                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
86804a/bfaf28/69685f                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       


Table BOJE dropped.


 
Odgovor na temu

Kety

Član broj: 49094
Poruke: 53
*.dynamic.isp.telekom.rs.



+8 Profil

icon Re: Kako prikazati podatke iz tabele15.10.2018. u 14:19 - pre 20 meseci
Izvini, u pravu si i prihvatam kritiku.
Puno ti hvala na pomoći, odlično radi :)
 
Odgovor na temu

[es] :: Oracle :: Kako prikazati podatke iz tabele

[ Pregleda: 884 | Odgovora: 9 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.