Function Syntax involving pipes and ' marks?
От | Ruben Gouveia |
---|---|
Тема | Function Syntax involving pipes and ' marks? |
Дата | |
Msg-id | 51e507b0809091620k91f5576w722d708b1043e8ed@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: Function Syntax involving pipes and ' marks?
Re: Function Syntax involving pipes and ' marks? |
Список | pgsql-sql |
<div dir="ltr">No matter how many times i try, i can't seem to get the write amount of ' marks around the date parametersin my v_where declaration. What am i doing wrong here?<br /><br />v_stmt should look like this if done correctly:<br/><br />select count(distinct <a href="http://m.id">m.id</a>) <br /><span style="color: rgb(204, 0, 0);">from(select id, greatest(max(last_p),max(last_b)) as date_created from job group by id) m where m.jb_date < '2008-08-29'and m.jb >='2008-08-28'. </span><br /> when instead it's coming out like this:<br /><span style="color: rgb(204,0, 0);">select count(distinct <a href="http://m.id">m.id</a>) from (select id, greatest(max(last_periodic),max(last_boot))as date_created from mediaportal group by id) m where m.date_created < 2008-08-29and m.date_created >=2008-08-28 . </span><br /> ...no tick marks around the dates.<br /><br />here's my code:<br/><br />CREATE OR REPLACE FUNCTION fcn_job(p_date date, <br /> p_typevarchar,<br /> p_jobid numeric)<br /> RETURNS numeric AS $$<br /><br />DECLARE<br/> v_job numeric := 0;<br /> v_stmt varchar(1024);<br /> <span style="color: rgb(204, 0, 0);"> v_wherevarchar(256) := 'where m.jb_date < '||p_date + integer '1'||</span><br style="color: rgb(204, 0, 0);" /><span style="color:rgb(204, 0, 0);"> ' and m.jb_date >='||p_date||'';</span><br /> <br /><br />BEGIN<br /> v_stmt := fcn_gen_statement(p_type, v_where, p_newonly);<br/> execute v_stmt into v_job;<br /> RAISE NOTICE 'sql looks like this: % . ',v_stmt;<br /> returnv_job;<br />END;<br />$$ LANGUAGE plpgsql;<br /><br /><br /></div>
В списке pgsql-sql по дате отправления: