Re: [SQL] [BUGS] session variable

2003-09-02 Thread sad
On Tuesday 02 September 2003 16:40, you wrote: > No problem to use a temp table in a trigger (which is local to the > session), I do so myself. Still, session variables would be nice, making > coding a little bit more comfortable. (it would be very good if you implement session variables in Post

[SQL] pg_type and type names

2003-09-04 Thread sad
hello developers, another question i have to ask: may the type names changes in the future releases? may the type oids changes...? I need look-up system catalog for a type of a field, so i need a constancy of some kind :-) ---(end of broadcast)--

Re: [SQL] recursive sql

2003-09-05 Thread sad
Good day On Friday 05 September 2003 21:41, you wrote: > can anyone recommend a good reference source for doing recursive sql on > postgresql? i want to do something similar to a BOM expansion. (i.e. i need > to traverse a self-referencing table that stores a tree structure and > answer a question

[SQL] how to call a function with row-type arg

2003-09-11 Thread sad
hi how to call a function with a row_type arg ?? that is the question CREATE FUNCTION foo(tablename) returns int . SELECT foo ( ??? ); ---(end of broadcast)--- TIP 7: don't forget to increase your free space map settings

Re: [SQL] auto_increment

2003-09-21 Thread sad
On Saturday 20 September 2003 10:23, you wrote: > On Sat, 2003-09-20 at 06:10, Muhyiddin A.M Hayat wrote: > > How to Create auto_increment field in PostreSQL. > > Can I create them using Trigger. > > Use the SERIAL datatype. See also the functions nextval(), currval() > and setval(). I believe it

Re: [SQL] Reg: Firing Trigger when a particular column value get changed

2003-09-21 Thread sad
On Sunday 21 September 2003 02:38, you wrote: > Thilak babu wrote: > > I have a scnerio as to fire a trigger when i update a particular column > > in a table. Please do help me out in getting thro this. > > The trigger function can use logic to exclude cases where a particular > column does not c

Re: [SQL] Large Objects and Bytea

2003-09-24 Thread sad
Hi, Friends ! On Thursday 25 September 2003 08:11, you wrote: > I am migrating MS SQL DB to Postgres DB. I have tables with columns of data > type 'Image' in the MS SQL database. IF I choose 'bytea' datatype, I am > afraid it may lead to poor performance of the database (which I read from > the m

Re: [SQL] Date interval

2003-09-25 Thread sad
On Friday 26 September 2003 09:18, you wrote: > I am looking for a way to convert an interval into a number of days ( > integer); > > In sybase I would use : > > days(today()-r_expire) SELECT now()::DATE - '1900-12-10'::DATE; ?column? 375

Re: [SQL] SQL Syntax problem

2003-09-29 Thread sad
> I've got a problem in porting the following select statement from Oracle to > Postgres, because of the characters after "b.bet_id" and "f.ask_id" in the > where clause: (+) > I don't know what these characters mean and how I can transform these into > PostgreSql Syntax. > > > select... >

[SQL] privileges

2003-10-07 Thread sad
Hi all can anyone give me a link to a Reference manual which describes all privileges on any DB object and it's meaning :-) thnx. ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

[SQL] see a current query

2003-10-22 Thread sad
Hello i'am logged in as superuser (pgsql) trying to SELECT * FROM pg_stat_activity; and seeing NULLs instead of current_query column& What is it? ---(end of broadcast)--- TIP 7: don't forget to increase your free space map settings

[SQL] bug in working with TEXT constants ?

2003-10-28 Thread sad
Good day. AFAIK PostgreSQL provides the type TEXT with 4-byte prefix length which is distinct to C's zero-terminated (char *) That's very good. Then I expect natural possibility to store texts having zero characters. try SELECT 'abc\0de'; SELECT length('abc\0de'); or insert such a value into an

[SQL] unescaped output of bytea

2003-10-29 Thread sad
Good day Guru I thought on output to input relation in general. Manual says about scalar types that input and output functions should be inverse to each other, because of dump problems (if output function prints a value not in a format that input function waiting for) That's the geat problem i

[SQL] varlena versus null-terminated strings

2003-10-30 Thread sad
Hi Developers. I think the problem is the input/output functions pass CSTRING -- not varlena. this waste all profits of using varlena storage cause values are not transparently passed. then application forced to convert them reverse. ---(end of broadcast)--

[SQL] a question to developers

2003-11-11 Thread sad
Hello Developers what had drove you to use CSTRING type for input argument of postgres-type input convertion functions (in general) and for output of postgres-type output conversion functions ? thanx ---(end of broadcast)--- TIP 6: Have you

[SQL] question to developers

2003-11-11 Thread sad
Hello Developers what had drove you to use CSTRING type for input argument of postgres-type input convertion functions (in general) and for output of postgres-type output conversion functions ? thanx ---(end of broadcast)--- TIP 9: the planne

[SQL] DROP TRIGGER

2004-01-18 Thread sad
hi all again i have little complex database was used in tests of a program in ordinal way (no manual expirements with pg_catalog have done) now the database seems damaged in strange manner: Postgres cannot drop nor create some triggers (he was thinking about an hour on the query then i have can

[SQL] cascade delete

2004-02-11 Thread sad
hi why a cascade delete is so slow ? pgsql 7.3.3 ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the m

Re: [SQL] cascade delete

2004-02-12 Thread sad
> Check if it is using indexes. > 7.3 seems to ignore them somethimes, try upgrading to 7.4 where index use > is apparently improved. good, i will upgrade anyway but how can i check index usage when DELETE from table1; ? EXPLAIN tells me only "seq scan on table1" when many other tables involved

Re: [SQL] Getting the week of a date

2004-02-16 Thread sad
On Monday 16 February 2004 15:10, you wrote: > > Any idea on how to find the 3 rd Wednesday of any given month. SELECT 1-(to_char(date_trunc('month', now()::timestamp),'D'))::INT2 + 7*3-3 replace now with any date and you'll the the day number of a third Wed in that month. 7 is a constant (fac

Re: [SQL] Getting the week of a date

2004-02-16 Thread sad
EXCUSE ME, GUYS ! i forgot to add one monome: 7*(((to_char(date_trunc('month',now()),'D'))::INT2-1)/4) which is stands for skip a first week of month in case it is not consist Wed finally the select will be similar the following SELECT 7*(((to_char(date_trunc('month',now()),'D'))::INT2-1)/4) + 1

Re: [SQL] bytea or blobs?

2004-02-17 Thread sad
On Tuesday 17 February 2004 18:08, you wrote: > I'd recommend to let the application convert the binary > data to and from base64, Don't, please don't ! Since you have the good bytea rule to convert so called "binary" data into so called "text". You have no need another encoding at all. Genera

[SQL] perfomance question

2004-03-17 Thread sad
hello. what are perfomance difference bitween a) update t1 set f1 = 'x', f2 = 'y'; b) update t1 set f1 = 'x', f2 = f2; c) update t1 set f1 = 'x'; ? ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if yo

