Re: [SQL] Order of execution

2013-05-06 Thread Jasen Betts
On 2013-05-06, JORGE MALDONADO wrote: > --089e013d1eb83325e504dc01710d > Content-Type: text/plain; charset=ISO-8859-1 > > I have an UPDATE query which performs several opertions in one table. > > UPDATE table01 SET > field1 = (query1 may contain any field), > field2 = (query1 may contain any field

Re: [SQL] execute

2013-04-27 Thread Jasen Betts
On 2013-04-25, Mauricio Cruz wrote: > declare > > aCad > text[][] > > begin > > ... > > execute 'aCad:=aCad > array[['||var1||','||var2||']]' execute 'select array[['||var1||','||var2||']]' into acad; -- ⚂⚃ 100% natural -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) T

Re: [SQL] Peer-review requested of soft-delete scheme

2013-04-18 Thread Jasen Betts
On 2013-04-16, Mark Stosberg wrote: > My challenge is that I want to make very hard or impossible to access > the soft-deleted rows through SELECT statements. There are lots of > selects statements in the system. > > My current idea is to rename the "foo" table to something that would > stand-out

Re: [SQL] Restrict FOREIGN KEY to a part of the referenced table

2013-04-12 Thread Jasen Betts
On 2013-04-11, Matthias Nagel wrote: > Hello, > > is there any best practice method how to create a foreign key that only > allows values from those rows in the referenced table that fulfill an > additional condition? tes. make the key wide enough to capture this state. I dom't like it either.

Re: [SQL] Advice for index design

2013-04-12 Thread Jasen Betts
On 2013-04-10, JORGE MALDONADO wrote: > Our application offers a catalog of artists where a user can select a range > of birthdays and/or sex. For example, a user can get an artists catalog for > those male artists who were born between May 1, 1970 and May 1, 1990 > ordered by birthday and, with

Re: [SQL] ZIP function

