Re: [SQL] [Re: PRIMARY KEY]

2007-03-09 Thread Bruno Wolff III
On Wed, Mar 07, 2007 at 23:20:12 +1100, Phillip Smith <[EMAIL PROTECTED]> wrote: > If you actually need to know the value of N_GEN in your ASP application, > you will need to query the database first and select the NEXTVAL from > the sequence that the "serial" data type will create, then use that

Re: [SQL] View Vs. Table

2007-03-09 Thread Bruno Wolff III
On Tue, Mar 06, 2007 at 09:32:19 -0500, Radhika Sambamurti <[EMAIL PROTECTED]> wrote: > > From the application's perspective the View is much better as data is > being stored in one place, reducing errors and also storage. > But from the db point of view, is there a bigger performace hit when I

Re: [SQL] [GENERAL] Esay question, about the numeric format

2007-02-28 Thread Bruno Wolff III
On Thu, Feb 22, 2007 at 12:20:12 +0100, Rafa Comino <[EMAIL PROTECTED]> wrote: > Hi every body > I have this query > SELECT 20.00::numeric(38,2) > and postgre gives me 20, i need that postgre gives me 20.00 > What can i do? i suppose this must be easy, but i dont find how to do ir > thanks every

Re: [SQL] problem with join

2007-02-14 Thread Bruno Wolff III
On Wed, Feb 14, 2007 at 17:21:44 -0500, "Edward W. Rouse" <[EMAIL PROTECTED]> wrote: > > I tried using coalesce(count(value4)) and case count(value4) = 0 > with no luck. I tried left and right joins and the right join gave me > the same results while the left join gave me rows like: That is b

Re: [SQL] interval as hours or minutes ?

2007-02-07 Thread Bruno Wolff III
On Wed, Feb 07, 2007 at 19:03:35 +0200, Aarni Ruuhimäki <[EMAIL PROTECTED]> wrote: > > Could anyone please tell an easy way to get total hours or minutes from an > interval ? Extract the epoch from the interval and divide by the number of seconds in the period of time that applies and apply ap

Re: [SQL] implementing (something like) UNIQUE constraint using PL/pgSQL

