Questions tagged [postgresql-8.3]

Questions specific to version 8.3 of the widely-used PostgreSQL relational database system

This tag is for questions specific to version 8.3 of the widely-used .

Official documentation for this version: http://www.postgresql.org/docs/8.3/interactive/index.html

For general PostgreSQL questions, use the tag.

61 questions
451
votes
15 answers

How to declare a variable in a PostgreSQL query

How do I declare a variable for use in a PostgreSQL 8.3 query? In MS SQL Server I can do this: DECLARE @myvar INT SET @myvar = 5 SELECT * FROM somewhere WHERE something = @myvar How do I do the same in PostgreSQL? According to the documentation…
EMP
  • 59,148
  • 53
  • 164
  • 220
12
votes
5 answers

Writing a function to select data only on weekdays in PostgreSQL

I am working on a Postgres 8.3 database. A query I use is meant to only select rows that are included in weekdays. Right now I have do do this by hand like in the example below but I want to transfer this to some funciotn where I can specefic the…
user7980
  • 703
  • 3
  • 15
  • 28
3
votes
2 answers

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…
telex-wap
  • 832
  • 1
  • 9
  • 30
3
votes
2 answers

Postgresql 8.3 doesn't understand negative interval greater than a day

The following statements are understood by Postgresql 8.3: SELECT '1.12:00:00'::interval SELECT '12:00:00'::interval SELECT '-12:00:00'::interval But the following statement isn't understood: SELECT '-1.12:00:00'::interval I receive the following…
Leonard
  • 348
  • 1
  • 6
  • 20
3
votes
3 answers

Postgres function much slower when using input variables

I have a function in Postgres 8.3.5 that selects data from multiple tables and dumps the result in a single table: create or replace function test_function_2(startdate timestamp, enddate timestamp) returns void as $$ begin delete from…
3
votes
2 answers

Problems running AUTO_VACUUM (to prevent wrap-around) on a very large table

I'm having a problem and need some advice. I am normally a developer, however with recent staff changes at my company I am now the sole IT person, so I'm having to branch into a lot of unknown areas and really need some help. We are running…
framauro13
  • 797
  • 2
  • 8
  • 18
3
votes
2 answers

Apply the same aggregate to every column in a table

I am using a proprietary mpp database that has been forked off psql 8.3. I am trying to apply a simple count to a wide table (around 450 columns) and so I was wondering if the best way to do this in terms of a simple sql function. I am just…
user7980
  • 703
  • 3
  • 15
  • 28
3
votes
3 answers

How to select more than 1 record per day?

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…
Drogba
  • 4,186
  • 4
  • 23
  • 31
2
votes
1 answer

Integrating resultant columns from function to main query

I have created a function that returned a table with one row and three columns. DROP FUNCTION IF EXISTS get_event_deposit_values(INTEGER, date, date); CREATE OR REPLACE FUNCTION get_event_deposit_values(event_id INTEGER, start_date date, end_date…
M. Ko
  • 563
  • 6
  • 31
2
votes
2 answers

Passing ROWTYPE parameter on EXECUTE

I am developing a function in Postgres which aims to recover for each record of a query the value of a result of a check contained in a set of functions. Only one of these functions will return the correct value. These functions have a comun prefix…
Geison Santos
  • 187
  • 1
  • 3
  • 16
2
votes
0 answers

PostgreSQL 8.3's equivalent for Oracle's ROWNUM?

In Oracle you can do: select rownum, -- here's the magic name as country, population as pop_mil from country where name like 'C%' and member = true order by population; and get rownum country pop_mil ------ …
Tulains Córdova
  • 2,559
  • 2
  • 20
  • 33
2
votes
1 answer

Rename VALUES of primary and foreign keys

There are two tables like this: CREATE TABLE rooms (rid CHAR PRIMARY KEY); CREATE TABLE users (uid INT PRIMARY KEY, rid CHAR FOREIGN KEY REFERENCES rooms(rid)) The target is to rename the keys (values, not table or column) of rid like this: BEGIN…
Chickenmarkus
  • 1,131
  • 11
  • 25
2
votes
2 answers

SQL query selecting public IP address

I am on a postgresql 8.3 database. I am trying to figure out where the mistake is in the query below. I am trying to design a query to only select source_ips and destination_ips that are private addresses. For some reason one of the addresses that…
user7980
  • 703
  • 3
  • 15
  • 28
2
votes
2 answers

how to terminate postgresql 8.3 sessions?

I am trying to terminate a session (a specific session or all sessions, doesnt matter) in postgresql 8.3 and am having trouble doing that. I know in newer versions (8.4 and later) there is a pg_terminate_backend command that will do the trick but…
user972276
  • 2,973
  • 9
  • 33
  • 46
2
votes
2 answers

Error passing array of ints to a plpgsql function (postgres 8.3.7)

I have the following function, which receives an array of ints, iterates it calling other function: CREATE FUNCTION calculateAbsencesForIDs(INT[]) RETURNS TEXT AS ' DECLARE index integer := 0; resultArray decimal[]; id int; result…
1
2 3 4 5