postgresql-8.3

Removing repeated letters in a set of rows on PostgreSQL 8.3

不羁岁月 提交于 2021-01-29 10:49:01
问题 I have a query that returns a set of rows with a combination of the letters A , E , I and L . That combination are Portuguese mneumonics for Alterar , Excluir , Incluir , and Listar . The column value can vary between A , AE , AEL , AELI ... L , LI , LIA , LIAE . In the example illustrated below I would like to be able to get a unique string with all repeated letters removed. So the result would be AELI , a merge of all rows. My first attempt was using the combination of the functions array

Iterating on each element from an array of arrays on Postgresql

若如初见. 提交于 2020-01-06 15:08:11
问题 I have a VARCHAR of numbers inside my stored procedure, these numbers are organized as arrays, I will show an example below: {1,2,3,4,5,6,7,8,9},{1,2,3,4,5},{1,2,3},{9} -- This is a STRING Now with a help from another guy from here I'm using this to get integer arrays integer[] SELECT string_to_array(regexp_split_to_table( trim('{1,2,3,4,5,6,7,8,9},{1,2,3,4,5},{1,2,3},{9}', '{}') , '},{'), ',')::int[] I will have a set of records, each of them with an array, see below: {1,2,3,4,5,6,7,8,9} {1

PostgreSQL 8.3.7: “FATAL: could not reattach to shared memory” and “WARNING: worker took too long to start; cancelled”

徘徊边缘 提交于 2019-12-25 06:01:14
问题 We record our office IP phone activity using Xima software's Chronicall, which uses a PostgreSQL backend. The server on which both of these are installed is an ESXi 5.5 VM running Windows Server Standard 2008 SP1. For some time now, we have been getting the following PostgreSQL errors in Windows event viewer: "FATAL: could not reattach to shared memory (key=248, addr=02510000): 487" "WARNING: worker took too long to start; cancelled" These errors occur every hour or two, and always occur back

PostgreSQL 8.3.7: “FATAL: could not reattach to shared memory” and “WARNING: worker took too long to start; cancelled”

天涯浪子 提交于 2019-12-25 06:00:20
问题 We record our office IP phone activity using Xima software's Chronicall, which uses a PostgreSQL backend. The server on which both of these are installed is an ESXi 5.5 VM running Windows Server Standard 2008 SP1. For some time now, we have been getting the following PostgreSQL errors in Windows event viewer: "FATAL: could not reattach to shared memory (key=248, addr=02510000): 487" "WARNING: worker took too long to start; cancelled" These errors occur every hour or two, and always occur back

How to select more than 1 record per day?

╄→尐↘猪︶ㄣ 提交于 2019-12-17 16:52:59
问题 This is a postgresql problem. PostgreSQL 8.3.3 on i686-redhat-linux-gnu, compiled by GCC gcc (GCC) 3.4.6 20060404 (Red Hat 3.4.6-9). The table looks like: date_time other_column 2012-11-01 00:00:00 ... 2012-11-02 01:00:00 ... 2012-11-02 02:00:00 ... 2012-11-02 03:00:00 ... 2012-11-02 04:00:00 ... 2012-11-03 05:00:00 ... 2012-11-03 06:00:00 ... 2012-11-05 00:00:00 ... 2012-11-07 00:00:00 ... 2012-11-07 00:00:00 ... ... I want to select at most 3 records per day from a specific date range. For

Query returning exact number of rows

社会主义新天地 提交于 2019-12-02 19:08:33
问题 I have a table that stores two foreign keys, implementing a n:m relationship. One of them points to a person ( subject ), the other one to a specific item. Now, the amount of items a person may have is specified in a different table and I need a query which would return the same number of rows as the number of items a person may have. The rest of the records may be filled with NULL values or whatever else. It has proven to be a pain to solve this problem from the application side, so I've

Implementing a total order ranking in PostgreSQL 8.3

假如想象 提交于 2019-12-02 17:28:26
问题 The issue with 8.3 is.....rank is introduced in 8.4. consider the numbers [10,6,6,2] I wish to achieve a rank of those numbers where the rank is equal to the the row number Rank,score 1, 10 2,6 3,6 4,2 A partial solution is to self join and count items with a higher or equal, score. this produces 1,10 3,6 3,6 4,2 this is not what I want. Is there a way to rank, or even just order by score then somehow extract the row number? 回答1: If you want a row number equivalent to the window function row

How to round REAL type to NUMERIC?

安稳与你 提交于 2019-12-02 17:24:58
问题 I have table with real column type with example values: 123456,12 0,12345678 And code in stored procedure: CREATE OR REPLACE FUNCTION test3() RETURNS integer AS $BODY$ DECLARE rec RECORD; BEGIN FOR rec IN SELECT gme.abs_km as km, CAST(gme.abs_km as numeric) as cast, round(gme.abs_km:: numeric(16,2), 2) as round FROM gps_entry gme LOOP RAISE NOTICE 'Km: % , cast: % , round: %', rec.km, rec.cast, rec.round; INSERT INTO test (km, casting, rounding) VALUES (rec.km, rec.cast, rec.round); END LOOP;

How to round REAL type to NUMERIC?

烈酒焚心 提交于 2019-12-02 12:22:55
I have table with real column type with example values: 123456,12 0,12345678 And code in stored procedure: CREATE OR REPLACE FUNCTION test3() RETURNS integer AS $BODY$ DECLARE rec RECORD; BEGIN FOR rec IN SELECT gme.abs_km as km, CAST(gme.abs_km as numeric) as cast, round(gme.abs_km:: numeric(16,2), 2) as round FROM gps_entry gme LOOP RAISE NOTICE 'Km: % , cast: % , round: %', rec.km, rec.cast, rec.round; INSERT INTO test (km, casting, rounding) VALUES (rec.km, rec.cast, rec.round); END LOOP; RETURN 1; END; $BODY$ LANGUAGE 'plpgsql' VOLATILE; Here is output: 2014-02-05 12:49:53 CET NOTICE: Km:

Implementing a total order ranking in PostgreSQL 8.3

只谈情不闲聊 提交于 2019-12-02 07:48:57
The issue with 8.3 is.....rank is introduced in 8.4. consider the numbers [10,6,6,2] I wish to achieve a rank of those numbers where the rank is equal to the the row number Rank,score 1, 10 2,6 3,6 4,2 A partial solution is to self join and count items with a higher or equal, score. this produces 1,10 3,6 3,6 4,2 this is not what I want. Is there a way to rank, or even just order by score then somehow extract the row number? If you want a row number equivalent to the window function row_number() , you can improvise in version 8.3 with a (temporary) SEQUENCE : CREATE TEMP SEQUENCE foo; SELECT