Re: [SQL] perfomance question

2004-03-18 Thread sad
On Thursday 18 March 2004 21:38, you wrote: > Sad, > > > what are perfomance difference bitween > > a) update t1 set f1 = 'x', f2 = 'y'; > > b) update t1 set f1 = 'x', f2 = f2; > > c) update t1 set f1 = 'x'; > > ? &g

[SQL] type conversions

2004-04-14 Thread sad
hi SELECT 'tbl'::regclass; works fine SELECT 'tbl'::text::regclass; says cannot convert type text to regclass what to do ? ---(end of broadcast)--- TIP 8: explain analyze is your friend

Re: [SQL] a wierd query

2004-05-13 Thread sad
> i require the dictinct values from (visualizing each column > result as a set) the union of the two columns select distinct a as F from table union select distinct b as F from table; ---(end of broadcast)--- TIP 7: don't forget to increase your

Re: [SQL] a wierd query

2004-05-13 Thread sad
On Thursday 13 May 2004 19:27, you wrote: > sad wrote: > > select distinct a as F from table > > union > > select distinct b as F from table; > > Note that UNION only returns the unique values of the union > You can get repeated values by using UNION ALL. read th

Re: [SQL] a wierd query

2004-05-17 Thread sad
> I forgot one situation: > > if I run the query like so: > select distinct on (task_id, begindate) task_id, workhour_id, > begindate as date from workhour UNION > select distinct on (task_id, enddate) task_id, workhour_id, enddate > as date from workhour I get yet another value: 2961 r

Re: [SQL] The PostgreSQL

2004-05-26 Thread sad
Dear developers, many tricks were discussed here, and many feature requests generated. Every discussed problem ALREADY have solution in the current version of the SQL. Most of the problems are forced by incorrect design of a database ! I ask you: do not burden the PostgreSQL with features !!! P

[SQL] type regclass casting

2004-05-31 Thread sad
hello look select * from pg_class where oid = 'sometablename'::regclass; (1 row) select * from pg_class where oid = 'sometablename'::text::regclass; ERROR can not cast TEXT to regclass What does this mean ? version 7.3.3 please try it on 7.4.x ---(end of broadcast)

[SQL] type regclass casting

2004-05-31 Thread sad
hello select * from pg_class where oid = 'sometablename'::regclass; (1 row) select * from pg_class where oid = 'sometablename'::text::regclass; ERROR can not cast TEXT to regclass What does this mean ? version 7.3.3 please try it on 7.4.x ---(end of broadcast)---

[SQL] empty string casting to typed value

2004-06-07 Thread sad
Hello It is clear that '' is a bad integer or timestamp representation but during the user input NULLs are usually represented with empty strings sometimes bunch of 'if empty' instructions grows huge (and in case of casting to timestamp apostrophes make sense) Why you prohibit casting ''::int

[SQL] casting int to bit

2004-06-11 Thread sad
PLEASE NOTE : select 1::int8::bit(64); 0001 select 1::int4::bit(64); 0001 select 1::int2::bit(64); ERROR: Cannot cast type smallint to bit the last is a great surprise for me

[SQL] feature request

2004-06-21 Thread sad
hello it might be stupid... sometimes i am starving UPDATE OR INSERT command thnx ---(end of broadcast)--- TIP 8: explain analyze is your friend

[SQL] feature request ?

2004-06-23 Thread sad
Hello since BOOL expression has three possible values: TRUE,FALSE,NULL plpgsql IF control structure should have three alternate blocks: THEN,ELSE,NULL shouldn't it ? ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ?

Re: [SQL] feature request ?

2004-06-23 Thread sad
On Thursday 24 June 2004 09:32, Michael Glaesemann wrote: > On Jun 24, 2004, at 2:12 AM, Josh Berkus wrote: > > Sad, > > > >> since BOOL expression has three possible values: TRUE,FALSE,NULL > >> plpgsql IF control structure should have three alte

Re: [SQL] feature request ?

2004-06-23 Thread sad
On Wednesday 23 June 2004 21:12, you wrote: > Sad, > > > since BOOL expression has three possible values: TRUE,FALSE,NULL > > plpgsql IF control structure should have three alternate blocks: > > THEN,ELSE,NULL > > > > shouldn't it ? > > No, why? &

Re: [SQL] feature request ?

2004-06-24 Thread sad
> I don't see what your point is. That SQL is wrong ? Or that SQL is not "C" > ? Or that SQL is not a "programming language" ? Who said wrong ? who said SQL ? I thougth _WHY_ the IF control structure has exactly two alternate blocks ? a BOOLEAN expression has exactly two possible values, that's

Re: [SQL] feature request ?

2004-06-24 Thread sad
...IF ELSEIF ELSE it's all clear but what about unequality of BOOL type possible value set and IF alternatives set ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html

Re: [SQL] feature request ?

2004-06-24 Thread sad
On Thursday 24 June 2004 14:32, Alexander M. Pravking wrote: > On Thu, Jun 24, 2004 at 11:04:15AM +0400, sad wrote: > > Now you treat NULLs as false. > > Nope. NULL is neither true, nor false. It's "unknown", or "undefined". > > fduch=# SELECT 1 WHER

Re: [SQL] feature request ?

2004-06-24 Thread sad
> If you were to add a NULL block you'd have to deal with things > like, if you only have a then and else, do you run the else on NULL or do > you do nothing? If you do nothing, what if you want the null and else to > be the same, do you add another way to specify that? If you do the else, > the

Re: [SQL] feature request ?

