SELECT raises exception in PL/pgSQL function

前端 未结 1 1810
暗喜
暗喜 2020-12-07 05:59

I want to implement a loop inside a function but I receive this error:

ERROR query has no destination for result data

The code:<

相关标签:
1条回答
  • 2020-12-07 06:07

    The manual instructs:

    Sometimes it is useful to evaluate an expression or SELECT query but discard the result, for example when calling a function that has side-effects but no useful result value. To do this in PL/pgSQL, use the PERFORM statement:

    PERFORM query;
    

    Unless you assign the result, replace

    SELECT 1;
    

    with

    PERFORM 1;
    
    0 讨论(0)
提交回复
热议问题