[SQL] Problem with FOR SELECT in plpgsql function

2004-02-20 Thread Plant Thomas
I have a problem with the following function: CREATE OR REPLACE FUNCTION weiterbildung.f_termine_uhrzeit (integer) RETURNS text AS' DECLARE id ALIAS for $1; dat RECORD; uhrzeiten text; BEGIN uhrzeiten = ; FOR dat IN SELECT vormittag_a, vormittag_e,

Re: [SQL] Problem with FOR SELECT in plpgsql function

2004-02-20 Thread Richard Huxton
On Friday 20 February 2004 10:07, Plant Thomas wrote: I have a problem with the following function: [snip] This function sometimes returns null even if there is a record in the database for the corrisponding id. This happens only when there is only one record for the corrisponding id value

Re: [SQL] pg_restore - don?t restore. Why?

2004-02-20 Thread Andrew Sullivan
On Fri, Feb 20, 2004 at 12:24:46AM -0300, 2000info wrote: pg_dump, ok. pg_restore, don?t restore. Why? If you didn't use a non-ASCII format from pg_dump, you don't need pg_restore. Just use psql. A -- Andrew Sullivan ---(end of

Re: [SQL] bytea or blobs?

2004-02-20 Thread Igor Shevchenko
On Wednesday 18 February 2004 09:18, you wrote: Maybe if bandwidth is a restriction the base64 solution saves some bandwith, since base64 file is ~ 1.3 times larger than the original, whereas the escaped octal representation will be ~ 4 times larger. If you use libpq's v3 protocol with binary

Re: [SQL] create function atof?

2004-02-20 Thread Achilleus Mantzios
O kyrios mark egrapse stis Feb 20, 2004 : Hello, Is it possible to create a database function that mimics the C function atof? I'm guessing it should look something like this: create function atof(varchar) returns float as '??' language returns

Re: [SQL] create function atof?

2004-02-20 Thread Tom Lane
mark [EMAIL PROTECTED] writes: Is it possible to create a database function that mimics the C function atof? Just cast. There doesn't seem to be a pg_cast entry for varchar to float8, but you could cast to text and then float8, or you could use functional notation for the cast (which is a tad

[SQL] date format in 7.4

2004-02-20 Thread Silke Trissl
Hi, I have an application where users can enter the date via a web interface. Recently I upgrated my PostgreSQL version from 7.3 to 7.4.1. On 7.3 I run several tests about the format of the date and found, that Postgres accepts almost everything. Today I found out, that 7.4.1 only accepts

Re: [SQL] date format in 7.4

2004-02-20 Thread Richard Huxton
On Friday 20 February 2004 14:58, Silke Trissl wrote: Hi, I have an application where users can enter the date via a web interface. Recently I upgrated my PostgreSQL version from 7.3 to 7.4.1. On 7.3 I run several tests about the format of the date and found, that Postgres accepts almost

Re: [SQL] Creating constraint sometime fail in a transaction

2004-02-20 Thread Tom Lane
Olivier Hubaut [EMAIL PROTECTED] writes: So, we're wondering if the action for putting/removing constraint could be executed out of the transaction, so that it may overlaps and crash in such case. Does anyone notice the same problem? When you didn't show us exactly what you're doing or

Re: [SQL] Row counts/data changes. Any catalog table that has this info?

2004-02-20 Thread Josh Berkus
David, table_name#Rows cust 1000 order 5000 order_detail 9500 If you're willing to live with some inaccuracy, do: SELECT relname, reltuples FROM pg_class WHERE relkind='r'; This count gets updated when you do a VACUUM, and is seldom 100% accurate; however, if you

Re: [SQL] Date Foo.

2004-02-20 Thread Brian Knox
Sorry, Not looking for a way to extract a month from a timestamp. I'm looking for a way to convert an interval from days to months. I'm not sure after digging into it that there is a way to handle it in SQL, as the interval that results from subtracting one timestamp from another is not away

Re: [SQL] Date Foo.

2004-02-20 Thread scott.marlowe
I'm still not sure what you were looking for. If you have, say, March 16th, and the next date is August 23rd, do you want to count March, April, May, Jun, July, August = 6? Or do you want to count the number of 30 day periods? Using date_part gets you the first one. Plus, since months can be

[SQL] searching polygons

2004-02-20 Thread David
What query would i have to use to search for an item using a polygon as a parameter? (i.e a very large polygon that would identify smaller polygons within it) ideally i would like to give postgresq a series of co-ordinates and then have it return all those results whose polygons fall into that set

[SQL] transaction block causing trouble

2004-02-20 Thread Fabian
Hey I hope someone can help me here. I'm doing some little test on PostgreSQL 7.3.5 and am experiencing some weird behaviour. I create some tables and add values to it using insert into select from. After I am done with that, I create unique constraints on the tables. The reason to do that

Re: [SQL] Function

2004-02-20 Thread Sumita Biswas
Is this the right place to get PostgreSQL 7.3.4 from: ftp://ftp10.us.postgresql.org/pub/postgresql/source/v7.3.4/postgresql-7. 3.4.tar.gz Regards, Sumita -Original Message- From: scott.marlowe [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 18, 2004 4:17 AM To: Sumita Biswas

[SQL] Binary retrieval - *Best practice* recommendations...

2004-02-20 Thread beyaNet Consultancy
Hi, I have a table in postgreSQL, ver. 7.4.1, which serves up image data(JPEG) to users browsers. In various posts I have read there has been a favour towards storing image data as bytea (byte[]) instead of storing the filesystem location of the image, or whatever binary data is, in the

Re: [SQL] Function

2004-02-20 Thread Sumita Biswas
I have a postgres function that returns a boolean, I want to use this return in another function. How do I do it? Will the following code help me fetch it in a variable: select lv_flag = drop_table_if_exists(''alarmconfig'',false); drop_table_if_exists is the function which I want to call. Any

Re: [SQL] Function

2004-02-20 Thread Sumita Biswas
We installed postgres, but it did not install the default DB postgres. This is on 7.3.4 postgres. Any thing that we might have missed out? TIA, Sumita -Original Message- From: scott.marlowe [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 18, 2004 4:17 AM To: Sumita Biswas (sbiswas)

[SQL] User defined types -- Social Security number...

2004-02-20 Thread Greg Patnude
Anyone have a good pre-built user-defined type definition for creating / maintaining / manipulating a SSN ... where valid chars are in the range 000-00- through 999-99-. I imagine that the storage column is probably varchar(11) -- I am looking for a type definition that 1) checks

[SQL] SQL / Join Help

2004-02-20 Thread FastEddie
First off, thanks for taking the time to read this and try to assist. I have 3 tables: assets,polls,aps -Assets is a master list of all of the wireless assets in our environment. -Polls is an ongoing table containing data from a script that logs into 140 AP's every hour on the hour and retrives

Re: [SQL] Date / interval question

2004-02-20 Thread Gnugeek
I'm looking for a way, within SQL, given a starting date and an ending date, to get back the number of months between the start and end date. If I SELECT end_date - start_date, I get back an interval in days; I need months. Thanks for any suggestions, Brian ---(end of

Re: [SQL] Compiling pl/pgsql functions

2004-02-20 Thread Rod Taylor
AFAIK there's not much you can do for obfuscation of pl functions right now since someone will be able to see the src text in pg_proc. However, are you allowing people that you don't want to see the code access to write arbitrary sql to the database? This is another one of those items where