![](/img/trans.png)
[英]What is the Microsoft SQL Server equivalent to Postgres Function DATE_PART?
[英]What is the Postgres equivalent of SQL Server's If Exists(
我有一個想在Postgres中使用的T-SQL查詢。 我是Postgres的新手,我想知道If Exists
以及Print
或等效If Exists
是否可行。
基本上,它只是檢查表中是否有任何信息,是否存在,然后調用存儲過程,如果沒有,則在日志中不報告任何內容,這部分不是真正需要的,但我想知道盡可能打印。
IF Exists(Select * from [mytable]
Having Count(*) > 0)
EXEC sp_someprocedure
ELSE
PRINT 'Table Empty: Nothing to report.'
當然可以,例如:
do $$begin
if exists (select * from yourtable) then
perform your_function();
else
raise notice 'nothing to report';
end if;
end$$;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.