How to assign multiple variable and string in a variable in postgresql

家住魔仙堡 提交于 2019-12-13 02:49:55

问题


I want to assign multiple values or string or their combination to a postgresql variable. What I want to achieve is something like this done in DB2:

STRING '('              DELIMITED BY SIZE           
       variable_1       DELIMITED BY SPACE          
       ' '              DELIMITED BY SIZE           
       variable_2                        
                        DELIMITED BY SIZE           
       variable_3       DELIMITED BY SIZE           
       ' ) '            DELIMITED BY SIZE           
       X'10'            DELIMITED BY SIZE           
     INTO    var_string                            
 END-STRING

In the same way i have some variables and string which I want to add in a variable "var_string". Is it possible?


回答1:


Try CONCAT Function

 DECLARE var_string varchar;
 var_string:= concat(variable_1, variable_2,variable_3);


来源:https://stackoverflow.com/questions/48540432/how-to-assign-multiple-variable-and-string-in-a-variable-in-postgresql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!