问题标签 [postgresql-8.3]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
62 浏览

greenplum - 无法在使用 postgresql 8.3 的 greenplum 中的查询中获取序列的 currval 或 lastval

我试图在不编写函数的情况下解决查询中的问题。我有一个表,其中包含如下用户信息:

我需要将其制作为 SCD-Type II 表,如下所示:

我认为实现这一点的是:

一步:temp_table1:

第二步:

临时表2:

在此之后,我可以如下查询并获得所需的结果:

我创建了第 1 步,但未能创建 temp_table2(第 2 步)。我正在使用以下查询来完成此操作:

结果为:temp_table2:

有人可以帮助解决这个问题吗?我使用正确的方法吗?提前致谢!!!

0 投票
2 回答
393 浏览

sql - Are these two PostgreSQL functions equivalent? (RETURNS TABLE and RETURNS SETOF)

I am dealing with two PostgreSQL installs at the same time: My local environment and the real remote server. Sadly the server has an old version (8.3.11) and my local environment is newer (9.4).

I don't have means to update the remote server at the moment, so I am converting a function that runs well in 9.4 (it uses RETURNS TABLE) to a function that should be fine in 8.3.11 (it should use RETURNS SETOF).

But while the local environment function works well and it gives good results, the remote one always yields no result (using the very same tables!)

So, are these two fully equivalent?

Newer function for local environment:

And here the function I have modified to use SETOF

It gives no error message at all, it runs ok, but it just yields no results (it always raises the exception message), so I am wondering whether there is something wrongly set up in the SETOF query ...

0 投票
2 回答
1046 浏览

sql - 在 EXECUTE 上传递 ROWTYPE 参数

我正在 Postgres 中开发一个函数,旨在为查询的每条记录恢复一组函数中包含的检查结果的值。这些函数中只有一个会返回正确的值。这些函数有一个公共前缀“fn_condicao_”,并接收一个“my_table”类型的对象作为参数。

由于进行检查的函数数量未知,我决定查阅 Postgres 目录,从表中pg_catalog.pg_proc搜索前缀为“fn_condicao_”的函数并使用 EXECUTE 动态执行它们。

我的问题是如何为EXECUTE传递正确的形状参数。

如何v_record正确传递上述函数中的注释EXECUTE命令?

示例函数:

0 投票
1 回答
224 浏览

postgresql - 聚合函数以保留特定值,具体取决于其他列

我有以下格式的数据

有没有一种按 id_A 分组的好方法,同时保持 id_A = Id_B 行的值?

我需要汇总的原因是,如果没有这样的线,我想要平均值。

结果应如下所示:

我想出了以下内容,但那个案例对我来说看起来很丑陋和hacky。

0 投票
1 回答
41 浏览

postgresql - 如何在postgresql中创建一个接受参数数组并返回表的函数

这是我的功能的外观:

但是,问题是我得到了这个

错误:函数 datafabric.test() 不存在 SQL 状态:42883 在创建函数期间。

请注意,此功能有效。但是,我想在 pgadmin 屏幕上输出结果。我现在无法做到这一点。

请帮忙。我正在使用 postgresql 8.3 版本。

0 投票
0 回答
70 浏览

sql - Postgresql 有效从字符串列中选择一个单词

我从这样的大表中选择有问题:

我需要检查 stringColumn 是否包含特定的单词。例如:搜索单词 'www' 给我 ID 1

我的所有解决方案都不是最理想的。我等了 30 多岁才得到结果。

[编辑] 查询:

解释分析:

第二个查询:

解释分析:

0 投票
0 回答
10 浏览

postgresql-8.3 - postresql 得到相同的 fileno 行并且计数不止一个

表名

如果 cname 或 pname 计数大于 1

我怎样才能得到这样的结果

0 投票
0 回答
69 浏览

sql - Postgresql:语法错误

如何正确添加单位聚合列(sprd_units)?它应该按 mrkt_desc、offer_seq_yr_nr、offer_seq_nr_desc 和 sprd_nr 对单位求和。我收到错误:“子查询必须只返回一列”我做错了什么?这是查询。

我忘了补充。我使用 Postgresql 8.3

0 投票
0 回答
21 浏览

postgresql-8.3 - 在 postgresql 中,如何使用时间戳获取两个日期列的差异?

我想要两个日期列的差异,如果两个日期与时间戳相同,结果应该为:0.62222222222222222。在 Oracle 中,我们可以通过减法来做到这一点,但这在 PostgreSQL 中不起作用。

任何人都可以用一个例子来解释我吗?

0 投票
2 回答
90 浏览

sql - 选择和分组依据

我只想根据MAX(ts). ts = timestamp. 如果我只选择两列 - deviceid 和 ts,一切都很好:

结果:

在此处输入图像描述

但我还需要两列 - 经度和纬度。如果我选择经度和纬度,我会遇到问题,因为它们必须出现在 GROUP BY 中,并且使用相同的 deviceid 得到太多结果:

在此处输入图像描述

如何避免在 GROUP BY 中插入经度和纬度?