Re: [SQL] backup

2009-06-09 Thread Jasen Betts
On 2009-06-09, Jyoti Seth wrote: > This is a multipart message in MIME format. > > --=_NextPart_000_003C_01C9E916.43A8D460 > Content-Type: text/plain; > charset="us-ascii" > Content-Transfer-Encoding: 7bit > > Hi all, > > > > Can we take backup of specific data of a table (using where

Re: [SQL] setting the where clause

2009-06-12 Thread Jasen Betts
On 2009-06-10, johnf wrote: > Hi, > I'm am programming in python using the Dabo modules. www.dabodev.com if your > interested. Dabo is a framework that provides an easy way to build desktop > app's. To clear a data entry form. I have been setting the where clause > to "where 1=0". This of c

Re: [SQL] SQL File in encrypted form

2009-06-19 Thread Jasen Betts
On 2009-06-19, Jyoti Seth wrote: > This is a multipart message in MIME format. > > --=_NextPart_000_0001_01C9F0F8.92EE3490 > Content-Type: text/plain; > charset="us-ascii" > Content-Transfer-Encoding: 7bit > > Hi All, > > > > I want to send the sql script file to a client but wants to

Re: [SQL] Client-side compression

2009-06-24 Thread Jasen Betts
On 2009-06-23, Rob Sargent wrote: > > Not sure if this belongs here or on the admin or performance list. > Apologies if so. (And this may be a second posting as the first was from > an un-registered account. Further apologies) > > My assumption is that any de/compression done by postgres would

Re: [SQL] Timestamp with timezone with Default value

2009-07-19 Thread Jasen Betts
On 2009-07-18, Gianvito Pio wrote: > This is a multi-part message in MIME format. > > --=_NextPart_000_0017_01CA0791.49E30EB0 > Content-Type: text/plain; > charset="iso-8859-1" > Content-Transfer-Encoding: quoted-printable > > Hi all, > how can I define a column of timestamp with timezon

Re: [SQL] Tweak sql result set... ?

2009-07-29 Thread Jasen Betts
On 2009-07-28, Axe wrote: > I have a problem where I want to tweak a simple select in an > "unobtrusive way". Imagine I have the following select statement: > "SELECT name FROM customer LIMIT 1" and I get a normal result set from > this. But, could I,maybe by defining some other function or simila

[SQL] Re: Determining logically unique entities across many partially complete rows where at least one column matches

2009-08-11 Thread Jasen Betts
On 2009-08-11, Jamie Tufnell wrote: > Hi, > > I am faced with a modeling problem and thought I'd see if anyone has run > into something similar and can offer some advice. > > Basically my problem domain is cataloguing "snippets of information" about > "entities" which are loosely identified. > > E

Re: [SQL] mail alert

2009-08-13 Thread Jasen Betts
On 2009-08-11, Jan Verheyden wrote: > > Hi All, > > I was looking in what way it's possible to alert via mail when some conditi= > ons are true in a database. > > Thanks in advance! Assuming you mean email, and not ink on paper (hmm, OTOH you could load postcards into a printer) you could d

Re: [SQL] mail alert

2009-08-13 Thread Jasen Betts
On 2009-08-12, Jan Verheyden wrote: > --_000_E30C7040DE22624185BAD4093190B54437BE5DB4A9EX2007MBX2uzk_ > Content-Type: text/plain; charset="us-ascii" > Content-Transfer-Encoding: quoted-printable > > It's on Windows > I'd go with notify and a listener written in C using c-client to send emails, bu

Re: [SQL] simple? query

2009-08-14 Thread Jasen Betts
On 2009-08-13, Jan Verheyden wrote: > --_004_E30C7040DE22624185BAD4093190B54437BE5DB4C1EX2007MBX2uzk_ > Content-Type: multipart/alternative; > boundary="_000_E30C7040DE22624185BAD4093190B54437BE5DB4C1EX2007MBX2uzk_" > > --_000_E30C7040DE22624185BAD4093190B54437BE5DB4C1EX2007MBX2uzk_ > Conten

Re: [SQL] operator contains in older Pgsql

2009-08-18 Thread Jasen Betts
On 2009-08-18, W. Kinastowski wrote: > I need a functionality of "@>" array operator in 8.1 Pg server. i.ex. > SELECT * FROM table WHERE array_col @> ARRAY ['xxx'] (works in 8.2, > error in 8.1) > How to performe such a query ? Is it possible ? Thanks for help. SELECT * FROM table WHERE 'xxx'

Re: [SQL] operator contains in older Pgsql

2009-08-18 Thread Jasen Betts
On 2009-08-18, W. Kinastowski wrote: > Jasen Betts wrote: >> On 2009-08-18, W. Kinastowski wrote: >> >>> I need a functionality of "@>" array operator in 8.1 Pg server. i.ex. >>> SELECT * FROM table WHERE array_col @> ARRAY ['xxx'] (

Re: [SQL] Updating one table with data from another

2009-08-20 Thread Jasen Betts
On 2009-08-18, drew wrote: > Hey all, > There are two things I need to do: > 1. Update existing rows with new data > 2. Append new rows > > I need to update only some of the fields table1 with data from > table2. These tables have the exact same fields. > > So here's what I have currently for app

Re: [SQL] multiple substitution in a single replace call?

2009-08-22 Thread Jasen Betts
On 2009-08-21, Gerardo Herzig wrote: > Hi all. There is a way to simulate the `pipe' in linux so y can use > replace() for replacing 2 different things? use regexp_replace instead? -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.po

Re: [SQL] Differences between bit string constant sintax

2009-09-10 Thread Jasen Betts
On 2009-09-09, Oliveiros C, wrote: > This is a multi-part message in MIME format. > > --=_NextPart_000_013B_01CA3146.85B62920 > Content-Type: text/plain; > charset="iso-8859-1" > Content-Transfer-Encoding: quoted-printable > > Dear All, > > I have a table which has a field that is of typ

Re: [SQL] How to get the previous date?

2009-10-17 Thread Jasen Betts
On 2009-10-14, Shruthi A wrote: > --0016e64698e4af821f0475e1f43d > Content-Type: text/plain; charset=ISO-8859-1 > > Hi, > > I'm using Enterprise DB PostgresPlus version 8.3. > Is there is a simple function or command like previous_date(mydate) which > when passed a particular date, simply returns

Re: [SQL] PostgreSQL Security/Roles/Grants

2009-11-02 Thread Jasen Betts
On 2009-11-01, Andrew Hall wrote: > 1. Default Roles -> a role which is activated at login time. Oracle imposes= > a limit on the number of default roles which any given user can have. > > 2. Non-default role -> a role which has to be explicitly activated during t= > he lifecycle of an applicati

Re: [SQL] Getting more than one row in UNIQUE fields

2009-12-06 Thread Jasen Betts
On 2009-12-04, Another Trad wrote: > --001485f94df095921c0479ea62fd > Content-Type: text/plain; charset=ISO-8859-1 > > My table 'client' has the unique 'client_id'. > My test server, when I try: > select * from client where client_id = 12 > My server returns 3 rows I had similar with a client

[SQL] Re: constants in 2-column foreign keys or how to design a storage for text-groups ?

2009-12-11 Thread Jasen Betts
On 2009-12-09, Andreas wrote: > Hi, ... > stupid example: > --- > color: red, green, blue > size: tiny, little, big, giant > structure: hard, soft, floppy > > How would I solve the rather common text storage issue? have you considered using enumerated types instead? -- Sent vi

Re: [SQL] Proper case function

2010-01-01 Thread Jasen Betts
On 2009-12-31, Michael Gould wrote: > Gary, > > Based on what I read it wouldn't handle cases where the result should be > > MacDonald from macdonald. There are other cases such as the sentence below > > ('it''s crazy! i couldn''t believe kate mcdonald, leo dicaprio, (terrence) > trent d''arby (c

Re: [SQL] problem using regexp_replace

2010-01-11 Thread Jasen Betts
On 2010-01-11, gher...@fmed.uba.ar wrote: > CREATE FUNCTION valores_sustitucion(valor_ingresado varchar[]) > returns varchar > as > $$ > select case > $1[1] when 'Action_1' then > (select descripcion from load_by_cod($1[2])) > >when 'Action_2' then (select descripcion from pay_by_view($

Re: [SQL] problem using regexp_replace

2010-01-12 Thread Jasen Betts
On 2010-01-11, gher...@fmed.uba.ar wrote: > So, i come with this: > SELECT regexp_replace( > formato, E'{([^.]*)\.([a-zA-Z0-9]*)}, > valores_sustitucion(ARRAY[E'\\1'::varchar,E'\\2'::varchar]), > 'g') > from table where id =1; select valores_sustitucion(ARRAY[E'\\1'::varchar

Re: [SQL] 'image' table with relationships to different objects

2010-02-11 Thread Jasen Betts
On 2010-02-09, Louis-David Mitterrand wrote: > Hello, > > In my database I have different object types (person, location, event, > etc.) all of which can have several images attached. can one image be several people? can one image be both event and location? > What is the best way to manage a

Re: [SQL] very frustrating feature-bug

2010-02-17 Thread Jasen Betts
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=> > > ERROR: return type mismatch in f

Re: [SQL] Create functions using a function

2010-03-08 Thread Jasen Betts
On 2010-03-01, Gianvito Pio wrote: > --001485f44fc07594a40480c43c01 > Content-Type: text/plain; charset=ISO-8859-1 > > Hi all, > is there a way to define functions and/or triggers in a function? assuming plpgsql: execute > For example, can I create a function that takes an argument and defines a

Re: [SQL] Does IMMUTABLE property propagate?

2010-03-08 Thread Jasen Betts
On 2010-03-06, Petru Ghita wrote: > > Given f1(x) as IMMUTABLE and f2(x) as IMMUTABLE, and f3(f1,f2) as > IMMUTABLE, does the query planner cache the result of f3 and reuse it > or if you want to get a little more speed you better explicitly define > yourself f3 as IMMUTABLE? > > I had an aggreg

Re: [SQL] Clarification With Money data type

2010-03-11 Thread Jasen Betts
On 2010-03-10, Navanethan Muthusamy wrote: > --0016e68e9a5510f1f504816d1fcb > Content-Type: text/plain; charset=ISO-8859-1 > > Hi, > > I am using Postgresql 8.4, Can you tell me How Can I use Money data type? it's best not to, "money" is a fixed-point fromat based on 32 bit integers, abn it's

Re: [SQL] Private functions

2010-03-13 Thread Jasen Betts
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. -- Sent via pgsql-sql mailing list (pgsql-sql@

Re: [SQL] list of all months

2010-03-16 Thread Jasen Betts
On 2010-03-08, query wrote: > --=_484d28810a276e7b5e461f0328ee205f > Content-Transfer-Encoding: 7bit > Content-Type: text/plain; charset="UTF-8" > > Hi, > > I want to display data for all days in a month even if no data > exists for that month. Some of the days in a month might not have any > data

Re: [SQL] Plpgsql: Iterating through a string of parameters

2010-03-26 Thread Jasen Betts
On 2010-03-25, Leif Biberg Kristensen wrote: > I'm struggling with how to make plpgsql iterate through a list of numbers > input as a text string, eg. "1438 2656 973 4208". I figure that I can use the > regexp_split_to_array() function to make an array of the string, but can I > iterate through

Re: [SQL] Week to date function

2010-03-31 Thread Jasen Betts
On 2010-03-27, Hiltibidal, Rob wrote: > U only 52 calendar weeks in a year... I'm almost sure that is the > norm All hours have 60 minutes All weeks have 7 days All years have 12 months all else is variable. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to

[SQL] Re: CHECK constraints with plpgsql functions - check 'fires' BEFORE data modification?

2010-04-19 Thread Jasen Betts
ate enum_agreement_state) RETURNS boolean AS $$ SELECT CASE COUNT(agreement_id) WHEN 0 THEN true WHEN 1 THEN $3 != 'approved' ELSE false END FROM agreements WHERE subject_id = $1 AND agreement_state = 'approved' a

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

2010-04-30 Thread Jasen Betts
On 2010-04-29, Andreas wrote: > Hi, > > while writing the reply below I found it sounds like beeing OT but it's > actually not. > I just need a way to check if a collumn contains values that CAN NOT be > converted from Utf8 to Latin1. > I tried: > Select convert_to (my_column::text, 'LATIN1') fr

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

2010-04-30 Thread Jasen Betts
On 2010-04-29, Justin Graf wrote: > I'm pretty sure this is the regualr expression to find all non ASCII=20 > chars.. [^\x00-\xFF] Not in postgres. \x00 does not work well in strings, and \xFF is invalid utf-8. this is why I used char() (also ASCII is undefined past at \x7F ... but the or

Re: [SQL] LIMIT problem

2010-04-30 Thread Jasen Betts
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 on it? not sure > Or we have to

Re: [SQL] How to get localized to_char(DATE) output

2010-05-06 Thread Jasen Betts
On 2010-05-06, Thomas Kellerer wrote: > Tom Lane, 06.05.2010 00:51: >> Thomas Kellerer writes: >>> I'm trying to get the output of the to_char(date, text) method in German >>> but I can't get it to work: >> >> I think you need 'TMMon' to get a localized month name. >> >> reg

Re: [SQL] Greetings folks, dumb question maybe?

2010-05-13 Thread Jasen Betts
On 2010-05-12, Josh wrote: > Hello, I'm a little new at this so please bear with me. > > I am trying to create a function that loads 100M test records into a > database, however I am having a hard time building the function that > does so. > > I'm trying to do this in PGAdmin III for Ubuntu. I

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

2010-05-13 Thread Jasen Betts
On 2010-05-11, Torsten Zühlsdorff wrote: > Hello, > > i have a problem with a trigger written in pl/pgsql. > > It looks like this: > > CREATE OR REPLACE FUNCTION versionize() > RETURNS TRIGGER > AS $$ > BEGIN > >NEW.revision := addContentRevision (OLD.content_id, OLD.revision); > >/* not w

Re: [SQL] How to get CURRENT_DATE in a pl/pgSQL function

2010-05-19 Thread Jasen Betts
On 2010-05-18, Kenneth Marshall wrote: > I am trying to write a function that updates the > date column to the current date. According to: > > http://www.postgresql.org/docs/8.4/static/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT > > you can use CURRENT_DATE. When I try to use it in > the fo

Re: [SQL] cast record type to array?

2010-05-28 Thread Jasen Betts
On 2010-05-26, Gerardo Herzig wrote: > Hi all. Im not being able to cast a record variable into an array. > > Im writing a trigger, and i would like to store NEW (and OLD) as text[]. > There is a way to do it in plpgsql? (w/o any contrib modules) why not store them as text instead? new::text

Re: [SQL] Extending Regular Expression bounds limit of 255.

2010-05-29 Thread Jasen Betts
On 2010-05-27, Brent DeSpain wrote: > --00504502c13812967604879b4ba3 > Content-Type: text/plain; charset=ISO-8859-1 > > It looks like most of our tools are using the Perl version of regular > expressions with an upper limit of a bound being 32766. Is there any way to > change this in PG? Or can

Re: [SQL] Extending Regular Expression bounds limit of 255.

2010-05-30 Thread Jasen Betts
On 2010-05-29, Tim Landscheidt wrote: > Jasen Betts wrote: > >>> It looks like most of our tools are using the Perl version of regular >>> expressions with an upper limit of a bound being 32766. Is there any way to >>> change this in PG? Or can I change from PO

Re: [SQL] how to construct sql

2010-06-04 Thread Jasen Betts
On 2010-06-02, Wes James wrote: > On Wed, Jun 2, 2010 at 10:55 AM, Oliveiros > wrote: >> Hi, >> Have you already tried this out? >> >> select MAX(page_count_count) - MIN(page_count_count)  from page_count group >> by page_count_pdate. >> >> >> Best, >> Oliveiros > > Oliveiros, > > Thx that mostly

Re: [SQL] ORDER BY is case insensitive

2010-06-23 Thread Jasen Betts
On 2010-06-22, Bryan White wrote: > I was suprised to find out that ORDER BY is case insensitive. Is > there a way to do a case sensitive ORDER BY clause? use bytea instead of a text type. > This transcript demonstrates what I am seeing: > > bryan=# select * from t order by f; > f > --- > a >

Re: [SQL] question about partitioning

2010-06-24 Thread Jasen Betts
On 2010-06-24, Joshua Gooding wrote: > Right now I am in the process of migrating an Oracle DB over to Postgres > 8.4.3. The table is partitioned by size. Is there anyway to partition > the new postgres table by size? I created some partitions for the new > table, but I didn't give postgres

Re: [SQL] Round integer division

2010-06-26 Thread Jasen Betts
On 2010-06-25, Lee Hachadoorian wrote: > Is it documented anywhere that floating-point numbers round > "scientifically", that is 0.5 rounds to the nearest even number? That's swiss rounding. And no, as I understand it documented that most arithmetic) is platform specific. Postgres is written

Re: [SQL] Round integer division

2010-06-26 Thread Jasen Betts
On 2010-06-25, Lee Hachadoorian wrote: > > > On 06/25/2010 07:00 PM, Scott Marlowe wrote: >> That all floating point representations are approximate? >> > But if it's error due to approximation, shouldn't the result be random? > I tried this for a handful of larger numbers, and it appears to > con

Re: [SQL] multi table import from 1 denormalized source table

2010-11-16 Thread Jasen Betts
On 2010-11-16, Andreas wrote: > Hi, > > I frequently get tables from spreadsheets to import into the DB. > > Usually it looks like this: > A1, A2, A3, A4, B1, B2, B3, with optional C1, C2, D1, D2, ... > > and there is a 1:n relation between A and B. > If provieded the C would be 1:1 to A and

Re: [SQL] subselect and left join not working?

2010-11-29 Thread Jasen Betts
On 2010-11-29, Jorge Arenas wrote: > select zona_id from zonas where zona_id not in (select zona_id from usuarios ### ###### > where per_id =2) select 'FRED' from from usuarios where per_id =2 what'shappening is your not in subquery is be

Re: [SQL] DELETE WHERE EXISTS unexpected results

2010-12-01 Thread Jasen Betts
On 2010-11-30, Jeff Bland wrote: > This is a multipart message in MIME format. > --=_alternative 007A6509852577EB_= > Content-Type: text/plain; charset="US-ASCII" > > I want to delete certain rows from table USER_TBL. > Two tables are involved. USER_TBL and OWNER_TBL. delete ... using was inv

Re: [SQL] Union Question

2010-12-03 Thread Jasen Betts
On 2010-12-03, Shaun McCloud wrote: > --_000_7742DD496427B743BC8B7BBF6D380BA0A2F114EXCHANGE10geocomm_ > Content-Type: text/plain; charset="us-ascii" > Content-Transfer-Encoding: quoted-printable > > Hello, > > I need to union three PostgreSQL tables and this won't be a problem but the= > tables a

Re: [SQL] The best option to insert data with primary id

2010-12-11 Thread Jasen Betts
On 2010-12-06, - wrote: > --0016364d26cf7fa4970496bf2224 > Content-Type: text/plain; charset=ISO-8859-1 > > Hi everyone, > I have a question about how best to insert and manipulate the table with > primary key id for better productivity. I need to insert data into the table > and get last id. > >

Re: [SQL] Regular Expression Match Operator escape character

2010-12-13 Thread Jasen Betts
On 2010-12-08, Gnanakumar wrote: > Hi, > > We're running PostgreSQL v8.2.3 on RHEL5. > > In some places in our application, we use Regular Expression Match Operator > (~* => Matches regular expression, case insensitive) inside WHERE criteria. > > Example: > SELECT ... > FROM ... > WHERE (SKILLS ~

Re: [SQL] constraint with check

2010-12-13 Thread Jasen Betts
On 2010-12-13, Viktor Bojović wrote: > --0015175cd20209e2030497532e39 > Content-Type: text/plain; charset=UTF-8 > Content-Transfer-Encoding: quoted-printable > > Hi > im trying to create foreign key constraint which checks not only the > existence of key in foreign table, but it has to check if no

Re: [SQL] UPDATE in a specific order

2010-12-16 Thread Jasen Betts
> I need to make update of table1 with data on table2 in the order of id > of table2 that looks like EAV. is it? > I=B4m trying to do an update like this: that's not going to work. perhaps you can rewrite the from part to only return one row for every table1_fk, this one row will combine seve

Re: [SQL] foreign key question

2011-01-05 Thread Jasen Betts
On 2011-01-05, Gary Stainburn wrote: > On Wednesday 05 January 2011 09:53:43 Gary Stainburn wrote: >> Now I want to set up a new access level table specific to the itinerary, >> along the lines of >> >> u_id int4 not null references users(u_id) >> fl_level int4 not null references facility_levels(

Re: [SQL] pattern matching with dates?

2011-01-08 Thread Jasen Betts
On 2011-01-05, Good, Thomas wrote: > This dubious query worked well previously: > select * from db_log where log_date LIKE '2011-01-%'; > (currently works on bluehost.com where they run 8.1.22) > > Can someone offer a (preferably ANSI compliant) way to do this on 8.4.5? where date_trunc( log_da

Re: [SQL] Issue with postgres connectivity

2011-01-22 Thread Jasen Betts
On 2011-01-21, Arindam Hore wrote: > We are accessing database using ip address. try adding the IP addresses of some of the clients as seen by the server to /etc/hosts on the server. see if that helps. try connecting to the server locally using 'su postgres -c psql' see if that's slow too. --

Re: [SQL] question about reg. expression

2011-01-22 Thread Jasen Betts
On 2011-01-18, andrew1 wrote: > hi all, > > these return t: > select 'ab' ~ '[a-z]$' this matches the b and the end of the string > select 'ab' ~ '^[a-z]' this matches the start of the string and the a > select 'ab' ~ '^[a-z]$' returns f > Can't I use ^ and $ at the same time to match, in thi

Re: [SQL] Compare the resulta of a count sql into bash

2011-01-27 Thread Jasen Betts
On 2011-01-26, manuel antonio ochoa wrote: > --0015174be152ceb275049ac2dc95 > Content-Type: text/plain; charset=ISO-8859-1 > > Hello, > I have the next : > > COUNTONE=`/var/lib/pgsql/bin/./psql -U 'Thor' -d princlocal -p 5432 -h > 192.170.1.82 -c "select count(*) from monterrey.${NOMBRETB}"` >

Re: [SQL] something simple but I can't

2011-01-28 Thread Jasen Betts
On 2011-01-29, John Fabiani wrote: > Hi guys, > I trying to return a 0.00 from a function it there are no records found else > return the amount. > select sum(aropen_paid) into _paidamt FROM public.aropen where > aropen_applyto is not null and (aropen_applyto = $1) ; > > IF (FOUND) T

Re: [SQL] DELETE FROM takes forever

2011-02-12 Thread Jasen Betts
On 2011-02-10, Josh wrote: > Hi > > I'm trying to do a DELETE FROM on my large table (about 800 million > rows) based on the contents of another, moderately large table (about > 110 million rows). The command I'm using is: > > DELETE FROM records WHERE id NOT IN (SELECT id FROM unique_records); >

Re: [SQL] UTF characters compromising data import.

2011-02-12 Thread Jasen Betts
On 2011-02-08, Gavin Beau Baumanis wrote: > I understand the error message - but what I don't know is what I > need to set the encoding to - in order to import / use the data. if you run it through iconv --from-code=ASCII -to-code=UTF8 -c it'll strip out all the non-ascii symbols, wi

Re: [SQL] Determine length of numeric field

2011-02-19 Thread Jasen Betts
On 2011-02-15, Tony Capobianco wrote: > I'm altering datatypes in several tables from numeric to integer. In > doing so, I get the following error: > > dw=# \d uniq_hits > Table "support.uniq_hits" >Column | Type | Modifiers > +-+--- > sourceid | numer

Re: [SQL] converting big int to date

2011-03-26 Thread Jasen Betts
On 2011-03-23, Sree wrote: > --90e6ba2123fbe15f02049f2ccf73 > Content-Type: text/plain; charset=ISO-8859-1 > > How can i convert bigint to date format. > > bigint=6169625280 that's got the right number of zeros to be a date expressed as microseconds since epoch in which case the magic s

Re: [SQL] converting big int to date

2011-03-27 Thread Jasen Betts
On 2011-03-26, Jasen Betts wrote: > that's got the right number of zeros to > be a date expressed as microseconds since epoch except the code which produces a likely data treats it as nanoseconds -- ⚂⚃ 100% natural -- Sent via pgsql-sql mailing list (pgsql-sql@postgre

Re: [SQL] convert in GMT time zone without summer time

2011-04-16 Thread Jasen Betts
On 2011-04-15, LaraK wrote: > Hello, > > I want write a function that converts a timestamp with time zone to the UTC > zone. But it should all be stored in the winter time. > > For example, it must now, in the summer, the German time back by 2 hours and > in the winter time only 1 hour. But it exp

Re: [SQL] Get id of a tuple using exception

2011-04-16 Thread Jasen Betts
On 2011-04-14, f vf wrote: > --000e0cd2bf6a60c30804a0dec84b > Content-Type: text/plain; charset=ISO-8859-1 > > Hello, > i'm using a pl/sql procedure and I prevent inserting duplicate tuples using > an exception for example: > > BEGIN >INSERT INTO "Triples"(id, subject, predicate, "object

Re: [SQL] help on select

2011-04-21 Thread Jasen Betts
On 2011-04-20, Saulo Venâncio wrote: > --bcaec52e65e9b2f22304a15f3840 > Content-Type: text/plain; charset=ISO-8859-1 > Content-Transfer-Encoding: quoted-printable > > Hi guys, > I need your help. > I have a table called medidas, in this table i have some ocurrences that ha= > s > id_medida(primary

Re: [SQL] self join

2011-05-14 Thread Jasen Betts
On 2011-05-14, Seb wrote: > Hi, > > This probably reflects my confusion with how self joins work. > > Suppose we have this table: > If I want to get a table with records where none of the values in column > b are found in column a, I thought this should do it: use the "NOT IN" operator with a su

Re: [SQL] self join

2011-05-17 Thread Jasen Betts
On 2011-05-16, Steve Crawford wrote: > On 05/14/2011 07:36 PM, Jasen Betts wrote: >> >> use the "NOT IN" operator with a subquery to retch the disallowed >> values > Hmmm, "retch" as a synonym for "output"? I've seen more than one cas

[SQL] Re: Order of evaluation in triggers for checks on inherited table partitions

2011-05-30 Thread Jasen Betts
On 2011-05-27, Kevin Crain wrote: > I am trying to create a trigger on updates to a table that is > partitioned. The child tables are partitioned by month and include > checks on a timestamp field. > However when I try to update an existing record with a > timestamp that would place it in a chi

Re: [SQL] selecting records X minutes apart

2011-06-04 Thread Jasen Betts
On 2011-06-03, lists-pg...@useunix.net wrote: > > IDTS (HH:MM) > --- > 0 20:00 > 0 20:05 > 0 20:10 > 1 20:03 > 1 20:09 > > > Does my question make sense? no, why is (1,20:04) excluded, but (0,20:05) included? both records are 5 minutes from the newest. --

Re: [SQL] ANY for Array value check

2011-06-11 Thread Jasen Betts
On 2011-06-10, Emi Lu wrote: > Good morning, > > String array compare command, I forgot how to do it. > > E.g., > create table z_drop(id varchar[]); > insert into z_drop values('{"a1", "a2", "b1", "b2", "b3"}'); > > I'd like to do: > > select * from z_drop where id = any('a1', 'b1'); use the arra

Re: [SQL] Storage of Indian Language text in postgresql through PHP

2011-06-15 Thread Jasen Betts
On 2011-06-14, INDER wrote: > Hello Everyone. I am new to this group and as well as to the Postgres > also. Can anybody tell me that how to insert hindi text into postgres > that a user has entered from html input with the use of PHP. Please I > am waiting for the reply. add this PHP before any c

Re: [SQL] pagination problem in postgresql need help

2011-06-19 Thread Jasen Betts
On 2011-06-17, hatem gamal elzanaty wrote: > hi, > please see this code > > select aiah_number.aiah_number_id, aiah_number.aiah_number, ... > order by rank_value desc limit 1 offset 0; > > and this code > > select aiah_number.aiah_number_id, aiah_number.aiah_number, ... > order by rank_value des

Re: [SQL] interesting sequence

2011-07-06 Thread Jasen Betts
On 2011-07-06, Kevin Crain wrote: > That's why you need to do this inside a function. Basically just make > an insert function for the table and have it calculate the count and > do the insert in one transaction. you will still get duplicates, so include code in the function to retry if there is

Re: [SQL] Looking for a "show create table " equivalent

2011-07-14 Thread Jasen Betts
On 2011-07-12, B.Rathmann wrote: > Hello, > > I've been trying to find out how to find out which sql was run to create > a certain table. That's like trying to find what change was used to create $1.83 there several possible answers all but one of them wrong, but many of them may . > As I nee

Re: [SQL] to_char() accepting invalid dates?

2011-07-18 Thread Jasen Betts
On 2011-07-18, Thomas Kellerer wrote: > Hi, > > I just noticed that to_char() will "accept" invalid dates such as 2011-02-31 > and "adjust" them accordingly: > > postgres=> select to_date('20110231', 'mmdd'); > >to_date > > 2011-03-03 > (1 row) > > is there a way to have to

Re: [SQL] Generic design: char vs varchar primary keys

2011-08-05 Thread Jasen Betts
On 2011-08-03, Raj Mathur (=?utf-8?b?4KSw4KS+4KSc?= =?utf-8?b?IOCkruCkvuCkpeClgeCksA==?=) wrote: > Hi, > > Can you point me to any pages that explain the difference between using, > say CHAR(8) vs VARCHAR(8) as the primary key for a table? Is there any > impact on the database in terms of: lo

Re: [SQL] Generic design: char vs varchar primary keys

2011-08-05 Thread Jasen Betts
On 2011-08-04, Raj Mathur (=?utf-8?b?4KSw4KS+4KSc?= =?utf-8?b?IOCkruCkvuCkpeClgeCksA==?=) wrote: > Thanks, that's useful for benchmarking the various textual data types. > Anything specific about using CHAR vs VARCHAR for primary keys that are > going to be referenced from multiple tables tha

Re: [SQL] which is better: using OR clauses or UNION?

2011-08-16 Thread Jasen Betts
On 2011-08-16, adam_pgsql wrote: > > Hi, > > I have a query hitting a table of 25 million rows. The table has a >text field ('identifier') which i need to query for matching rows. The >question is if i have multiple strings to match against this field I >can use multiple OR sub-statements or multi

Re: [SQL] exclusion constraint for ranges of IP

2011-08-22 Thread Jasen Betts
On 2011-08-21, Herouth Maoz wrote: > Hi, > > I'm designing a new database. One of the table contains allowed IP ranges for > a customer (Fields: customer_id, from_ip, to_ip) which is intended to check - > if an incoming connection's originating IP number falls within the range, it > is identif

Re: [SQL] Confused about writing this stored procedure/method.

2011-08-23 Thread Jasen Betts
On 2011-08-22, JavaNoobie wrote: > Hi All, > I'm trying to write a stored procedure /function to re-order a set of > calendar months.I have a set of calendar months stored from January to > December in my tables. And as of now when I do order by on this column , > the data is ordered alphabetical

Re: [SQL] exclusion constraint for ranges of IP

2011-08-23 Thread Jasen Betts
On 2011-08-23, Herouth Maoz wrote: > EXCLUDE USING GIST ( customer_id WITH =, is_default WITH AND ) > Basically, each customer can have several rows in this table, but only = > one per customer is allowed to have is_default =3D true. Is this exclude = > constraint correct? I don't really

Re: [SQL] where col1 not ilike ('str1%', 'str2%'... 'strN%') support?

2011-08-31 Thread Jasen Betts
On 2011-08-30, Emi Lu wrote: > Hi Tom, > select * from tablename where not (col1 ~~* any(array['str1%', 'str2%'... 'strN%'])); >> >>> If next version could have "not ilike ('', '')" added into window >>> functions, that's will be great! >> >> Why? And what's this got to do with window f

Re: [SQL] Want some basic compare of data type on PostgreSQL and MySQL

2011-09-01 Thread Jasen Betts
On 2011-09-01, bhavesh1385 wrote: > Hello All, > > I Want some basic compare of data type on PostgreSQL and MySQL. > > [1] How to make Primary Key as a Auto Increment...? you can't, use the pseudo-type serial (or bigserial) instead which does something similar, but subtly different. > [2] Suppo

Re: [SQL] Dynamic sql

2011-09-10 Thread Jasen Betts
On 2011-09-10, Gabriel Filipiak wrote: > --bcaec517adbceea3c804ac90a376 > Content-Type: text/plain; charset=ISO-8859-1 > > Hi, this is my first on this list. > > I want to know the basics of dynamic sql especially in PostgreSQL. I was > googling for a while but have no luck for getting a good desc

Re: [SQL] Edit multiple rows concurrent save

2011-10-08 Thread Jasen Betts
On 2011-09-29, Péter Szabó wrote: > users_has_cards.auctions + users_has_cards.decks never can be higher > then users_has_cards.total. It should be also granted that > users_has_cards.total - users_has_cards.auctions number of cards from > a specific type can be in any decks. > > The deck assembl

Re: [SQL] Number timestamped rows

2011-11-08 Thread Jasen Betts
On 2011-11-02, Jan Peters wrote: > Dear all, > maybe a stupid question, but: I have a table that is ordered like this: > Tables aren't ordered. Sometimes they may seem to be ordered, but they seldom stay that way for long. > and I would like to number them according to their timestamps like th

Re: [SQL] the use of $$string$$

2011-11-08 Thread Jasen Betts
On 2011-11-07, Richard Huxton wrote: > On 05/11/11 00:12, John Fabiani wrote: > OK, so it seems psycopg is quoting your strings for you (as you'd > expect). It's presumably turning your query into: > ... values (E'123', $$E''$$) > So - the $$ quoting is unnecessary here - just use the % pla

Re: [SQL] Partitionning + Trigger and Execute not working as expected

2011-11-12 Thread Jasen Betts
On 2011-11-08, Sylvain Mougenot wrote: > --f46d043c7fbad4a6b104b1357041 > Content-Type: text/plain; charset=ISO-8859-1 > Content-Transfer-Encoding: quoted-printable > > Hello, > I'm trying to use table partitionning on a table called JOB. > Each month a new table is created to contain the rows cre

Re: [SQL] Updatable view should truncate table fields

2011-11-12 Thread Jasen Betts
On 2011-11-08, Russell Keane wrote: > > We can extend the table to accept more than 5 characters but the view must = > return 5 characters. > If we try to extend the table to accept, say, 10 characters the view will d= > isplay 10. > If I also cast the view field to 5 characters then any insert wi

Re: [SQL] updating a sequence

2011-11-16 Thread Jasen Betts
On 2011-11-16, Scott Marlowe wrote: > You need to wrap a subselect in (): > > select setval('foo', (select max(some_id) from some_table)); I prefer to do it in once select like this: select setval('foo', max(some_id)) from some_table; -- ⚂⚃ 100% natural -- Sent via pgsql-sql mailing list

Re: [SQL] conditional FROM

2011-12-10 Thread Jasen Betts
On 2011-12-10, Richard Klingler wrote: > Good day... > > I'm trying to build a query for PGSQL 9.1 where a table has two > references with only one being used depending of the type of entry.. > > For example, the table has following simplified structure: > > portid primary key >

Re: [SQL] Question on imports with foreign keys

2011-12-10 Thread Jasen Betts
On 2011-12-08, Andreas wrote: > Hi, > > suppose you need to import a csv with standard ciolums like name, > adress, phone, ... and some additional text columns that need to be > split off into referenced tables. ... > How is the easiest way to to find the customer.id of the new customers > so I

Re: [SQL] partitions versus databases

2011-12-10 Thread Jasen Betts
On 2011-12-08, chester c young wrote: > have an db with about 15 tables that will handle many companies. no data > overlap between companies. is it more efficient run-time to use one database > and index each row by company id, and one database and partition each table > by company id, or to

Re: [SQL] internal format of timstamp?

2011-12-29 Thread Jasen Betts
On 2011-12-29, Lars Gustafsson wrote: > Hi, > > I am trying to recover a lot of deleted rows from a database ( pg > 8.2.3 ) , not my database, I promise….. >> When using the tool pgfsck I get good results, but timestamp is not >> implemented. > > When trying to export as int8 i get fx. 4

[SQL] Re: Current transaction is aborted, commands ignored until end of transaction block

2012-01-01 Thread Jasen Betts
On 2011-12-30, Jan Bakuwel wrote: > This is a cryptographically signed message in MIME format. > > What annoys me is that I don't think that a constraint violation made by > a user should result in an aborted transaction. There is probably a very > good reason to do that however the logic escapes

Re: [SQL] lo_import

2012-01-03 Thread Jasen Betts
On 2012-01-03, Maurício Cruz wrote: > Hi all, > > I'm trying to use lo_import to import a file into my database, if I > execute from postgres runing in my local machine > it works perfectly, but if I do it in the postgres runing in the server, > it says "No such file or directory" > > I Guess po

  1   2   >