简体   繁体   中英

why does not execute statement query in postgresql?

I have write below query in function which executes through trigger.

SELECT report_date INTO logdate FROM agent_statistics WHERE agentid =             
    NEW.caller_id_name AND report_date = DATE(NEW.start_stamp);
SELECT COUNT(*) INTO outbound FROM cdr WHERE (caller_id_name = 
    NEW.caller_id_name AND direction = 'outbound' AND 
    DATE(NEW.start_stamp) = logdate);
SELECT COUNT(*) INTO consult FROM cdr WHERE (caller_id_name =
    NEW.caller_id_name AND direction = 'outbound' AND 
    DATE(NEW.start_stamp) = logdate AND billsec > '0');

Here, logdate value gives proper date. But, outbound and consult gives all rows from table. means previous date also include which is not to include. I need only current date total rows.

replace your DATE(NEW.start_stamp) = logdate); with start_stamp = logdate);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM