Re: [SQL] Can I read the data without commit

2012-03-23 Thread Tim Landscheidt
John Fabiani jo...@jfcomputer.com wrote: Yes I understand - but I want to know is it possible? Can I read the data I just inserted without a commit. [...] Are you talking about a web application? Then no, you'll have to code that yourself. Tim -- Sent via pgsql-sql mailing list

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

2012-02-21 Thread Tim Landscheidt
(anonymous) wrote: is there a way to split up phone numbers? 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 Austria. I've got everything in a phone number column that makes hardly sense

Re: [SQL] time interval math

2012-02-08 Thread Tim Landscheidt
Edward W. Rouse ero...@comsquared.com wrote: Hehe, thanks, I played around and ended up with this: round(SUM(extract('epoch' from (time_out - time_in I will have to do the division outside of the query, but that's really a minor issue. You can always use subqueries.

Re: [SQL] Getting a list of a table's attributes that are sortable sorted by uniqueness

2012-01-26 Thread Tim Landscheidt
I wrote: I frequently use pg_dump to dump databases and compare them with diff. To get rid of most false positives, I'd like to patch pg_dump to sort the table so that its dumped order isn't changed more than necessary by insertions Co. So I'm looking for a query that will return a list

[SQL] Token separation

2012-01-15 Thread Tim Landscheidt
Hi, I just tried to input a hexadecimal number in PostgreSQL (8.4) and was rather surprised by the result: | tim=# SELECT 0x13; | x13 | - |0 | (1 Zeile) | tim=# SELECT 0abc; | abc | - |0 | (1 Zeile) | tim=# The documentation says: | A token can be a key word, an identifier,

Re: [SQL] lo_import

2012-01-03 Thread Tim Landscheidt
MaurĂ­cio Cruz c...@sygecom.com.br wrote: 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 postgres only see

[SQL] Getting a list of a table's attributes that are sortable sorted by uniqueness

2011-12-29 Thread Tim Landscheidt
Hi, I frequently use pg_dump to dump databases and compare them with diff. To get rid of most false positives, I'd like to patch pg_dump to sort the table so that its dumped order isn't changed more than necessary by insertions Co. So I'm looking for a query that will return a list of a

Re: [SQL] postgres sql help

2011-10-17 Thread Tim Landscheidt
Harald Fuchs hari.fu...@gmail.com wrote: hi, i am fairly new in postgresql, so if anyone can help me would be great if i simply do: select ver_no from version order by ver_no the result will be something like this: .1.3.1 .1.3.2.5. .1.4.1.7.12 .1.4.11.14.7. .1.4.3.109.1. .1.4.8.66.

Re: [SQL] how to calculate differences of timestamps?

2011-09-26 Thread Tim Landscheidt
(anonymous) wrote: How could I calculate differences of timestamps in a log-table? Table log ( user_id integer, login boolean, ts timestamp ) So login = true would be a login-event and login = false a logout. Is there a way to find the matching login/logout to calculate the difference?

Re: [SQL] Passing function parameters to regexp_replace

2011-09-17 Thread Tim Landscheidt
Leif Biberg Kristensen l...@solumslekt.org wrote: UPDATE sources SET source_text = regexp_replace(source_text, E'n=(.*?)$1(.*?)', E'n=\\1$2\\2', 'g') where source_text like '%n=%$2%%'; Sorry, I pasted a literal replacement, and substituted the parameters by hand. The expression should of

Re: [SQL] Passing function parameters to regexp_replace

2011-09-17 Thread Tim Landscheidt
Leif Biberg Kristensen l...@solumslekt.org wrote: On Saturday 17. September 2011 19.07.03 Tim Landscheidt wrote: Leif Biberg Kristensen l...@solumslekt.org wrote: UPDATE sources SET source_text = regexp_replace(source_text, E'n=(.*?)$1(.*?)', E'n=\\1$2\\2', 'g') where source_text like

Re: [SQL] Add one column to another

2011-08-25 Thread Tim Landscheidt
(anonymous) wrote: I have to deal with a table which contains: first_name surname email1 email2 ... and I would like to create a view which combines both email columns thus: first_name surname email It looks simple but I can't think of an obvious query. Try: | SELECT first_name,

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

2011-08-24 Thread Tim Landscheidt
(anonymous) wrote: [...] I intend pass the number of the month(say 1 for January , 2 for February etc) as the parameter to this method and return a number that corresponds to the index of the month in the new order , say I pass 8 for August , I return 11 , in order to get the index of

Re: [SQL] need magic to shuffle some numbers

2011-08-24 Thread Tim Landscheidt
(anonymous) wrote: there is a table that has among others a integer primary key id and another integer column prio as well as an integer group_id. I'd like to invert the values of the prio-column for one of the groups. The prio numbers start with 3 and there are 1159 different prios in

Re: [SQL] Help with regexp-query

2011-08-02 Thread Tim Landscheidt
Johann Spies jsp...@sun.ac.za wrote: I am struggling a bit to do the following type of update in a table. I want the content of a field updated like this: Original: '0894396e-16bf-4e63-aa52-97fe7031eec9||50a6b47c-f69c-414d-bcb6-14bbe403de5f|||' After update:

Re: [SQL] How to remove a set of characters in text-columns ?

2011-06-30 Thread Tim Landscheidt
(anonymous) wrote: how can I remove a set of characters in text-columns ? Say I'd like to remove { } ( ) ' , ; . : ! Of course I can chain replace ( replace ( replace ( replace ( ... , '' ) and replace the chars one by one against an empty string ''. There might be a more elegant

Re: [SQL] Duplicates Processing

2010-10-08 Thread Tim Landscheidt
Gary Chambers gwch...@gmail.com wrote: I've been provided a CSV file of parts that contains duplicates of properties (e.g. resistors have a wattage, tolerance, and temperature coefficient property) of those parts that differ by a manufacturer part number. What I'd like to do is to process

Re: [SQL] grouping subsets

2010-07-22 Thread Tim Landscheidt
Richard Huxton d...@archonet.com wrote: What I want to get is the values grouped by subset, where a subset is a set of rows with identical column until the colum changes. Is there a way to get | 2 | B | | 4 | C | | 4 | B | | 3 | D | by SQL only? I think, the problem is that there are

Re: [SQL] grouping subsets

2010-07-22 Thread Tim Landscheidt
Rainer Stengele rainer.steng...@diplan.de wrote: yes, the date is always incremented - but anyway the date column is not really the point! Actually the first tow columns are relevant. I want them gouped together as indicated, adding up column 1 in the blocks with identical second column, but

Re: [SQL] Aggregates (last/first) not behaving

2010-07-22 Thread Tim Landscheidt
Wes Devauld w...@devauld.ca wrote: I believe I lost the flavour of what I'm doing when I constructed this example. I'm not interested in the timepoint as much as the value that is attached to it. I need to be able to find the last chronological record for a given day. I can get the value

Re: [SQL] How to find events within a timespan to each other?

2010-07-07 Thread Tim Landscheidt
(anonymous) wrote: is there a way to find events in a log that happen within a certain timespan to each other? Log is like this event_idinteger not null default 0 primary key event_type_idinteger not null default user_idinteger not null default 0

Re: [SQL] How to select text field as interger

2010-06-29 Thread Tim Landscheidt
Jerrel Kemper jer...@s-wise.nl wrote: My table consist off the following fields CREATE TABLE test ( id bigserial NOT NULL, name character varying(100), CONSTRAINT logs_pkey PRIMARY KEY (log_id) ) with value : IDName 1 001 201 3 1 411

Re: [SQL] enforcing constraints across multiple tables

2010-06-25 Thread Tim Landscheidt
Andrew Geery andrew.ge...@gmail.com wrote: [...] My questions are: (A) Is there a way to check (2) above using a constraint and not a trigger? (B) Is there an easier way to solve this problem? Does the complicated nature of the solution make the design poor? (C) Should I not worry about

Re: [SQL] error on line 1 trying to execute a script using psql

2010-06-21 Thread Tim Landscheidt
Steven Dahlin pgdb.sldah...@gmail.com wrote: I am attempting to generate a temporary function to execute some dml with the following script: create or replace function setuplicense() returns integer as $$ declare hwcustid integer := 0; retvalinteger := 0; begin insert into

Re: [SQL] what does this do

2010-06-10 Thread Tim Landscheidt
John jo...@jfcomputer.com wrote: I have a piece of python code that excutes a SQL statement: apitempCur.execute(select * from jfcs_balancedue('%s') f(enrolleeid varchar, course_cost decimal, paid_amt decimal) % (enrollIds,)); The enrollids is a list of primary keys and the jfcs_balancedue

Re: [SQL] what does this do

2010-06-10 Thread Tim Landscheidt
Richard Broersma richard.broer...@gmail.com wrote: I have a piece of python code that excutes a SQL statement: apitempCur.execute(select * from jfcs_balancedue('%s') f(enrolleeid varchar, course_cost decimal, paid_amt decimal) % (enrollIds,)); The enrollids is a list of primary keys and

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

2010-05-29 Thread Tim Landscheidt
Jasen Betts ja...@xnet.co.nz 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 POSIX to Perl? perhaps you can do something in pl-perl? posix

Re: [SQL] inner join and limit

2010-05-26 Thread Tim Landscheidt
Michele Petrazzo - Unipex michele.petra...@unipex.it wrote: I have two table that are so represented: t1: id int primary key ... other t2: id int primary key t1id int fk(t1.id) somedate date ... other data t1: 1 | abcde 2 | fghi data t2: 1 | 1 | 2010-05-23 2 | 1 | 2010-05-24 3

Re: [SQL] safely exchanging primary keys?

2010-05-24 Thread Tim Landscheidt
Louis-David Mitterrand vindex+lists-pgsql-...@apartia.org wrote: I have this function which swaps primary keys for cabin_types (so that id_cabin_type ordering reflects natural data ordering): CREATE OR REPLACE FUNCTION swap_cabin_types(id1 integer, id2 integer) RETURNS integer

Re: [SQL] safely exchanging primary keys?

2010-05-24 Thread Tim Landscheidt
Louis-David Mitterrand vindex+lists-pgsql-...@apartia.org wrote: you use something simple like (untested): | UPDATE cabin_type | SET id_cabin_type = | CASE | WHEN id_cabin_type = id1 THEN | id2 | ELSE | id1 | END | WHERE id_cabin_type

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

2010-05-19 Thread Tim Landscheidt
Brian Modra br...@zwartberg.com wrote: It works using 'now' and I assume that since curtime is of type DATE that the assignment casts the return automatically to type DATE. Thank you for the ideas. [...] What's wrong with Pavel's correct and to-the-point answer? No need actually to

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

2010-05-18 Thread Tim Landscheidt
Kenneth Marshall k...@rice.edu wrote: It works using 'now' and I assume that since curtime is of type DATE that the assignment casts the return automatically to type DATE. Thank you for the ideas. [...] What's wrong with Pavel's correct and to-the-point answer? Tim -- Sent via pgsql-sql

Re: [SQL] import ignoring duplicates

2010-05-16 Thread Tim Landscheidt
Mark Fenbers mark.fenb...@noaa.gov wrote: I am using psql's \copy command to add records to a database from a file. The file has over 100,000 lines. Occasionally, there is a duplicate, and the import ceases and an internal rollback is performed. In other words, no data is imported even if

Re: [SQL] regexp_replace and search/replace values stored in table

2010-04-27 Thread Tim Landscheidt
Leif Biberg Kristensen l...@solumslekt.org wrote: [...] So far, so good. But when I try to do the actual expansion, I'm stumped. pgslekt= select regexp_replace((select source_text from sources where source_id=23091), (select quote_literal(short_link) from short_links where link_type =

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

2010-04-20 Thread Tim Landscheidt
Feixiong Li feixion...@gmail.com wrote: I am newbie for sql, I have a problem when using max() function, I need get null when there are null in the value list, or return the largest value as usual, who can do this? i.e. max([1,2,3,4,5]) = 5 max([1,2,3,4,5,null]) = null You can cheat a

Re: [SQL] UNION or LEFT JOIN?

2010-02-16 Thread Tim Landscheidt
Louis-David Mitterrand vindex+lists-pgsql-...@apartia.org wrote: Here is the basic schema: --id_ship--- || [SHIP]-id_ship-[CABIN]-id_cabin-[PRICE]-id_cruise-[CRUISE] It's a database of

Re: [SQL] Can i force deletion of dependent rows?

2010-02-13 Thread Tim Landscheidt
Shruthi A shruthi.i...@gmail.com wrote: Thanks people, but the trigger doesnt really solve my problem. You see, there is actually a CHAIN of dependencies where B references A, C references B, D and E reference C and so on... So if i start writing triggers for all these, there'll be a huge

Re: [SQL] complex join question

2010-02-12 Thread Tim Landscheidt
Louis-David Mitterrand vindex+lists-pgsql-...@apartia.org wrote: Here is my schema: cruise_line - ship(id_line) - cruise_type(id_ship) - cruise(id_cruise_type) - price(id_cruise, id_currency) - currency (USD,GBP,EUR,CAD) (a 'cruise' is a 'cruise_type' + a date) I am trying to

Re: [SQL] Can i force deletion of dependent rows?

2010-02-12 Thread Tim Landscheidt
Shruthi A shruthi.i...@gmail.com wrote: I have 2 tables (A and B) where the table B has a foreign key reference to table A. Like this: create table A (x int primary key); create table B (y int primary key, z int references A (x) ); As you can see, i've not specified any further 'on

Re: [SQL] loading a file into a field

2009-12-31 Thread Tim Landscheidt
Brian Sherwood bds...@gmail.com wrote: I am looking to play around with the postgres XML functions, but can't seem to find a way to load my data. I have a number of XML files: file1.xml, file2.xml, etc All files follow the same xml format (DTD?) I would like to create the following

Re: [SQL] Proper case function

2009-12-31 Thread Tim Landscheidt
Michael Gould mgo...@intermodalsoftwaresolutions.net wrote: 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

Re: [SQL] Lag and lead window functions order by weirdness

2009-10-18 Thread Tim Landscheidt
Thom Brown thombr...@gmail.com wrote: [...] Having a look around, it looks as if Postgres might be misbehaving. According to this page, http://my.safaribooksonline.com/0596004818/sqlnut2-CHP-4-SECT-3, the ORDER BY in the window function's clause shouldn't be having this ordering effect:

Re: [SQL] FW: simple? query

2009-08-18 Thread Tim Landscheidt
Jan Verheyden jan.verhey...@uz.kuleuven.ac.be wrote: Thanks for the suggestion, the only problem is, if primary key is used then each row should be unique what is not true; since I have a column 'registered' what only can be 1 or 0... [...] I have no idea what you are trying to say. Tim

Re: [SQL] simple? query

2009-08-14 Thread Tim Landscheidt
Relyea, Mike mike.rel...@xerox.com wrote: The goal is, where uid not equals to 'janvleuven10' a new record should be inserted with the uid, and registered=0 So if a record is found you want to update it and if a record isn't found you want to insert it. I think you'll probably want to use

Re: [SQL] mail alert

2009-08-13 Thread Tim Landscheidt
Alvaro Herrera alvhe...@commandprompt.com wrote: It's on Windows I'd go with notify and a listener written in C using c-client to send emails, but only because I've used those before. I wouldn't write it in C but rather Perl or Python, but whatever suits your fancy should work (Visual

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

2009-07-30 Thread Tim Landscheidt
(anonymous) wrote: Any ideas on how to achieve this? I would like to let the original sql code stay original. I can prepare postgres before executing the sql if this makes it easier to acheive the goal Have a look at CREATE RULE. Ok, you mean I could create a rule for the table, then I

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

2009-07-28 Thread Tim Landscheidt
(anonymous) 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 similar, change the

[SQL] Comparing a string against an XPath result set

2009-07-16 Thread Tim Landscheidt
Hi, I'm trying to check whether a given string is part of an XPath result set. I have encountered some performance prob- lems in the process, but before I track those down further, I'd like to see if I've chosen the right path to begin with: | SELECT * FROM $TABLE | WHERE $COLUMN =