Re: [SQL] SQL stored function inserting and returning data in a row.

2008-01-14 Thread Marc Mamin
What about $$ INSERT INTO ; select currval('seq_matchmaking_session_id'); $$ language sql; ? Hello, I'm not sure that this would return the correct id in case of concurrent calls to your function. I'm using following kind of function to manage reference tables: HTH, Marc Mamin

Re: [SQL] SQL question: Highest column value of unique column pairs

2008-01-14 Thread Marc Mamin
Hello Kevin, I would use select distinct on to first isolate the candidates in (1) and (2) and then reitere the query on this sub result: (the query below will retrieve the last score, not the best one...) something like (not tested): select distinct on (date,name) date,name,score from

Re: [SQL] trigger for TRUNCATE?

2008-01-14 Thread Peter Childs
On 11/01/2008, Simon Riggs [EMAIL PROTECTED] wrote: On Fri, 2008-01-11 at 08:24 +, Richard Huxton wrote: I've always considered TRUNCATE to be DDL rather than DML. I mentally group it with DROP TABLE rather than DELETE DDL/DML probably isn't the right split, since its then arguable as

[SQL] Unescaping text or binary file

2008-01-14 Thread RDyes
IN your sql statements you use e to escape data going into a binary, or text field. How do you unescape this same data? Richmond H. Dyes Monroe Community Hospital 760-6213

[SQL] table column names - search

2008-01-14 Thread Marcin Krawczyk
Hi all. I would like to know if there's a way to obtain a list of tables containing specified column name? Using standard LIKE '%string' syntax would be great. Regards, mk

Re: [SQL] table column names - search

2008-01-14 Thread Peter Eisentraut
Am Montag, 14. Januar 2008 schrieb Marcin Krawczyk: Hi all. I would like to know if there's a way to obtain a list of tables containing specified column name? Using standard LIKE '%string' syntax would be great. SELECT table_schema, table_name FROM information_schema.columns WHERE column_name

Re: [SQL] UTF8 encoding and non-text data types

2008-01-14 Thread Medi Montaseri
Thanks Steve, Actually I do not insert text data into my numeric field. As I mentioned given create table t1 { name text, cost decimal } then I would like to insert numeric data into column cost because then I can later benefit from numerical operators like SUM, AVG, etc More specifically, I am

Re: [SQL] table column names - search

2008-01-14 Thread Marcin Krawczyk
Thanks a lot. 2008/1/14, Peter Eisentraut [EMAIL PROTECTED]: Am Montag, 14. Januar 2008 schrieb Marcin Krawczyk: Hi all. I would like to know if there's a way to obtain a list of tables containing specified column name? Using standard LIKE '%string' syntax would be great. SELECT

Re: [SQL] UTF8 encoding and non-text data types

2008-01-14 Thread Tom Lane
Medi Montaseri [EMAIL PROTECTED] writes: More specifically, I am using HTML, Perl and PG. So from the HTML point of view a textfield is just some strings. So my user would enter 12345 but expressed in UTF8. Perl would get this and use DBI to insert it into PG What I am experiencing now is

Re: [SQL] UTF8 encoding and non-text data types

2008-01-14 Thread dmp
Hi Steve, Have you tried converting to a decimal type or cast for the cost field? If you are gathering this data from a text field and placing in a variable of type string then using that variable in the insert statement it may be rejected because it is not type decimal. This has been my

Re: [SQL] UTF8 encoding and non-text data types

2008-01-14 Thread dmp
Sorry this should have been addressed to Medi dana. Hi Steve, Have you tried converting to a decimal type or cast for the cost field? If you are gathering this data from a text field and placing in a variable of type string then using that variable in the insert statement it may be rejected

Re: [SQL] UTF8 encoding and non-text data types

2008-01-14 Thread Steve Midgley
On Jan 13, 2008 8:51 PM, Steve Midgley mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote: At 02:22 PM 1/13/2008, mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote: Date: Sat, 12 Jan 2008 14:21:00 -0800 From: Medi Montaseri mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] To:

Re: [SQL] UTF8 encoding and non-text data types

2008-01-14 Thread Medi Montaseri
Here is my traces from perl CGI code, I'll include two samples one in ASCII and one UTF so we know what to expect Here is actual SQL statement being executed in Perl and DBI. I do not quote the numerical value, just provided to DBI raw. insert into t1 (c1, cost) values ('tewt', 1234) this works

Re: [SQL] UTF8 encoding and non-text data types

2008-01-14 Thread Steve Midgley
At 12:43 PM 1/14/2008, Medi Montaseri wrote: Here is my traces from perl CGI code, I'll include two samples one in ASCII and one UTF so we know what to expect Here is actual SQL statement being executed in Perl and DBI. I do not quote the numerical value, just provided to DBI raw. insert

Re: [SQL] UTF8 encoding and non-text data types

2008-01-14 Thread Tom Lane
Medi Montaseri [EMAIL PROTECTED] writes: insert into t1 (c1, cost) values ('tewt', 1234) this works find insert into t1 (c1, cost) values ('#1588;#1583;', #1777;#1778;#1779;#1780;) DBD::Pg::db do failed: ERROR: syntax error at or near ; at character 59, Well, you've got two problems

Re: [SQL] UTF8 encoding and non-text data types

2008-01-14 Thread Tom Lane
Joe [EMAIL PROTECTED] writes: Tom Lane wrote: Well, you've got two problems there. The first and biggest is that #NNN; is an HTML notation, not a SQL notation; no SQL database is going to think that that string in its input is a representation of a single Unicode character. The other

Re: [SQL] UTF8 encoding and non-text data types

2008-01-14 Thread Joe
Tom Lane wrote: Medi Montaseri [EMAIL PROTECTED] writes: insert into t1 (c1, cost) values ('tewt', 1234) this works find insert into t1 (c1, cost) values ('#1588;#1583;', #1777;#1778;#1779;#1780;) DBD::Pg::db do failed: ERROR: syntax error at or near ; at character 59, Well,

Re: [SQL] UTF8 encoding and non-text data types

2008-01-14 Thread Joe
Tom Lane wrote: Oh? Interesting. But even if we wanted to teach Postgres about that, wouldn't there be a pretty strong risk of getting confused by Arabic's right-to-left writing direction? Wouldn't be real helpful if the entry came out as 4321 when the user wanted 1234. Definitely seems like