如何在postgresql中声明变量? [英] How to declare variables in postgresql?

查看:1500
本文介绍了如何在postgresql中声明变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,



我是postgresql的新手。我必须在函数内声明变量以进行内部计算。



我使用以下语法:

声明num1 int;



但它给了我错误:

语法错误在int或附近。



可以有人建议我解决吗?

任何形式的帮助都非常值得赞赏。



谢谢大家。

解决方案

以下是您要找的内容: PostgreSQL文档:声明 [ ^ ]



int 或附近的消息语法错误意味着 int 尚未被识别为正确的数据类型;)请参阅: PostgreSQL文档:数据类型 [ ^ ]


< blockquote>您可以通过过程/函数中的以下行声明变量。



DECLARE变量名整数;

DECLARE变量名字符变化;


Dear all,

I am newbie to postgresql. I have to declare variable inside a function for internal calculation.

I am using following syntax:
Declare num1 int;

But it's giving me error:
syntax error at or near int.

Can anybody suggest me any solution?
Any kind of help is highly appreciable.

Thank you to all.

解决方案

Here is what you're looking for: PostgreSQL Documentation: Declarations[^]

The message syntax error at or near int means that int hasn't been recognized as proper data type ;) Please see: PostgreSQL documentation: Data types[^]


You can declare the variable by the following line in your procedure/function.

DECLARE variablename integer;
DECLARE variablename character varying;


这篇关于如何在postgresql中声明变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