2004-06-24 Thread sad
> then lots of currently perfectly correct > programs break. If they're the same, then ELSE has different meanings > depending on whether NULL is specified, and that's generally bad from an > understanding the language standpoint. i've already thougth on this new control structure needed but the

Re: [SQL] feature request ?

2004-06-24 Thread sad
> Very simply, a boolean may have to values: true or false. It's also > possible that it's not been set to anything (NULL). really ? what about (13 < NULL)::BOOL ---(end of broadcast)--- TIP 7: don't forget to increase your free space map sett

Re: [SQL] feature request ?

2004-06-25 Thread sad
On Friday 25 June 2004 09:37, Rosser Schwarz wrote: > On Fri, 25 Jun 2004 08:16:47 +0400, sad <[EMAIL PROTECTED]> wrote: > > > Very simply, a boolean may have to values: true or false. It's also > > > possible that it's not been set to anything (NULL). > &g

Re: [SQL] feature request ?

2004-06-25 Thread sad
> sad wrote: > > On Friday 25 June 2004 09:37, Rosser Schwarz wrote: > >>On Fri, 25 Jun 2004 08:16:47 +0400, sad <[EMAIL PROTECTED]> wrote: > >>>>Very simply, a boolean may have to values: true or false. It's also > >>>>possible t

[SQL] locks and triggers. give me an advice please

2004-07-19 Thread sad
Good day. often, I am turning triggers off and on to perform a mass operation on a table, and i am interested how should i care of another user operations. the scene is: table t1 with user defined triggers and many tables reference t1, (so FK triggers defined on t1) the operation i want to per

Re: [SQL] locks and triggers. give me an advice please

