Re: [SQL] From with case

2013-03-26 Thread Pavel Stehule
2013/3/26 Pavel Stehule : > Hello > > 2013/3/26 Ben Morrow : >> Quoth pavel.steh...@gmail.com (Pavel Stehule): >>> Dne 25.3.2013 23:51 "Ben Morrow" napsal(a): >>> > >>> > I would use a view for this: >>> > >>> > create view vale_any as >>> > select 'P'::text "type", v.adiant, v.desc_per, v

Re: [SQL] From with case

2013-03-26 Thread Pavel Stehule
Hello 2013/3/26 Ben Morrow : > Quoth pavel.steh...@gmail.com (Pavel Stehule): >> Dne 25.3.2013 23:51 "Ben Morrow" napsal(a): >> > >> > I would use a view for this: >> > >> > create view vale_any as >> > select 'P'::text "type", v.adiant, v.desc_per, v.cod >> > from valepag v >> >

Re: [SQL] From with case

2013-03-25 Thread Ben Morrow
Quoth pavel.steh...@gmail.com (Pavel Stehule): > Dne 25.3.2013 23:51 "Ben Morrow" napsal(a): > > > > I would use a view for this: > > > > create view vale_any as > > select 'P'::text "type", v.adiant, v.desc_per, v.cod > > from valepag v > > union all > > select 'R', v.adiant,

Re: [SQL] From with case

2013-03-25 Thread Pavel Stehule
This design has a performance problem. You read both tables everywhere - for large tables can be bad Dne 25.3.2013 23:51 "Ben Morrow" napsal(a): > > Quoth c...@sygecom.com.br (Mauricio Cruz): > > > > I'm working in a PL/SQL and I'd like to use the same > > PL for 2 kinds of tables... > > > > I hav

Re: [SQL] From with case

2013-03-25 Thread Ben Morrow
Quoth c...@sygecom.com.br (Mauricio Cruz): > > I'm working in a PL/SQL and I'd like to use the same > PL for 2 kinds of tables... > > I have "valepag" and "valerec" both tables > have the same columns, but one is for debit and the other one is for > credit, the PL will work for both cases > >

Re: [SQL] From with case

2013-03-25 Thread Mauricio Cruz
Thanks very much Pavel, the dynamic SQL ideia has work perfect in my case. Thanks so much. -- Grato, Mauricio Cruz Sygecom Informática 51 3442-3975 / 3442-2345 On Mon, 25 Mar 2013 15:01:09 +0100, Pavel Stehule wrote: > Hello > > >> For rSql in select a.adiant, >>a.de

Re: [SQL] From with case

2013-03-25 Thread Pavel Stehule
Hello > For rSql in select a.adiant, >a.desc_per > from case > when cTip='P' > then valapag > else valerec >end > where cod=2 Loop you can use a dynamic SQL, but