2013-03-16 Thread Jasen Betts
On 2013-03-16, Victor Sterpu wrote: > > =_MBF521B7A8-BC31-4E93-BC62-8C86007F2089 > Content-Transfer-Encoding: quoted-printable > Content-Type: text/plain; format=flowed; charset=utf-8 > > Is there a function that will give the resulting zip content for a=20 > string? > Like SELECT zip('tes

Re: [SQL] Concatenating bytea types...

2013-03-02 Thread Jasen Betts
On 2013-02-28, Marko Rihtar wrote: > --047d7b603fca8e330f04d6c63f7b > Content-Type: text/plain; charset=ISO-8859-1 > > Hi all, > > i have a little problem. > cv1 := CONCAT(cv1, DECODE(TO_HEX(11), 'escape')); what's that supposed to do? if I were to fix it how would I know? -- ⚂⚃ 100% natur

Re: [SQL] Conditional expression in an UPDATE statement

2013-02-06 Thread Jasen Betts
On 2013-02-07, JORGE MALDONADO wrote: > Can I use a conditional expression in an UPDATE query like this: > > UPDATE table_1 SET > field_1 = > CASE WHEN (condition) THEN (COALESCE(query_1, -1)) > ELSE (COALESCE(query_1, -2)) > END > yesh, that should work. -- ⚂⚃ 100% natural -- Se

Re: [SQL] Setting a default value for a select statement without results

2013-02-05 Thread Jasen Betts
On 2013-02-06, JORGE MALDONADO wrote: > --f46d0401fb2fcb805e04d50354b1 > Content-Type: text/plain; charset=ISO-8859-1 > > I have an UPDATE query with the following general structure: > > UPDATE table1 SET (SELECT field FROM table2 WHERE conditions ORDER BY > order_field LIMIT 1) assuming you mean

[SQL] Re: returning the number of rows output by a copy command from a function

2013-01-17 Thread Jasen Betts
On 2013-01-16, James Sharrett wrote: > The problem I have is that I get nothing back when the COPY is run inside > the function other than what I explicitly return from the function so I > don't have anything to parse. It's odd that the record count in the > function is treated differently than f

Re: [SQL] Can't get upsert working.

2012-12-03 Thread Jasen Betts
On 2012-12-02, Jasen Betts wrote: > On 2012-11-30, Bert wrote: > >> Anyone here with upsert experience? This guy "Depesz" does: http://www.depesz.com/2012/06/10/why-is-upsert-so-complicated/ -- ⚂⚃ 100% natural -- Sent via pgsql-sql mailing list (pgsql-sql@postgresq

Re: [SQL] organizing cron jobs in one function

2012-11-19 Thread Jasen Betts
On 2012-11-17, Louis-David Mitterrand wrote: > Hi, > > I'm planning to centralize all db maintenance jobs from a single > pl/pgsql function called by cron every 15 minutes (highest frequency > required by a list of jobs). In pseudo code: centralising execution of cron jobs into a single function

Re: [SQL] Trigger triggered from a foreign key

2012-10-22 Thread Jasen Betts
On 2012-10-19, Victor Sterpu wrote: > I have this trigger that works fine. The trigger prevents the deletion > of the last record. > But I want skip this trigger execution when the delete is done from a > external key. > How can I do this? perhaps you have to use a rule instead of a trigger? -

Re: [SQL] Calling the CTE for multiple inputs

2012-10-11 Thread Jasen Betts
On 2012-10-04, air wrote: > I have a CTE that takes top left and bottom right latitude/longitude values > along with a start and end date and it then calculates the amount of user > requests that came from those coordinates per hourly intervals between the > given start and end date. However, I wa

Re: [SQL] checking the gaps in intervals

2012-10-11 Thread Jasen Betts
On 2012-10-05, Anton Gavazuk wrote: > Hi dear community, > > Have probably quite simple task but cannot find the solution, > > Imagine the table A with 2 columns start and end, data type is date > > start end > 01 dec. 10 dec > 11 dec. 13 dec > 17 dec. 19 dec > . > > If I

Re: [SQL] Reuse temporary calculation results in an SQL update query

2012-10-01 Thread Jasen Betts
On 2012-09-29, Matthias Nagel wrote: > Hello, > > is there any way how one can store the result of a time-consuming calculation > if this result is needed more than once in an SQL update query? This solution > might be PostgreSQL specific and not standard SQL compliant. Here is an > example of

Re: [SQL] HOw to convert unicode to string

2012-10-01 Thread Jasen Betts
On 2012-09-23, Abhijit Prusty -X (abprusty - UST Global at Cisco) wrote: > --_000_8A2A33BFAA5E2F408D0BBB80844412720487D0xmbalnx03ciscocom_ > Content-Type: text/plain; charset="us-ascii" > Content-Transfer-Encoding: quoted-printable > > Hi, > > I have a query in oracle like this mentioned below >

Re: [SQL] Problem with committing the update

2012-09-22 Thread Jasen Betts
On 2012-09-13, BeeBee wrote: > Hi all, > > I have a problem updating the record using store procedure (LANGUAGE > plpgsql).I have attach the query. it all looks good to me. -- ⚂⚃ 100% natural -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription

Re: [SQL] generated dates from record dates - suggestions

2012-08-21 Thread Jasen Betts
On 2012-08-20, Gary Stainburn wrote: > Hi folks. > > I've got a table with three dates which are populated from an external source. > I then want to have a view with two calculated dates in it, e.g. > > if date_1 is null and date_2 is null then date_a=NULL > if date_1 is not null and date 2 is nul

Re: [SQL] Simple Upgrade from PostgreSQL version 8.1.11 (With schemas)

2012-07-13 Thread Jasen Betts
On 2012-07-10, Chris Preston wrote: > > Hello all, > How far can I get to a higher version of PostgreSQL by just entering a > command line instruction to upgrade without any major effort? 8.1.23 going to 8.2.x or later is going to need more effort, especially if any of your code relies on any o

Re: [SQL] Insane behaviour in 8.3.3

2012-06-18 Thread Jasen Betts
On 2012-06-15, Richard Huxton wrote: > On 15/06/12 16:32, Achilleas Mantzios wrote: >> On Παρ 15 Ιουν 2012 18:03:26 Scott Marlowe wrote: >>> Not talking about going to something after 8.3.19, just updating to >>> the latest 8.3 version. On most systems it's a simple: >>> >>> sudo apt-get upgrade

Re: [SQL] Insane behaviour in 8.3.3

2012-06-18 Thread Jasen Betts
On 2012-06-15, Achilleas Mantzios wrote: > On Παρ 15 Ιουν 2012 18:03:26 Scott Marlowe wrote: >> Not talking about going to something after 8.3.19, just updating to >> the latest 8.3 version. On most systems it's a simple: >> >> sudo apt-get upgrade >> >> or similar and sit back and watch. > > T

Re: [SQL] possible bug in psql

2012-05-29 Thread Jasen Betts
On 2012-05-29, chester c young wrote: > do not know if right mailing list > > in psql in Ubuntu, when beginning with a smaller terminal, eg, 80 > col wide, then moving to a larger terminal, eg, 132 col wide, the > readline(?) editor in psql still treats like 80 cols, making it > impossible to edit

Re: [SQL] order by different on mac vs linux

2012-05-26 Thread Jasen Betts
On 2012-05-27, Wes James wrote: >> >> Why is there a different order on the different platforms. postgres uses the text comparison operators provided by the host platform. for linux these are defined in the locales package this may be part of the glibc package. > I'd like to bring up my questi

Re: [SQL] Understanding Binary Data Type

2012-05-23 Thread Jasen Betts
On 2012-05-22, Carlos Mennens wrote: > Hello everyone! I wanted to ask the list a question about the 'bytea' > data type & how I can picture this in my head. I've been reading SQL > for about a few months now and since then, I've only been working with > textual data. Basically I'm familiar with s

Re: [SQL] Need help in grouping records

2012-05-19 Thread Jasen Betts
On 2012-05-19, Andreas wrote: > Hi, > > I'm trying to fight against double entries in tables. > I got as far as I can find similar records with trigram string matching. > If I do this with a table compared to itself I get something like this: > > id_a, id_b > 3, 5 > 3, 7 > 5, 3 > 5, 7 > 7,

Re: [SQL] Finding Max Value in a Row

2012-05-11 Thread Jasen Betts
On 2012-05-11, Carlos Mennens wrote: > I have a problem in SQL I don't know how to solve and while I'm sure > there are 100+ ways to do this in ANSI SQL, I'm trying to find the > most cleanest / efficient way. I have a table called 'users' and the > field 'users_id' is listed as the PRIMARY KEY. I

Re: [SQL] getting the OS user name

2012-04-24 Thread Jasen Betts
On 2012-04-23, John Fabiani wrote: > Hi, > In my app it is possible to login as one name and use a different name to > login to postgres. > > Is it possible to get the actual OS login name using plsql. not a chance. RFC1413 man 3 ident looks like the parameters you need can be found here

Re: [SQL] How to html-decode a html-encoded field

2012-04-12 Thread Jasen Betts
On 2012-04-10, JORGE MALDONADO wrote: > --000e0ce0d2ee43edb104bd553408 > Content-Type: text/plain; charset=ISO-8859-1 > > I have a table with a varchar field, such a field is HTML ENCODED. So, for > example, the string "PLAIN WHITE T'S" is saved as "PLAIN WHITE > T''S" (double quotes are not part

Re: [SQL] Wrong output from union

2012-04-03 Thread Jasen Betts
On 2012-04-02, Gary Stainburn wrote: > Thanks for this David. > > Does anyone know why it too until Saturday for my post to appear on the listr? > > Gary If you haven't signed up for the mailing list with exactly the same email address that you post from the message will be held for moderation.

Re: [SQL] Problems with ODBC connections

2012-03-04 Thread Jasen Betts
On 2012-03-02, Sandeep Reddy wrote: > --e89a8ffba9b7723ad004ba47c368 > Content-Type: text/plain; charset=ISO-8859-1 > > Hi, The Error message is like this > > "Could not connect to server; A connection attempt failed because the > connected party did not properly respond after a periord..." >

Re: [SQL] No sort with except

2012-03-01 Thread Jasen Betts
On 2012-03-01, reto.buc...@wsl.ch wrote: > Dies ist eine mehrteilige Nachricht im MIME-Format. > --=_alternative 002D2CF5C12579B4_= > Content-Type: text/plain; charset="US-ASCII" > > Dear all, > > When I run the following SQL with PostgreSQL 9.1: > > -- > SELECT DISTINCT ON (pernr) pernr, vorna, n

Re: [SQL] How to split up phone numbers?

2012-02-23 Thread Jasen Betts
On 2012-02-20, Andreas wrote: > Hi, > is there a way to split up phone numbers? several. I wouldn't trust a computer to do any of them. > I know that's a tricky topic and it depends on the national phone number > format. > I'm especially interested in a solution for Germany, Swizerland and Aust

Re: [SQL] time interval math

2012-02-13 Thread Jasen Betts
On 2012-02-09, Edward W. Rouse wrote: >> the operation abs() is meaninless on the type interval >> eg: what is abs( '1 month - 32 days + 24 hours'::interval ) > > If you need to add 30 intervals together, then +- is not meaningless. if you stop reading after one line you miss the answer. --

Re: [SQL] time interval math

2012-02-09 Thread Jasen Betts
On 2012-02-08, Edward W. Rouse wrote: > I'm still working on getting this to work, but the summary is this: > > I am getting several (many) intervals of hour, minutes and seconds. I need a > sum of the absolute value these intervals, similar to the SUM(ABS()) > function for numbers; and I need to

Re: [SQL] type cast about int to bit

2012-02-06 Thread Jasen Betts
does the mailing list mangle these, or is it just GMANE? On 2012-02-06, zoulx1982 wrote: >hi, >there is a problem about type cast that i don't understand, follow is my test. > >postgres=# select 10::bit(3); > bit >- > 010 >(1 row) >postgres=# select 10::bit varying(3); >ERROR: cannot cast t

Re: [SQL] MS-SQL Store Procedure to Postgresql Function

2012-02-02 Thread Jasen Betts
On 2012-01-30, Rehan Saleem wrote: >hi , how i can convert this store procedure to PostgreSQL function, >especially I really dont know how to set type to readonly in PostgreSQL. >thanksUserACUserAC I don't actually understand T-SQL so I'm going from the structure more than from the actual meanin

Re: [SQL] Token separation

2012-01-20 Thread Jasen Betts
On 2012-01-16, Tim Landscheidt wrote: > Tom Lane wrote: > >>> [ "0x13" is lexed as "0" then "x13" ] > >>> Is this behaviour really conforming to the standard? > >> Well, it's pretty much the universal behavior of flex-based lexers, >> anyway. A token ends when the next character can no longer se

Re: [SQL] ignore unique violation OR check row exists

2012-01-04 Thread Jasen Betts
On 2012-01-03, Misa Simic wrote: > If exists is better, though insert line by line and check if exists may > be very slow... > > The best would be if you can use copy command from csv to staging table > (without constraints) and then > > Insert to live from stage where stage constraint column not

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

[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] 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

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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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-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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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. --

[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] 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

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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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

  1   2   >