2004-07-21 Thread sad
thnx. i try to sound the idea to ensure myself that you are right. > begin transaction; > lock t1 in access exclusive mode; > > Turn off triggers and do your updates. > (Note, "truncate t1" is faster than "delete from t1" followed by a > "vacuum full" and you might consider running "reindex table

Re: [SQL] surrogate key or not?

2004-07-21 Thread sad
Thnx, Josh (Byou are very helpful. (B (B> There are, in fact, three very good reasons to use surrogate keys, all of (B> which are strictly due to limitations of technology; that is, (B> implementation and performance issues, NOT business logic. They are: (B> (B> 1) Convenience: It's very a

Re: [SQL] surrogate key or not?

2004-07-21 Thread sad
On Wednesday 21 July 2004 14:58, Markus Bertheau wrote: > > 4) Replication: to identify an object of ANY type (record of any table > > regardless to datamodel), to store lists of deleted or modified objects > > (regardless to datamodel) > > That sounds like a datamodel on data that belongs to ano

[SQL] ? on announcement of 7.5

2004-07-21 Thread sad
Hello can anyone comment the announcement of 7.5 about "nested transactions" ? doesn't the nesting hurt the matter of transaction ? ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] surrogate key or not?

2004-07-22 Thread sad
I want to add some notes > create table diagnosis ( > pk serial primary key, > fk_patient integer > not null > references patient(pk) > on update cascade > on delete cascade, > narrative text > not null, > unique(fk_patient, narrative) > ); 1) a seque

Re: [SQL] surrogate key or not?

2004-07-26 Thread sad
hello > This reminds me of a project I worked on many years ago, I was pretty much > fresh out of university writing a system for a large medical practice - > itwas principally for accounting purposes. I made lots of suggestions like > Josh's, only to get replies like Karsten's. I the progammer wa

[SQL] surrogate keys and replication.

2004-07-27 Thread sad
Josh, I agree to treat this case as a (1) convinence. But it is still very cpecific, more than just simplifying FKs And you have said about general GUID problem. Let we disscuss this problem ? I hope to here good ideas from you again. Now I solve the GUID problem, with one sequence of IDs on the

Re: [SQL] surrogate key or not?

2004-08-23 Thread sad
On Sunday 08 August 2004 04:29, Kenneth Gonsalves wrote: > but why would anyone want to change the value of an autogenerated serial > row? because of catenating data from two or more databases. ---(end of broadcast)--- TIP 8: explain analyze is y

[SQL] casting BOOL to somthng

2004-08-31 Thread sad
hello why BOOL can not be casted to TEXT ...nevertheless BOOL has a textual (output) representation 't' and 'f' letters why not to use this fact to define cast to TEXT ? ---(end of broadcast)--- TIP 8: explain analyze is your friend

Re: [SQL] casting BOOL to somthng

2004-08-31 Thread sad
you wrote: > you can use CREATE CAST to make your own cast from boolean to text. thnx it helps. and i am still desire to know _WHY_ there are no predefined cast for BOOL ? and at the same time there are predefined casts for INT and FLOAT.. ---(end of broadcast)

Re: [SQL] casting BOOL to somthng

2004-08-31 Thread sad
On Tuesday 31 August 2004 16:22, Geoffrey wrote: > sad wrote: > > you wrote: > >>you can use CREATE CAST to make your own cast from boolean to text. > > > > thnx it helps. > > > > and i am still desire to know _WHY_ there are no predefined cast for

Re: [SQL] casting BOOL to somthng

2004-08-31 Thread sad
On Tuesday 31 August 2004 17:49, Michael Glaesemann wrote: > On Aug 31, 2004, at 8:24 PM, sad wrote: > > and i am still desire to know _WHY_ there are no predefined cast for > > BOOL ? > > and at the same time there are predefined casts for INT and FLOAT.. > > I th

Re: [SQL] casting BOOL to somthng

2004-08-31 Thread sad
On Wednesday 01 September 2004 09:24, Stephan Szabo wrote: > On Wed, 1 Sep 2004, sad wrote: > > On Tuesday 31 August 2004 17:49, Michael Glaesemann wrote: > > > On Aug 31, 2004, at 8:24 PM, sad wrote: > > > > and i am still desire to know _WHY_ there are no pr

Re: [SQL] casting BOOL to somthng

2004-08-31 Thread sad
On Wednesday 01 September 2004 10:38, Michael Glaesemann wrote: > On Sep 1, 2004, at 2:41 PM, sad wrote: > > On Wednesday 01 September 2004 09:24, Stephan Szabo wrote: > >> There's a fairly accepted convention for integer representations. > >> There's no such c

Re: [SQL] casting BOOL to somthng

2004-09-01 Thread sad
> There's a difference between an output function and a cast to text. > One gives you an external representation of the data for end use. The > other gives you an internal representation for manipulation. And at the same time 't'::TEXT can be casted to BOOL 't'::BOOL but reverse.

[SQL] casting UNKNOWN to REGCLASS

2004-09-01 Thread sad
> select 't'::text::bool; > ERROR: cannot cast type text to boolean > > If you're thinking 't'::bool, that's something different. Ok i have nothing to opppose and by the way (!!!) why TEXT can not be casted to REGCLASS ? ---(end of broadcast)---

Re: [SQL] Isnumeric function?

2004-09-09 Thread sad
On Friday 10 September 2004 04:20, Theo Galanakis wrote: > I was just thinking, wouldn't it be great if the pg community had a site > where anyone could contribute their generic functions, or request for a > particular function. i vote positive. ---(end of broadcast)-

[SQL] libpq-fe: PQgetvalue() ?

2004-10-14 Thread sad
hi does PQgetvalue() allocate memory rof its result, it returns ? the answer will help me in problem: should i free some cstring_variable if { cstring_variable=PQgetvalue(pgresult_variable,0,0); } and could i PQclear(pgresult_varible) while cstring_varible is in use. thnx --

Re: [SQL] Howto turn an integer into an interval?

2004-10-05 Thread sad
hello SELECT ('3600'::int::abstime-'epoch'::abstime)::interval; try to modify this idea to fit your purpose. ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html

Re: [SQL] help on a query

2004-10-07 Thread sad
On Friday 08 October 2004 07:10, Thomas F.O'Connell wrote: > A query that should get the job done is: > > SELECT registration_id > FROM registrations r > WHERE NOT EXISTS ( > SELECT 1 > FROM receipts > WHERE registration_id = r.registration_id > ); Don't, PLEASE, don't !!! drive

[SQL] Offtopic: psql

2004-10-21 Thread sad
Hi (B (BPostgres has a perfect tool - psql (Bwhat libraries did you (developers) use to develop psql console and (Bparticulary command-line editor. (B (Bthnx (B (B (B---(end of broadcast)--- (BTIP 6: Have you searched our list archives? (B

Re: [SQL] CREATE TYPE

2004-11-03 Thread sad
Hello i note something related to this discussion > create table mytmp(name myvarchar(10,"en_US")); i meant that "en_US" is a locale name, then it means natural language and also character encoding -- those both things are not a matter of SQL-TYPE at all. It is wrong to represent application

Re: [SQL] A transaction in transaction? Possible?

2004-11-09 Thread sad
On Tuesday 09 November 2004 18:24, Theodore Petrosky wrote: > I thought nested transactions are available in the new > release (8) coming up. how to commit/rollback them ? ---(end of broadcast)--- TIP 7: don't forget to increase your free space ma

Re: [SQL] tree structure photo gallery date quiery

2004-11-16 Thread sad
On Tuesday 16 November 2004 14:29, Gary Stainburn wrote: > Hi folks. > > I'm looking at the possibility of implementing a photo gallery for my > web site with a tree structure > How would I go about creating a view to show a) the number of photos in > a gallery and b) the timestamp of the most rec

Re: [SQL] SET AUTOCOMMIT TO OFF

2004-12-01 Thread sad
On Wednesday 01 December 2004 18:42, Tom Lane wrote: > Christoph Haller <[EMAIL PROTECTED]> writes: > > Please, could someone point me to the right list > > or tell me how to do a "SET AUTOCOMMIT TO OFF" within libpq. > > libpq does not have any support for that. Does this mean libpq calls always

Re: [SQL] Single row tables

2005-01-11 Thread sad
On Tuesday 11 January 2005 17:45, KÖPFERL Robert wrote: > Hi, > > with what constraint or how can I ensure that one of my tables has exact > one record or 0..1 records? A trigger procedure BEFORE INSERT would help you. And a column type with only one possible field value would help you if you de

Re: [SQL] currval() within one statement

2008-01-21 Thread sad
A. Kretschmer wrote: is it expected that the currval() changes its value between calls within one statement ? Conclusion, don't call nextval() within a TRIGGER, and insert either nextval() for the column or omit this column. I only note that i still want to discuss the titled problem or to

Re: [SQL] currval() within one statement

2008-01-22 Thread sad
Richard Huxton wrote: sad wrote: A. Kretschmer wrote: is it expected that the currval() changes its value between calls within one statement ? Conclusion, don't call nextval() within a TRIGGER, and insert either nextval() for the column or omit this column. I only note that i still

Re: [SQL] Multiple postgresql functions in a single transaction

2008-02-05 Thread sad
Robins Tharakan wrote: > > It can be done, but it depends on how you are generating the value in the > > first function. > > If you sequences though you may have to take care of reverting it > > yourself. Sequences had been constructed in this manner not to cause pain for users -- think of it. S

[SQL] very frustrating feature-bug

2010-02-16 Thread silly sad
acc=> CREATE OR REPLACE FUNCTION add_user (TEXT, TEXT, TEXT, TEXT) RETURNS usr AS $$ INSERT INTO usr (login,pass,name,email) VALUES ($1,$2,$3,$4) RETURNING usr.*; $$ LANGUAGE sql SECURITY DEFINER; acc=> ERROR: return type mismatch in function declared to return usr DETAIL: Function's fin

Re: [SQL] very frustrating feature-bug

2010-02-17 Thread silly sad
On 02/17/10 13:51, Jasen Betts wrote: On 2010-02-17, silly sad wrote: acc=> CREATE OR REPLACE FUNCTION add_user (TEXT, TEXT, TEXT, TEXT) RETURNS usr AS $$ INSERT INTO usr (login,pass,name,email) VALUES ($1,$2,$3,$4) RETURNING usr.*; $$ LANGUAGE sql SECURITY DEFINER; acc=>

[SQL] what exactly is a query structure?

2010-02-25 Thread silly sad
hello. Postgresql 8.3.9 CREATE TYPE usr_secrets AS (login TEXT, pass TEXT, shop_pass TEXT); CREATE OR REPLACE FUNCTION get_noobs () RETURNS SETOF usr_secrets AS $$ BEGIN RETURN QUERY SELECT login, '*' as pass, shop_pass FROM noob; RETURN; END; $$ LANGUAGE plpgsql SECURITY DEFINER; SELECT *

Re: [SQL] what exactly is a query structure?

2010-02-26 Thread silly sad
On 02/26/10 10:19, A. Kretschmer wrote: In response to silly sad : hello. Postgresql 8.3.9 CREATE TYPE usr_secrets AS (login TEXT, pass TEXT, shop_pass TEXT); CREATE OR REPLACE FUNCTION get_noobs () RETURNS SETOF usr_secrets AS $$ BEGIN RETURN QUERY SELECT login, '*' as pass,

Re: [SQL] what exactly is a query structure?

2010-02-26 Thread silly sad
On 02/26/10 09:50, silly sad wrote: hello. Postgresql 8.3.9 CREATE TYPE usr_secrets AS (login TEXT, pass TEXT, shop_pass TEXT); CREATE OR REPLACE FUNCTION get_noobs () RETURNS SETOF usr_secrets AS $$ BEGIN RETURN QUERY SELECT login, '*' as pass, shop_pass FROM noob; RETURN; END; $

[SQL] client_timezone to server_timezone and reverse

2010-03-05 Thread silly sad
HELO i am looking for strange things: a timezone conversion AS transparent AS a charset encoding conversion are. for __example__ (not intending to override the current behavior) i want to see now()::timestampTZ always the same (the server side time with the timezone predefined firmly) and to s

Re: [SQL] Private functions

2010-03-14 Thread silly sad
On 03/14/10 06:21, Jasen Betts wrote: On 2010-03-13, Gianvito Pio wrote: Hi all, is there a way to write a function that can only be called by another function but not directly using SELECT function_name ( )? not really. but there may be another way to get the effect you want. read the se

Re: [SQL] Odd query behavior

2010-03-15 Thread silly sad
On 03/12/10 18:41, Dan McFadyen wrote: Hello, I've come across an odd situation. I've had access to a database where a the following happens: " SELECT * FROM table WHERE name LIKE 'abc%' " returns 2 rows... but... " SELECT * FROM table WHERE name IN (SELECT name FROM table WHERE name LIKE 'ab

Re: [SQL] list of all months

2010-03-15 Thread silly sad
It looks like a procedural problem. I would solve it in plpgsql. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] I, nead to capture the IP number from the PC how is running the script ...

2010-03-15 Thread silly sad
On 03/15/10 22:18, John Dizaro wrote: I, nead to capture the IP number from the PC how is running the script first of all you must tell us how your client is connected to your database? there are a lot of different variants, and the most common of them is not PG related at all while the connec

Re: [SQL] MSSQL to PostgreSQL - Issue trying to generate unique ID using actual date

2010-03-18 Thread silly sad
On 03/17/10 17:52, Ignacio Balcarce wrote: CREATE PROCEDURE dbo.THUBAN_SP_GENERATEID @NEWID VARCHAR(20) OUTPUT AS SET @NEWID = ( SELECT REPLACE(SUBSTRING(CONVERT(CHAR(10),GETDATE(),20 ),1,10),'-','') + CAST(REPLICATE(0,8-LEN (ISNULL(CAST(SUBSTRING(MAX(SEQ_ID),9,8) AS INTEGER),0) +

Re: [SQL] MSSQL to PostgreSQL - Issue trying to generate unique ID using actual date

2010-03-18 Thread silly sad
On 03/17/10 17:52, Ignacio Balcarce wrote: -- IF EXISTS A ROW IN THE TABLE STARTING WITH THE CURRENT_DATE Sorry, your field is not an atom => your database does not met a FIRST normal form. it needs normalization urgently. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To mak

Re: [SQL] SQL Developer accessing PostgreSQL

2010-03-29 Thread silly sad
On 03/29/10 20:33, Snyder, James wrote: Hello, Is there a way to configure Oracle’s SQL Developer to access a PostgreSQL database? IMHO, no. And (even if it possible) it is completely useless, since the Postgresql has the "psql" program far better than any oracle tool and than all oracle too

Re: [SQL] Table Design for Hierarchical Data

2010-04-06 Thread silly sad
single table. nested tree + ordinal parent reference. nests are calculated in a trigger on insert. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Table Design for Hierarchical Data

2010-04-06 Thread silly sad
P.S. almost foget, do not try any oracle-like "tree-jouns" or "special types" or such a crap. your problem as plain as to store a pair of integers (or numerics (i prefer)) -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.

Re: [SQL] Table Design for Hierarchical Data

2010-04-07 Thread silly sad
On 04/07/10 11:00, Achilleas Mantzios wrote: Column | Type| Modifiers -+---+--- id | integer | not null default nextval(('public.paintgentypes_id_seq'::text)

Re: [SQL] Cascading sum in tree with CTE?

2010-04-09 Thread silly sad
to select a whole subtree of a particular node of a tree. u have to modify the tree representation in one of the two ways (according to you fine-tuned needs) (1) store in the EACH node the PATH from root to this node (2) store (l,r) segment representing the INCLUSIONS of nodes into other nodes s

Re: [SQL] How to max() make null as biggest value?

2010-04-21 Thread silly sad
On 04/14/10 08:33, Feixiong Li wrote: Hi , guys , I am newbie for sql, I have a problem when using max() function, I need get null when there are null in the value list, or return the largest value as usual, who can do this? i.e. max([1,2,3,4,5]) => 5 max([1,2,3,4,5,null]) => null if u want a

Re: [SPAM]-D] [SQL] How to find broken UTF-8 characters ?

2010-04-26 Thread silly sad
On 04/26/10 04:12, Andreas wrote: Excel files > pgAdmin > Access. looks like a complete offtopic How can I find those broken UTF-8 characters? How can I get rid of them? iconv -c BUT u should not have those characters at all if one is occured it most probably an error AND u should get ri

Re: [SPAM]-D] Re: [SPAM]-D] [SQL] How to find broken UTF-8 characters ?

2010-04-26 Thread silly sad
How can I get rid of them? iconv -c AFAIK iconv would translate on file system level but I would think that messed up a allready messed up Excel workmap even further. I'd be glad to handle csv, too. pg_dump | iconv -c | psql -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To mak

[SQL] LIMIT problem

2010-04-30 Thread silly sad
suppose i request SELECT foo(t.x) FROM t LIMIT 1; Whither it DEFINED how many times foo() will be executed? May anyone rely on it? Or we have to avoid this non SQLish trick? -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresq

Re: [SQL] LIMIT problem

2010-05-01 Thread silly sad
On 04/30/10 16:57, Nilesh Govindarajan wrote: On 04/30/2010 06:20 PM, silly sad wrote: suppose i request SELECT foo(t.x) FROM t LIMIT 1; Whither it DEFINED how many times foo() will be executed? May anyone rely on it? Or we have to avoid this non SQLish trick? It will execute foo only

Re: [SQL] LIMIT problem

2010-05-01 Thread silly sad
On 05/01/10 03:58, Jasen Betts wrote: On 2010-04-30, silly sad wrote: suppose i request SELECT foo(t.x) FROM t LIMIT 1; Whither it DEFINED how many times foo() will be executed? foo will be executed repeatedly until it returns a result or all the rows in t are exhausted. May anyone rely

Re: [SQL] [GENERAL] Schema design / joins

2010-05-04 Thread silly sad
__Orgs__ id name __Seasons__ id org_id fk(orgs.id) name __Teams__ id season_id fk(seasons.id) name __TeamFees__ id team_id fk(teams.id) *org_id<--- (?put extra fk here to avoid many joins?) NO. instead of it use triggers before insert/update CREATE FUNCTION foo() RE

Re: [SQL] [Trigger] Help needed with NEW.* and TG_TABLE_NAME

2010-05-11 Thread silly sad
On 05/11/10 18:26, Torsten Zühlsdorff wrote: Tom Lane schrieb: =?ISO-8859-15?Q?Torsten_Z=FChlsdorff?= writes: NEW.revision := addContentRevision (OLD.content_id, OLD.revision); /* not working line, just a stub: EXECUTE 'INSERT INTO ' || TG_TABLE_NAME || ' SELECT $1 ' USING NEW; */ RETU

  1   2   >