O problema tb está sendo com várias funções que utilizam o ||, com integer, float, etc... tenho que mudar todas as minhas funções? (tenho só 97 funções para abrir e ver o q tem || rrsrs)
2009/4/27 Osvaldo Kussama <[email protected]> > 2009/4/27 André Pignata <[email protected]>: > > A resposta que o Vinícius me enviou ajudou muito só que estou tendo > > problemas com ||, ele dá erro de typecast > > ERROR: operator is not unique: unknown || date at character 199 > > Em outras funções em que utilizo o || ocorre o mesmo problema. > > Abaixo segue um exemplo de função: > > > > CREATE OR REPLACE FUNCTION "public"."acumula_fatura" (portadores_port > > integer, tipotitulos_tptitulo integer, data_limite date, coduniop > integer) > > RETURNS numeric AS > > $body$ > > /* New function body */ > > declare > > rfaturatmp RECORD; > > rfaturatmpdet RECORD; > > rclitit record; > > rMesFat record; > > squery varchar; > > sQMesFat varchar; > > i integer; > > begin > > squery := 'select * from vfaturatmp where (vfaturatmp.status = > ''S'') > > and (vfaturatmp.ntitulo <> '''') and ((vfaturatmp.nfatura = '''') or > > (vfaturatmp.nfatura is null)) and (vfaturatmp.dtvencto <= > > '''||"data_limite"||''')'; > > if "portadores_port" <> 0 then > > squery := squery||' and (vfaturatmp.clientesfat_portadores_port = > > '||"portadores_port"||')'; > > end if; > > if "tipotitulos_tptitulo" <> 0 then > > squery := squery||' and > (vfaturatmp.clientesfat_tipotitulos_tptitulo > > = '||"tipotitulos_tptitulo"||')'; > > end if; > > squery := squery|| ' order by dtvencto'; > > Raise notice '%', sQuery; > > i := 0; > > > > sQMesFat := 'select max(dtvencto)as dt,clientesfat_codcli from > vfaturatmp > > where (vfaturatmp.status = ''S'') and (vfaturatmp.ntitulo <> '''') and > > ((vfaturatmp.nfatura = '''') or (vfaturatmp.nfatura is null)) and > > (vfaturatmp.dtvencto <= '''||"data_limite"||''')'; > > if "portadores_port" <> 0 then > > sQMesFat := sQMesFat||' and > (vfaturatmp.clientesfat_portadores_port > > = '||"portadores_port"||')'; > > end if; > > if "tipotitulos_tptitulo" <> 0 then > > sQMesFat := sQMesFat||' and > > (vfaturatmp.clientesfat_tipotitulos_tptitulo = > > '||"tipotitulos_tptitulo"||')'; > > end if; > > sQMesFat := sQMesFat||' group by clientesfat_codcli'; > > Raise notice '%', sQMesFat; > > > > for rMesFat IN EXECUTE sQMesFat loop > > raise notice '%-%',rMesFat.clientesfat_codcli,lpad(extract(month > > from rMesFat.dt + interval '1 month' ),2,'0')||'/'||extract(year from > > rMesFat.dt + interval '1 month'); > > update clienteplanopreco set mesfat = lpad(extract(month from > > rMesFat.dt + interval '1 month' ),2,'0')||'/'||extract(year from > rMesFat.dt > > + interval '1 month') > > where clientes_codcli = (select * from > > fatura_para(rMesFat.clientesfat_codcli,0)) and dtcanc is null; > > > > > > > > end loop; > > > > --raise exception 'chegou aqui'; > > > > FOR rfaturatmp IN EXECUTE squery loop > > insert into fatura values > > (rfaturatmp.filial_nfilial, > > "coduniop", > > rfaturatmp.ntitulo, > > rfaturatmp.clientesfat_codcli, > > rfaturatmp.clientesfat_coddep, > > rfaturatmp.vlrliquido, > > rfaturatmp.vlrbruto, > > rfaturatmp.vlrdesc, > > rfaturatmp.vlrmulta, > > rfaturatmp.vlracresc, > > rfaturatmp.dtemissao, > > rfaturatmp.dtvencto, > > null, > > null, > > null, > > rfaturatmp.vlrirrf, > > rfaturatmp.vlrimpostos, > > null, > > 1, > > extract(day from date (CAST(rfaturatmp.dtvencto AS > DATE))), > > rfaturatmp.vlrdesc, > > rfaturatmp.vlracresc, > > rfaturatmp.clientesfat_tipotitulos_tptitulo, > > rfaturatmp.clientesfat_portadores_port); > > --atualizando mes de faturamento > > > > for rfaturatmpdet in select * from faturatmpdet where > > faturatmpdet.faturatmp_clientesfat_codcli = rfaturatmp.clientesfat_codcli > > and faturatmpdet.faturatmp_clientesfat_coddep = > > rfaturatmp.clientesfat_coddep and faturatmpdet.faturatmp_dtvencto = > > rfaturatmp.dtvencto loop > > --gerando faturadet > > select clientes.categoriascliente_codcateg, > > clientes.categoriascliente_subcateg, clientes.grupos_codgrupo from > clientes > > where clientes.codcli = rfaturatmpdet.clientes_codcli and clientes.coddep > = > > 0 into rclitit; > > > > insert into faturadet values ( > > nextval('faturadet_codfaturadet_seq'), > > rfaturatmp.filial_nfilial, > > rfaturatmp.ntitulo, > > null, > > rfaturatmpdet.clienteplanopreco_planos_codplano, > > rfaturatmpdet.qtde, > > rfaturatmpdet."clienteplanopreco_valor_vlrbruto", > > rfaturatmpdet.vlracresc, > > rfaturatmpdet.vlrdesc, > > rfaturatmpdet.vlrliquido, > > rfaturatmpdet."clienteplanopreco_valor_vlrbruto", > > 0, > > 0, > > rfaturatmpdet.vlrtaxaimplanta, > > 1, > > rfaturatmp.numnf, > > 'N', > > null, > > rfaturatmpdet.clienteplanopreco_vendedores_codven, > > rfaturatmpdet.clienteplanopreco_vendedores_codsup, > > rfaturatmpdet.clienteplanopreco_vendedores_codger, > > null, > > null, > > rclitit.categoriascliente_codcateg, > > rclitit.categoriascliente_subcateg, > > rclitit.grupos_codgrupo, > > "coduniop", > > rfaturatmpdet.clienteplanopreco_planos_codplano, > > rfaturatmpdet.clientes_codcli, > > rfaturatmpdet.clientes_coddep, > > rfaturatmpdet.flag_taxaimplanta > > ); > > > > RAISE NOTICE ' det é %', > rfaturatmpdet.faturatmp_dtvencto; > > end loop; > > > > > > > > RAISE NOTICE 'fat e %', rfaturatmp.ntitulo; > > i := i +1; > > insert into contareceber values ( > > rfaturatmp.filial_nfilial, > > "coduniop", > > rfaturatmp.ntitulo, > > null, > > null, > > null, > > rfaturatmp.clientesfat_portadores_port, > > rfaturatmp.clientesfat_codcli, > > rfaturatmp.clientesfat_coddep, > > rfaturatmp.clientesfat_tipotitulos_tptitulo, > > rfaturatmp.ntitulo, > > rfaturatmp.filial_nfilial, > > "coduniop", > > rfaturatmp.dtemissao, > > rfaturatmp.dtvencto, > > null, > > rfaturatmp.clientesfat_grupos_codgrupo, > > null, > > rfaturatmp.vlracresc, > > rfaturatmp.vlrdesc, > > 'N', > > now(), > > null, > > null, > > false, > > rfaturatmp.vlrliquido,'C',null,rfaturatmp.parcela); > > > > > > > > > > delete from faturatmp where faturatmp.clientesfat_codcli = > > rfaturatmp.clientesfat_codcli and faturatmp.clientesfat_coddep = > > rfaturatmp.clientesfat_coddep and faturatmp.dtvencto = > rfaturatmp.dtvencto; > > end loop; > > > > > > > > return i; > > end > > $body$ > > LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER; > > > > > Se você está montando uma string então transforme seu campo date em > uma string para concatena-lo. > ... and (vfaturatmp.dtvencto <= ''' || to_char(data_limite, > 'YYYY-MM-DD') || '''::date);'; > > Osvaldo > _______________________________________________ > pgbr-geral mailing list > [email protected] > https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral > -- André Luiz Martins Pignata Albert Einstein<http://www.brainyquote.com/quotes/authors/a/albert_einstein.html> - "Only two things are infinite, the universe and human stupidity, and I'm not sure about the f...
_______________________________________________ pgbr-geral mailing list [email protected] https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