2007-01-26 Thread Bruno Wolff III
On Fri, Jan 26, 2007 at 10:41:26 +0100, Tomas Vondra <[EMAIL PROTECTED]> wrote: > > in our application we need to implement a constraint that enforces 'at > most N rows with this value', that is we have a table with 'flag' column > and for each value there should be at most 10 rows (for exampl

Re: [SQL] Intersection of two date interval

2007-01-26 Thread Bruno Wolff III
On Fri, Jan 26, 2007 at 12:02:24 +0200, Achilleas Mantzios <[EMAIL PROTECTED]> wrote: > Suha, > the function is the number of days in the > maximum of the two start dates , untill , minimum of the two end dates > interval. > But in postgresql (7.4.15 at least) there is no MIN(date,date),MAX(dat

Re: [SQL] select based on multi-column primary keys

2007-01-19 Thread Bruno Wolff III
On Fri, Jan 19, 2007 at 16:44:50 -0800, mawrya <[EMAIL PROTECTED]> wrote: > I have set up a table with a multi-column primary key constraint: > > If I had a row in the table where systemid=123, enclosureid=ab, > pointid=56, I would have a Primary Key ("ID") of 123ab56 for that row. > > I now w

Re: [SQL] Query to return schema/table/columname/columntype

2007-01-19 Thread Bruno Wolff III
On Fri, Jan 19, 2007 at 12:41:19 +, [EMAIL PROTECTED] wrote: > For background I am selecting table & schema by > the query: > SELECT schemaname || '.' || tablename AS tablename > FROM pg_tables ORDER BY tablename; Are you guaranteed that all of the names are lower case? If not you may want t

Re: [SQL] How to aggregates this data

2007-01-11 Thread Bruno Wolff III
On Thu, Jan 11, 2007 at 07:50:19 +0900, John Summerfield <[EMAIL PROTECTED]> wrote: > > I've perused my book (Mastering SQL by Martin Gruber), the postgresql > docs (I have versions here on RHEL (Centos) 4, FC5,6, Debian Testing - > up to 8,1) and I don't see how to choose the entry for the firs

Re: [SQL] SQL - update table problem...

2006-11-14 Thread Bruno Wolff III
On Mon, Nov 13, 2006 at 11:36:05 +0100, Marko Rihtar <[EMAIL PROTECTED]> wrote: > > i'm trying to do update on multiple tables but don't know how. > is something like this posible with postgresql? I believe you need to use multiple update statements to do this. Each update can only update one t

Re: [SQL] deleting rows in specific order

2006-10-16 Thread Bruno Wolff III
On Wed, Oct 11, 2006 at 21:31:37 +0200, Daniel Drotos <[EMAIL PROTECTED]> wrote: > On Wed, 11 Oct 2006, Markus Schaber wrote: > > After inserting new rows into this table, very old rows are going to > be deleted. But value of deleted info should be remembered somehow, so > there is a trigger o

Re: [SQL] optimal insert

2006-10-08 Thread Bruno Wolff III
On Sun, Oct 08, 2006 at 23:04:02 +0200, Dirk Jagdmann <[EMAIL PROTECTED]> wrote: > > insert into a_b(a,b) values(1,100); > insert into a_b(a,b) values(1,200); > insert into a_b(a,b) values(1,54); > insert into a_b(a,b) values(1,4577); > > So for a batch of inserts the value of a stays the same,

Re: [SQL] timestamps over the web - suggestions

2006-10-06 Thread Bruno Wolff III
On Tue, Oct 03, 2006 at 14:44:12 -0700, chester c young <[EMAIL PROTECTED]> wrote: > My server is based MST, but web clients from Maine to Hawaii, and they wish > to see timestamps based in their own locale. > > Can anyone tell me how they're handling this? (sorry - can't get rid of my > clie

Re: [SQL] Fw: How to FindNearest

2006-10-03 Thread Bruno Wolff III
On Tue, Oct 03, 2006 at 17:35:55 +, [EMAIL PROTECTED] wrote: > > My function will take all the above info about the hole and down_hole_survey > tables, and sample.hole_id and sample.depth_meters and will calculate the > coordinates. I need to put these coordinates into sample.x , sample.y

Re: [SQL] Update 3 columns w/ 1 function calc 3 values?

2006-10-03 Thread Bruno Wolff III
On Tue, Oct 03, 2006 at 14:55:55 +, [EMAIL PROTECTED] wrote: > My function was made to return coordinates, X,Y,Z > for a point along a curved line. So it is not the > fastest of functions because it has to call and > query data from 3 different tables. I used to > > What should I do to spe

Re: [SQL] How to FindNearest

2006-10-03 Thread Bruno Wolff III
On Tue, Oct 03, 2006 at 14:43:40 +0300, Alexander Ilyin <[EMAIL PROTECTED]> wrote: > > Thank you for your great idea. But how it can be used for positioning the > cursor in the already existed ResultSet? Using your idea I can found the > closest to targetvalue row but not its position in my Re

Re: [SQL] SEQUENCES

2006-10-03 Thread Bruno Wolff III
On Mon, Oct 02, 2006 at 13:39:38 -0300, Rodrigo Sakai <[EMAIL PROTECTED]> wrote: > Hi all, > > > > I need to get all sequences and their respective current values! Is there > any catalog table or any other away to get this??? You can get their names from pg_class (with relkind = 'S') and

Re: [SQL] How to FindNearest

2006-10-02 Thread Bruno Wolff III
On Sat, Sep 30, 2006 at 11:43:40 +0300, Alexander Ilyin <[EMAIL PROTECTED]> wrote: > > Suppose we have huge table. On the screen we need to show contents of that > table in the Grid and under that Grid user can input in TextBox some letters. > OnChange of this TextBox we need to make current r

Re: [SQL] unique rows

2006-09-27 Thread Bruno Wolff III
On Wed, Sep 20, 2006 at 22:18:04 -0700, TJ O'Donnell <[EMAIL PROTECTED]> wrote: > I want to make a table that has unique rows - no problem. > Create Table x (smarts Varchar Unique); > > I have input data that has many duplicates and until now > I was creating a temp table allowing duplicates, an

Re: [SQL] nested select within a DISTINCT block

2006-09-22 Thread Bruno Wolff III
On Thu, Sep 14, 2006 at 05:02:25 -0700, zqzuk <[EMAIL PROTECTED]> wrote: > > Hi, here i have a problem with this task... > > I have a table "cancellation" which stores cancelled bookings and details of > charges etc > and a table "bookings" which stores details of bookings, for example: > > ca

Re: [SQL] Mac Address

2006-09-02 Thread Bruno Wolff III
On Sat, Sep 02, 2006 at 17:42:29 -0300, Ezequias Rodrigues da Rocha <[EMAIL PROTECTED]> wrote: > Hi list, > > It is possible to retrieve the MAC Address of a computer using a Postgresql > function like others: MAC Addresses are generally only transferred within a subnet and you aren't going to

Re: [SQL] Create Assertion -- Question from a newbie

2006-08-27 Thread Bruno Wolff III
On Sun, Aug 27, 2006 at 00:19:59 -0700, Richard Broersma Jr <[EMAIL PROTECTED]> wrote: > Sorry if my question is a little off topic. > > I am reading my new "SQL for Smarties" book side by side with the PostgreSQL > 8.1 manual. I > noticed that this particular feature is not included in Postgr

Re: [SQL] Storing an ordered list

2006-07-27 Thread Bruno Wolff III
On Wed, Jul 26, 2006 at 20:13:03 -0400, Michael Artz <[EMAIL PROTECTED]> wrote: > On 7/26/06, Bruno Wolff III <[EMAIL PROTECTED]> wrote: > >If you use numeric instead of int, then it is easy to insert new values. > > Hmm, hadn't thought about that. How would

Re: [SQL] Storing an ordered list

2006-07-26 Thread Bruno Wolff III
On Tue, Jul 25, 2006 at 22:58:47 -0400, Michael Artz <[EMAIL PROTECTED]> wrote: > > I figure that one choice is to explicitly code the order as an integer > column in the predicate table which has the advantage of being very > easy and fast to query/order but *very* slow to reorder as all of the

Re: [SQL] Referential integrity (foreign keys) across multiple tables

2006-07-24 Thread Bruno Wolff III
On Mon, Jul 24, 2006 at 18:53:20 +0100, Richard Jones <[EMAIL PROTECTED]> wrote: > > I'm not sure what this means. By "data integrity" I just meant that I > don't want applications to create page_contents.link_name fields which > could point to non-existent URLs. (A URL consists of a particula

Re: [SQL] Referential integrity (foreign keys) across multiple tables

2006-07-24 Thread Bruno Wolff III
On Mon, Jul 24, 2006 at 09:59:07 +0100, Richard Jones <[EMAIL PROTECTED]> wrote: > On Sun, Jul 23, 2006 at 01:32:37PM -0500, Bruno Wolff III wrote: > > On Sat, Jul 22, 2006 at 14:32:57 +0100, > > Richard Jones <[EMAIL PROTECTED]> wrote: > > > > > >

Re: [SQL] Referential integrity (foreign keys) across multiple tables

2006-07-23 Thread Bruno Wolff III
On Sat, Jul 22, 2006 at 14:32:57 +0100, Richard Jones <[EMAIL PROTECTED]> wrote: > > Now I want to add a column to page_contents, say called link_name, > which is going to reference the pages.url column for the particular > host that this page belongs to. What are you trying to accomplish by th

Re: [SQL] unique values of profile in the whole system

2006-07-03 Thread Bruno Wolff III
On Wed, Jun 28, 2006 at 08:56:31 -0700, [EMAIL PROTECTED] wrote: > * tbl_data_type : contains the data type of the profile, their id > and their names. E.g.: id=1, data type name="last name"; id=2, > data type name="address", and so on > * tbl_data : the data of all the profil

Re: [SQL] any additional date_time functions?

2006-06-18 Thread Bruno Wolff III
On Sat, Jun 17, 2006 at 13:08:20 -0700, Richard Broersma Jr <[EMAIL PROTECTED]> wrote: > I am working with the date_trunc() function with great success especially in > the group by clause > for aggregates. > > However, it is limited to returning "WHOLE" time units. i.e. years, months, > days,

Re: [SQL] empty set

2006-06-09 Thread Bruno Wolff III
On Thu, Jun 08, 2006 at 14:40:12 -0700, CG <[EMAIL PROTECTED]> wrote: > PostgreSQL 8.1 > > I've been trying to write a SQL prepare routine. One of the challenging > elements I'm running into is an empty set ... > > "select foo from bar where foo in ? ;" > > What if "?" is an set with zero elem

Re: [SQL] Get max value from an comma separated string

2006-06-04 Thread Bruno Wolff III
On Mon, May 29, 2006 at 13:22:38 +0200, Mauro Bertoli <[EMAIL PROTECTED]> wrote: > Hi, I've a field that contain values-comma-separated > like > A) 1;2;3;;5 -- ;2;;4;5 > but also > B) 12;34;18 > how I can get the max value? > For A I tried: > SELECT max(array_upper(string_to_array(answer,';'),1)

Re: [SQL] PLEASE help ME , HOW TO GENERATE PRIMARY Keys on the fly

2006-05-26 Thread Bruno Wolff III
On Fri, May 26, 2006 at 06:50:37 -0400, Andrew Sullivan <[EMAIL PROTECTED]> wrote: > On Fri, May 26, 2006 at 05:11:26PM +0700, andi wrote: > > select rank() over(order by testeridpk ) as rank , * from tester; > > > > I get the result is like this, > > > > > > RANK TESTERIDPK TESTER_NA

Re: [SQL] Help with a seq scan on multi-million row table

2006-05-10 Thread Bruno Wolff III
On Wed, May 10, 2006 at 13:13:59 -0500, [EMAIL PROTECTED] wrote: > Hello, > > I have a little 2-table JOIN, GROUP BY, ORDER BY query that does a sequential > scan on a multi-million row table. I _thought_ I had all the appropriate > indices, but apparently I do not. I was wondering if anyo

Re: [SQL] problem with uniques and foreing keys

2006-05-06 Thread Bruno Wolff III
On Sat, May 06, 2006 at 12:27:41 -0500, "kernel.alert kernel.alert" <[EMAIL PROTECTED]> wrote: > Hi list... > > Please i have a problem with this... > > I create the follow tables... > > > > CREATE TABLE empresa ( > id_empresa

Re: [SQL] Returning String as Integer

2006-05-06 Thread Bruno Wolff III
On Fri, May 05, 2006 at 18:52:19 -0300, Jorge Godoy <[EMAIL PROTECTED]> wrote: > Em Sexta 05 Maio 2006 18:37, Kashmira Patel (kupatel) escreveu: > > Hi all, > >I have a table with a column of type 'text'. It mainly contains > > numbers. Is there any way to select a value from this column and

Re: [SQL] selects on differing subsets of a query

2006-05-03 Thread Bruno Wolff III
On Wed, May 03, 2006 at 09:47:49 +0100, [EMAIL PROTECTED] wrote: > First post, be gentle as I have terminology problems and so the > subject might be wrongly worded. > > Say I have a table with fields > ... > gender > diet_pref > ... > > What I am trying to construct is a *single* query showing

Re: [SQL] selects on differing subsets of a query

2006-05-03 Thread Bruno Wolff III
On Wed, May 03, 2006 at 14:19:27 +0200, Markus Schaber <[EMAIL PROTECTED]> wrote: > > I think this is a result of the "only subscribers may post" policy, but > I'm getting of topic. Note the policy is really only subscribers may post without moderator approval. ---(end

Re: [SQL] Sorting aggregate column contents

2006-05-02 Thread Bruno Wolff III
On Wed, May 03, 2006 at 00:13:40 +0300, Volkan YAZICI <[EMAIL PROTECTED]> wrote: > On May 02 06:00, Everton Luís Berz wrote: > > Is it possible to sort the content of an aggregate text column? > > > > Query: > > select s.name, ag_concat(c.name) from state s > > inner join city c on (c.idstate =

Re: [SQL] Multi-Column Constraints and Null Values

2006-04-29 Thread Bruno Wolff III
On Sat, Apr 29, 2006 at 13:14:36 -0700, Jeff Frost <[EMAIL PROTECTED]> wrote: > On Thu, 27 Apr 2006, Phillip Tornroth wrote: > > >I have a problem in a number of my tables. I'd like to add uniqueness > >constraints across multiple columns, but some of the columns are nullable. > >This gives me

Re: [SQL] date array

2006-04-23 Thread Bruno Wolff III
used for things that are naturally arrays (e.g. vectors) and I would be surprised if this was the case when you are storing dates.) Also note that 8.1.3 is out and 8.1.4 will probably be out soon, so you should be looking to upgrade in any case. > > > thanks > > Bruno Wolff III wrote:

Re: [SQL] date array

2006-04-23 Thread Bruno Wolff III
On Sun, Apr 23, 2006 at 07:55:54 -0500, "A. R. Van Hook" <[EMAIL PROTECTED]> wrote: > How do you add null values to a date array? > > update dattable set insDate= '{04/12/2006,null}' <-- doesn't work That is the correct format. However, I think that only works in HEAD (what will become 8.2

Re: [SQL] find all tables with a specific column name?

2006-04-21 Thread Bruno Wolff III
On Fri, Apr 21, 2006 at 09:29:33 -0700, Jeff Frost <[EMAIL PROTECTED]> wrote: > Is there a reasonable way to extract a list of all tables which contain a > specific column name from the system views on 8.1? > > For instance, I might want to enumerate all tables with a column named > last_modif

Re: [SQL] ask syntax sql to get length of field

2006-04-20 Thread Bruno Wolff III
On Thu, Apr 20, 2006 at 00:37:08 -0700, Mariya Yuniarti <[EMAIL PROTECTED]> wrote: > Here Question : > > I have table A with structure : > > Number Character(20), >Description Character(50) > > I want to get length of field Number (20) > > What is syntax sql to get l

Re: [SQL] Please help with a query..

2006-04-17 Thread Bruno Wolff III
On Tue, Apr 11, 2006 at 02:34:22 -0700, Timo Tuomi <[EMAIL PROTECTED]> wrote: > > I'd need to get the time interval X-Y-Z on each date but I cannot rely > on the date (can't make any joins based on the date part of > timestamps). Instead I'd need to find out X-Y and Y-Z pairs with a > minimal "s

Re: [SQL] slow 'IN' clause

2006-04-11 Thread Bruno Wolff III
On Sun, Apr 09, 2006 at 20:44:34 -0700, [EMAIL PROTECTED] wrote: > I have a slow sql: > SELECT * FROM mytable WHERE id IN (1,3,5,7,3k here...); > mytable is about 10k rows. > > if don't use the "IN" clause, it will cost 0,11 second, otherwise it > will cost 2.x second > I guess pg use linear

Re: [SQL] have you feel anything when you read this ?

2006-03-21 Thread Bruno Wolff III
On Mon, Mar 20, 2006 at 17:40:03 -0500, Tom Lane <[EMAIL PROTECTED]> wrote: > > Indeed. I wonder whether we shouldn't tweak the SQL string literal > parser to reject \000, because AFAICS that isn't going to do anything > useful for any datatype, and it leads to what are at best questionable > r

Re: [SQL] rowcount for all tables

2006-03-18 Thread Bruno Wolff III
On Fri, Mar 17, 2006 at 14:39:04 +0100, Stefan Meyer <[EMAIL PROTECTED]> wrote: > i have a beginner question and i have read the FAQs. > is there a faster ways than > > select count(*) from foo; > > to get the rowcount for the tables in my db ? There are some ways to get approximate counts

Re: [SQL] How can I selet rows which have 2 columns values cross equal?

2006-03-10 Thread Bruno Wolff III
On Fri, Mar 10, 2006 at 08:24:44 -0500, Fay Du <[EMAIL PROTECTED]> wrote: > Hi All: > I have a table like this: > >Table test > Id | a | b > -++--- > 1| 100| 101 > 2| 101| 100 > 3| 100| 3 > 4| 20 | 30 > 5| 11 | 13 > 6| 3 | 33 > 7| 30 | 20 > > I want t

Re: [SQL] grant select,... over schema

2006-03-01 Thread Bruno Wolff III
On Tue, Feb 28, 2006 at 09:43:58 -0700, Michael James <[EMAIL PROTECTED]> wrote: > GRANT ALL PRIVILEGES ON databaseName To username; This won't do what he wants. This will not grant access to objects contained in the database, only a few specific privileges. There is no single command that does

Re: [SQL] ORDER BY CASE ...

2006-02-20 Thread Bruno Wolff III
On Mon, Feb 13, 2006 at 22:28:38 +0100, Mario Splivalo <[EMAIL PROTECTED]> wrote: > Can't do so, because receiving_time is timestamptz, and "from" is > varchar. There: > > pulitzer2=# select id, "from", receiving_time from messages order by > case when 2=3 then "from" else receiving_time end des

Re: [SQL] query

2006-02-09 Thread Bruno Wolff III
On Tue, Feb 07, 2006 at 01:45:50 -0800, "superboy143 (sent by Nabble.com)" <[EMAIL PROTECTED]> wrote: > > I have a table in which I have a field with format like 100101. It has many > values like 100101, 100102, 100103, 100201, 100202, 100301. I have to write a > query such that I have to get

Re: [SQL] non-equi self-join optimization

2006-01-24 Thread Bruno Wolff III
On Tue, Jan 17, 2006 at 12:57:30 -0800, George Pavlov <[EMAIL PROTECTED]> wrote: > I have a table of names with two subsets of entities. I want to find > those names from set 1 that are substrings of names from set 2 from the > same table. Basically the pared down query I want is something like >

Re: [SQL] select and as doubt

2006-01-23 Thread Bruno Wolff III
On Sun, Jan 15, 2006 at 12:59:48 -0200, Alexandre Gonçalves Jacarandá <[EMAIL PROTECTED]> wrote: > Thanks for reply Tom, but which docs should I read for that ? The documentation for whatever ever programming language you will be using to generate the queries. > > Tom Lane escreveu: > > =?ISO-

Re: [SQL] constraint and ordered value

2005-12-28 Thread Bruno Wolff III
On Wed, Dec 28, 2005 at 00:52:18 +0700, David Garamond <[EMAIL PROTECTED]> wrote: > Is it possible to use only CHECK constraint (and not triggers) to > completely enforce ordered value of a column (colx) in a table? By that > I mean: > > 1. Rows must be inserted in the order of colx=1, then colx

Re: [SQL] Help on function creating

2005-12-17 Thread Bruno Wolff III
On Fri, Dec 16, 2005 at 14:03:14 -0200, Alexandre Gonçalves Jacarandá <[EMAIL PROTECTED]> wrote: > Guys, I can do what I need but I have other problem: How can I named > columns with another data ? For example: You might be better off doing this in your application rather than entirely with sql.

Re: [SQL] # of 5 minute intervals in period of time ...

2005-12-14 Thread Bruno Wolff III
On Tue, Dec 13, 2005 at 18:34:36 -0400, "Marc G. Fournier" <[EMAIL PROTECTED]> wrote: > > Is there a simpler way of doing this then: > > select (date_part('epoch', now()) - > date_part('epoch', now() - '30 days'::interval)) / ( 5 * 60 ); Are you trying to do this: select extract(epoch

Re: [SQL] Database query: Notification about change?

2005-12-05 Thread Bruno Wolff III
On Tue, Dec 06, 2005 at 02:00:18 +0100, Erik Sigra <[EMAIL PROTECTED]> wrote: > Thanks for the hint! I thought I need to put the triggers on > materialized views. If I would have to put them on the base tables, the > application program would have to understand the query to figure out > which tab

Re: [SQL] Database query: Notification about change?

2005-12-05 Thread Bruno Wolff III
On Mon, Dec 05, 2005 at 19:22:22 +0100, Erik Sigra <[EMAIL PROTECTED]> wrote: > Hi, > I plan to develop an application that is somewhat like a spreadsheet > with cells containing formulas. When a cell value is changed, things > must be updated. But the formulas can contain database queries, which

Re: [SQL] join if all matches

2005-11-28 Thread Bruno Wolff III
On Tue, Nov 22, 2005 at 10:30:17 +0200, Sim Zacks <[EMAIL PROTECTED]> wrote: > I am trying to figure out an sql statement and I was hoping someone could > help. I'm having brainfreeze right now. > > Table Rules > RuleID > RuleName > > Table RuleAgents > RuleAgentID > RuleID >

Re: [SQL] DISTINCT ON

2005-11-19 Thread Bruno Wolff III
On Sat, Nov 19, 2005 at 17:06:27 +1300, Jeremy Palmer <[EMAIL PROTECTED]> wrote: > > Interesting enough, on my server the "distinct on" clause that I originally > ran takes 10% of execution time that the query you provided does. If DISTINCT ON wasn't useful, I doubt it would have been added. -

Re: [SQL] how to update table to make dup values distinct

2005-11-10 Thread Bruno Wolff III
On Thu, Nov 10, 2005 at 10:58:18 -0500, george young wrote: > [PostgreSQL 7.4RC2 on i686-pc-linux-gnu](I know, I know... must upgrade soon) > > I have a table mytable like: > i | txt > ---+--- > 1 | the > 2 | the > 3 | rain > 4 | in > 5 | mainly > 6 | spain > 7 | stays > 8 | mai

Re: [SQL] PGSQL encryption functions

2005-11-02 Thread Bruno Wolff III
On Wed, Nov 02, 2005 at 16:01:19 -0500, "Mark R. Dingee" <[EMAIL PROTECTED]> wrote: > Thanks Bruno. I'm using a hash so I can merge info available in the HTTPS > header with data I store on the server so that the hash can be reconstructed > during the validation process from the raw elements.

Re: [SQL] PGSQL encryption functions

2005-11-02 Thread Bruno Wolff III
On Tue, Nov 01, 2005 at 17:00:50 -0500, "Mark R. Dingee" <[EMAIL PROTECTED]> wrote: > Bruno, > > I use an authenticate() function as a part of state maintenance in a PHP web > app. In the function, I generate an encrypted token that is then used in the > validation process on subsequent pages

Re: [SQL] PGSQL encryption functions

2005-11-01 Thread Bruno Wolff III
On Tue, Nov 01, 2005 at 14:38:05 -0500, "Mark R. Dingee" <[EMAIL PROTECTED]> wrote: > Everyone, > > I'm in need of a one-way pgsql script that will take a plain-text string and > return an ecrypted string (preferably 32 character) . I've been using > md5('string'), but I'm concerned it's too

Re: [SQL] Aggregate versus lineitem report

2005-10-29 Thread Bruno Wolff III
On Fri, Oct 21, 2005 at 11:32:13 -0400, Jerry Blumenthal <[EMAIL PROTECTED]> wrote: > How do you get a report that lists items and then produces a sum at the > end. Like this: > > name date amount1 amount2 > name date amount1 amount2 > name date amount1 amount2 > > tot

Re: [SQL] How to speed up the database query?

2005-10-27 Thread Bruno Wolff III
On Thu, Oct 27, 2005 at 15:03:36 +0800, Abdul Wahab Dahalan <[EMAIL PROTECTED]> wrote: > Hi everyone! > > I'm looking for solution to speed up the database query, means that to get > resultset as quicker as we can. > > For example if I've 700 records in the table it will take longer time > co

Re: [SQL] select best price

2005-10-26 Thread Bruno Wolff III
On Wed, Oct 26, 2005 at 16:38:48 +0100, Gary Stainburn <[EMAIL PROTECTED]> wrote: > On Wednesday 26 October 2005 4:21 pm, Gary Stainburn wrote: > > Hi folks > > > > I've got a table holding item code(cs_id), supplier a/c (co_id) , and > > price (cs_price). > > > > How can I select the rows contai

Re: [SQL] Combining two SELECTs by same filters

2005-10-26 Thread Bruno Wolff III
On Wed, Oct 26, 2005 at 18:16:13 +0300, Volkan YAZICI <[EMAIL PROTECTED]> wrote: > And I want to collect the count of sales at hour = 21 and hour = 22. > For this purpose, I'm using below SELECT query: > > => SELECT > -> (SELECT count(id) FROM sales > -> WHERE id = 2 > -> AND

Re: [SQL] query tables based on a query

2005-10-24 Thread Bruno Wolff III
On Fri, Sep 30, 2005 at 18:47:48 -0400, solarsail <[EMAIL PROTECTED]> wrote: > I have a large number of tables with a common naming convention > > basically: > > table001, table002, table003 ... table00n > > > I would like to do a query across all of the tables, however I do not know > all of

Re: [SQL] Difficulties with a master-detail query

2005-09-23 Thread Bruno Wolff III
On Mon, Sep 19, 2005 at 20:29:40 +0300, "Milen A. Radev" <[EMAIL PROTECTED]> wrote: > > I would like to get all employees, who speak two specified languages > (say german and french). The following query gives me that, bu I don't > like it (see for yourself): > > > SELECT > ?.employee_id, >

Re: [SQL] R-tree and start/end queries

2005-09-21 Thread Bruno Wolff III
On Wed, Sep 21, 2005 at 13:52:40 -0400, Sean Davis <[EMAIL PROTECTED]> wrote: > I have a table like: > > Create table gf ( > pkserial, > start int, > end int, > gfvarchar > ); > > I want to do queries along the lines of: > > "find all gf that overlap with (1,2

Re: [SQL] how to update with a join?

2005-09-10 Thread Bruno Wolff III
On Sat, Sep 10, 2005 at 18:56:10 +0200, [EMAIL PROTECTED] wrote: > Hello all, > > thanks for the answere to the prev. thread. With the help of them > I solved the problme I used "not like" instead of <> and this leads > to a problem. This works for me: > > update stamm > set code = replace

Re: [SQL] how to have 2 select creteria on one column?

2005-09-10 Thread Bruno Wolff III
On Sat, Sep 10, 2005 at 17:45:50 +0200, Michael Hoeller <[EMAIL PROTECTED]> wrote: > Hello, > > I would like to select every row which has got in the column CODE a "k" > but I want to exclude every "kV" -- may be it is due to the fact that > it is Saturday and I work too long I don't get it..

Re: [SQL] SELECT: retrieve only 2 rows next to known row

2005-09-09 Thread Bruno Wolff III
On Fri, Sep 09, 2005 at 16:23:00 +0400, Nikolay Samokhvalov <[EMAIL PROTECTED]> wrote: > > I've encountered with following task. I have one SELECT statement with > ORDER BY clause; and know, that result set for this SELECT contains > row with ID = 1000 (just for example). > I don't know the posi

Re: [SQL] Statistics from Sequences

2005-09-06 Thread Bruno Wolff III
On Tue, Sep 06, 2005 at 23:43:44 -0300, Joÿffe3o Carvalho <[EMAIL PROTECTED]> wrote: > Is it possible to get from a sequence: > >The sequence owner >The min value >The max value >The increment value >The last used number Yes. Associated with each sequence is a one ro

Re: [SQL] POSIX Regular Expression question

2005-09-06 Thread Bruno Wolff III
On Mon, Sep 05, 2005 at 16:19:28 +0200, Peter Eisentraut <[EMAIL PROTECTED]> wrote: > Am Montag, 5. September 2005 15:57 schrieb Aldor: > > I want to get out a string only with characters A-Za-z. > > Any idea how to do this in Postgres with POSIX Regex? > > Presumably, > > colname ~ '^[A-Za

Re: [SQL] Help with UNION query

2005-09-06 Thread Bruno Wolff III
On Sun, Sep 04, 2005 at 20:54:00 +0200, Andreas Joseph Krogh <[EMAIL PROTECTED]> wrote: > > So, the question stands: any idea on how to rewrite the lower wuery to only > specify "ug.username='andreak'" once? Why do you want to do that? This isn't going to help with performance and may actually

Re: [SQL] Searching for results with an unknown amount of data

2005-09-06 Thread Bruno Wolff III
On Fri, Sep 02, 2005 at 20:40:24 +0100, DownLoad X <[EMAIL PROTECTED]> wrote: > Now, I want to find all objects that have at most properties 1,2,3, say (so > something with (1,2) is okay, as is (1,2,3)). I can't see a way to do this > -- can anyone help? It sounds like you are trying to find a

Re: [SQL] Performance issue

2005-08-30 Thread Bruno Wolff III
On Tue, Aug 30, 2005 at 15:42:06 +0700, Ricky Sutanto <[EMAIL PROTECTED]> wrote: > > I use Apache Web Server and PostgreSQL 7.3 to collect data everyday. Now it > has been 5 month since I install that server. > > I wonder why now my web very slow to retrieve and display data? > When I check t

Re: [SQL] Negative lookbehind assertions in regexs

2005-08-29 Thread Bruno Wolff III
On Mon, Aug 29, 2005 at 14:11:37 +0100, Julian Scarfe <[EMAIL PROTECTED]> wrote: > I'd like a regex that matches 'CD' but not 'ABCD' in any part of the regex. > > Is there a workaround that allows me to do this as a single regex? > > I know I could and together a ~ and !~ like this > > # selec

Re: [SQL] nullif('','') on insert

2005-08-27 Thread Bruno Wolff III
> Your problem is that NULL's are typed in PostgreSQL. > > Try this: > > SELECT NULL; > SELECT NULL::BOOL; > SELECT NULL::BOOL::TEXT; > > to see what I mean. This is an exact illustration of your problem. Note that in 8.1 he will be able to do: SELECT NULL::TEXT::INT::BOOL and get the conversi

Re: [SQL] returning inserted id

2005-08-26 Thread Bruno Wolff III
On Sun, Aug 21, 2005 at 12:56:27 -0700, "Matt A." <[EMAIL PROTECTED]> wrote: > this may have been asked a thousand times but i > haven't found a standard answer... > > > MSSQL > set nocount on > insert into (column) values (value) > select identityid = @@identity > set nocount off > > > POSTG

Re: [SQL] Tidying values on variable instantiation

2005-08-26 Thread Bruno Wolff III
On Fri, Aug 26, 2005 at 13:04:10 +1000, > Desired Outcome(s): > * I would like to have the convenience of declaring a column that obeys > a constraint (similar to using a domain), but allows a "tidy-up" as the > value is created BEFORE asserting the constraint. This *might* be > termed a "do

Re: [SQL] How this query!

2005-08-25 Thread Bruno Wolff III
On Thu, Aug 25, 2005 at 18:44:00 +0700, Richard Susanto <[EMAIL PROTECTED]> wrote: > Folks, > would you like help me how to query this case. This question is off topic for the pgsql-admin list, it should have been asked on the pgsql-sql list because it was a question about SQL. (I probably would

Re: [SQL] Number of rows in a cursor ?

2005-08-25 Thread Bruno Wolff III
On Thu, Aug 25, 2005 at 08:51:59 +0200, Bo Lorentsen <[EMAIL PROTECTED]> wrote: > Michael Fuhr wrote: > > >Right -- when you open a cursor PostgreSQL doesn't know how many > >rows it will return. PostgreSQL selects a query plan based on an > >*estimate* of how many rows the query will return, b

Re: [SQL] PGSQL function for converting between arbitrary numeric bases?

2005-08-19 Thread Bruno Wolff III
On Mon, Aug 15, 2005 at 16:48:40 +0100, Simon Kinsella <[EMAIL PROTECTED]> wrote: > Hello, > > I'm looking - without luck so far - for a PGSQL function for converting > numbers between two arbitrary bases (typically base 10,16 and 26 in my > case). Something similar to the C 'strtol' function o

Re: [SQL] how to do a select * and decrypt a column at the same time?

2005-08-16 Thread Bruno Wolff III
On Tue, Aug 16, 2005 at 12:53:51 -0700, The One <[EMAIL PROTECTED]> wrote: > Hello, > > I have a table with one encrypted column. > How can I do a select statement such that it will select all columns from the > table and at the same time will decrypt it too? You want to explicitly list all o

Re: [SQL] Fwd: How to encrypt a column

2005-08-12 Thread Bruno Wolff III
ecute query >\q to quit > intrapos=# select encrypt('hello world', '', 'aes') \g > encrypt > ------- > \333\337\003\217\016\222WC\243\031\306\250`&\265Q > (1 row) > intr

Re: [SQL] SQL Newbie

2005-08-12 Thread Bruno Wolff III
On Fri, Aug 12, 2005 at 18:57:34 +0100, Nick Stone <[EMAIL PROTECTED]> wrote: > Hope this helps > > SELECT > * > FROM > speed_history as outside etc.. > WHERE > (speed = ( > SELECT > speed > FROM > speed_hi

Re: [SQL] SQL Newbie

2005-08-12 Thread Bruno Wolff III
> Data in speed history looks like this: > interface_id updated_time speed > 1 2005-08-11 08:10:23 450112 > 1 2005-08-11 10:53:34 501120 <--- > 1 2005-08-11 10:58:11 450112 > 2 2005-08-11 08:10:23 450112 <--- >

Re: [SQL] Fwd: How to encrypt a column

2005-08-11 Thread Bruno Wolff III
On Thu, Aug 11, 2005 at 13:50:45 -0700, Owen Jacobson <[EMAIL PROTECTED]> wrote: > Jeff Lu wrote: > > > Another question is can the encrypted column be of type "text" ? > > Can't see any reason why not, so long as the encrypted data is represented > as text. There can't be any 0 bytes in the e

Re: [SQL] Breakdown results by month

2005-08-10 Thread Bruno Wolff III
On Tue, Aug 02, 2005 at 14:34:46 -0400, Henry Ortega <[EMAIL PROTECTED]> wrote: > I have the ff table: > > id |total| effective|end_date > john 6 01-01-200502-28-2005 > john 8 03-01-200506-30-2005 > > How

Re: [SQL] Foreign key with check?

2005-07-27 Thread Bruno Wolff III
On Wed, Jul 27, 2005 at 16:08:19 -0400, Jeff Boes <[EMAIL PROTECTED]> wrote: > Given a table like this: > > create table primary ( > a integer primary key, > b boolean > ); > > And another like this: > > create table secondary ( > a integer, > some_other_fields > ); > > > I would lik

Re: [SQL] Closes Match

2005-07-25 Thread Bruno Wolff III
On Mon, Jul 25, 2005 at 19:31:11 +0200, Christian Rusa <[EMAIL PROTECTED]> wrote: > Hi there, > > I want to match a string against the database and get the closest > (shorter) match. > I was asking myself if its possible to realise this in SQL. > > So if the string is: > abcdefg > > And in th

Re: [SQL] int to date

2005-07-25 Thread Bruno Wolff III
On Mon, Jul 25, 2005 at 10:54:42 +0200, Daniel Drotos <[EMAIL PROTECTED]> wrote: > Hi, > > I have a string containing hexa dump of an 4 bytes integer, like > '6AF4805C'. Is it possible to convert it somehow to date type in > plpgsql (v8.0.0-rc1)? Doc says that date is represented as 4 bytes >

Re: [SQL] Convert numeric to money

2005-07-22 Thread Bruno Wolff III
On Fri, Jul 22, 2005 at 11:03:40 -0300, [EMAIL PROTECTED] wrote: > Hi. > I have searched in mailing-list archives about converting types, but I > couldn't > found a function or clause that convert a numeric type to money type. > How Can I convert this types? > > => select '1234'::money; >mo

Re: [SQL] getting back autonumber just inserted

2005-07-14 Thread Bruno Wolff III
On Thu, Jul 07, 2005 at 14:47:23 -0600, Larry Meadors <[EMAIL PROTECTED]> wrote: > If you have a trigger on your table that inserts a record in a table > and shares the same sequence, what value do you get back, the > triggered curval, or the currently inserted one? Whichever one was done second

Re: [SQL] Index creation question for expression (col1 || '-' || col2)

2005-07-08 Thread Bruno Wolff III
On Fri, Jul 08, 2005 at 12:08:41 -0400, Ying Lu <[EMAIL PROTECTED]> wrote: > Greetings, > > A question about creating index for the following expression. > > CREATE INDEX idx_t1 ON test (col1 || '-' || col2); > > May I know is it possible and how I may create index for the expression > such a

Re: [SQL] two sums in one query

2005-07-08 Thread Bruno Wolff III
On Fri, Jul 08, 2005 at 16:49:44 +0200, PFC <[EMAIL PROTECTED]> wrote: > > >>SELECT (SELECT sum(amount) FROM table WHERE debit=X) AS debit, (SELECT > >>sum(amount) FROM table WHERE credit=x) AS credit; > > > >If most of the records are credits or debits you don't want to do this. > >A single seq

  1   2   3   4   >