Re: [SQL] Query prepared plan

2008-07-29 Thread Emi Lu


Similar to \dt to show all tables, within one session, may I know the  
command to list all prepared query plan please?


select * from pg_prepared_statements;


Thank you! I think this is the command.

Too bad that I could not use it under 8.0x.
select * from pg_prepared_statements;
ERROR:  relation "pg_prepared_statements" does not exist
fis=> select version();
 version
-
 PostgreSQL 8.0.15 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.2



--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


[SQL] column names with - and (

2008-07-29 Thread maria s
Hi All,
When I am fetching the data from a table,
I am giving the column names with - and ( and ) like IL-a, IL-a(p30) etc..

select x1 as IL-a, x2 as IL-a(p30) from abc

But I am getting

ERROR:  syntax error at or near "-" and also t "(" , ")"

Can anyone help me to fix this?

Thank you,
Maria


Re: [SQL] column names with - and (

2008-07-29 Thread Oliveiros Cristina
Maria,

The minus, open bracket and close bracket are illegal as identifier names 

http://www.postgresql.org/docs/8.3/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

Best,
Oliveiros

  - Original Message - 
  From: maria s 
  To: Osvaldo Rosario Kussama ; pgsql-sql@postgresql.org ; Pavel Stehule ; Ivan 
Sergio Borgonovo 
  Sent: Tuesday, July 29, 2008 5:06 PM
  Subject: [SQL] column names with - and (


  Hi All,
  When I am fetching the data from a table,
  I am giving the column names with - and ( and ) like IL-a, IL-a(p30) etc..

  select x1 as IL-a, x2 as IL-a(p30) from abc

  But I am getting 

  ERROR:  syntax error at or near "-" and also t "(" , ")"

  Can anyone help me to fix this?

  Thank you,
  Maria


Re: [SQL] column names with - and (

2008-07-29 Thread maria s
Hi Oliveiros,
Thanks for the link. Yes I read it.

But I am using "" for the column names. So now I am getting the result that
I need.

Thanks for all your help.

Maria

On Tue, Jul 29, 2008 at 12:27 PM, Oliveiros Cristina <
[EMAIL PROTECTED]> wrote:

>  Maria,
>
> The minus, open bracket and close bracket are illegal as identifier names
>
>
> http://www.postgresql.org/docs/8.3/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
>
> Best,
> Oliveiros
>
>
> - Original Message -
> *From:* maria s <[EMAIL PROTECTED]>
> *To:* Osvaldo Rosario Kussama <[EMAIL PROTECTED]> ;
> pgsql-sql@postgresql.org ; Pavel Stehule <[EMAIL PROTECTED]> ; Ivan
> Sergio Borgonovo <[EMAIL PROTECTED]>
> *Sent:* Tuesday, July 29, 2008 5:06 PM
> *Subject:* [SQL] column names with - and (
>
> Hi All,
> When I am fetching the data from a table,
> I am giving the column names with - and ( and ) like IL-a, IL-a(p30) etc..
>
> select x1 as IL-a, x2 as IL-a(p30) from abc
>
> But I am getting
>
> ERROR:  syntax error at or near "-" and also t "(" , ")"
>
> Can anyone help me to fix this?
>
> Thank you,
> Maria
>
>


Re: [SQL] column names with - and (

2008-07-29 Thread Oliveiros Cristina
You can enclose the names in quotes, then the characters are allowed

Sorry to mislead you :p

Best,
Oliveiros


  - Original Message - 
  From: Oliveiros Cristina 
  To: maria s ; Osvaldo Rosario Kussama ; pgsql-sql@postgresql.org ; Pavel 
Stehule ; Ivan Sergio Borgonovo 
  Sent: Tuesday, July 29, 2008 5:27 PM
  Subject: Re: [SQL] column names with - and (


  Maria,

  The minus, open bracket and close bracket are illegal as identifier names 

  
http://www.postgresql.org/docs/8.3/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

  Best,
  Oliveiros

- Original Message - 
From: maria s 
To: Osvaldo Rosario Kussama ; pgsql-sql@postgresql.org ; Pavel Stehule ; 
Ivan Sergio Borgonovo 
Sent: Tuesday, July 29, 2008 5:06 PM
Subject: [SQL] column names with - and (


Hi All,
When I am fetching the data from a table,
I am giving the column names with - and ( and ) like IL-a, IL-a(p30) etc..

select x1 as IL-a, x2 as IL-a(p30) from abc

But I am getting 

ERROR:  syntax error at or near "-" and also t "(" , ")"

Can anyone help me to fix this?

Thank you,
Maria


Re: [SQL] column names with - and (

2008-07-29 Thread maria s
Its okay, Yes I am using quotes. Michael was telling that too.

Thanks for all the help at all times.

Maria


On Tue, Jul 29, 2008 at 12:37 PM, Oliveiros Cristina <
[EMAIL PROTECTED]> wrote:

>  You can enclose the names in quotes, then the characters are allowed
>
> Sorry to mislead you :p
>
> Best,
> Oliveiros
>
>
>
> - Original Message -
> *From:* Oliveiros Cristina <[EMAIL PROTECTED]>
> *To:* maria s <[EMAIL PROTECTED]> ; Osvaldo Rosario Kussama<[EMAIL 
> PROTECTED]>;
> pgsql-sql@postgresql.org ; Pavel Stehule <[EMAIL PROTECTED]> ; Ivan
> Sergio Borgonovo <[EMAIL PROTECTED]>
> *Sent:* Tuesday, July 29, 2008 5:27 PM
> *Subject:* Re: [SQL] column names with - and (
>
> Maria,
>
> The minus, open bracket and close bracket are illegal as identifier names
>
>
> http://www.postgresql.org/docs/8.3/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
>
> Best,
> Oliveiros
>
>
> - Original Message -
> *From:* maria s <[EMAIL PROTECTED]>
> *To:* Osvaldo Rosario Kussama <[EMAIL PROTECTED]> ;
> pgsql-sql@postgresql.org ; Pavel Stehule <[EMAIL PROTECTED]> ; Ivan
> Sergio Borgonovo <[EMAIL PROTECTED]>
> *Sent:* Tuesday, July 29, 2008 5:06 PM
> *Subject:* [SQL] column names with - and (
>
> Hi All,
> When I am fetching the data from a table,
> I am giving the column names with - and ( and ) like IL-a, IL-a(p30) etc..
>
> select x1 as IL-a, x2 as IL-a(p30) from abc
>
> But I am getting
>
> ERROR:  syntax error at or near "-" and also t "(" , ")"
>
> Can anyone help me to fix this?
>
> Thank you,
> Maria
>
>


[SQL] Identifying which column matches a full text search

2008-07-29 Thread Ryan Wallace
Hi all,

 

The following example is given in the Postgres 8.3 manual regarding how to
create a single ts_vector column for two existing columns:

 

ALTER TABLE pgweb ADD COLUMN textsearchable_index_col tsvector;

UPDATE pgweb SET textsearchable_index_col =

 to_tsvector('english', coalesce(title,'') || coalesce(body,''));

Then we create a GIN index to speed up the search: 

CREATE INDEX textsearch_idx ON pgweb USING gin(textsearchable_index_col);

Now we are ready to perform a fast full text search: 

SELECT title

FROM pgweb

WHERE textsearchable_index_col @@ to_tsquery('create & table')

ORDER BY last_mod_date DESC LIMIT 10;

 

Using this approach. Is there any way of retrieving which of the original
two columns the match was found in?

 

Any help would be much appreciated,

Ryan



Re: [SQL] column names with - and (

2008-07-29 Thread Igor Neyman
Maria,
 
Try "" (double quotes:
 
select x1 as "IL-a", x2 as "IL-a(p30)" from abc
 
should help.
 
Igor

 



From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of maria s
Sent: Tuesday, July 29, 2008 12:07 PM
To: Osvaldo Rosario Kussama; pgsql-sql@postgresql.org; Pavel Stehule;
Ivan Sergio Borgonovo
Subject: [SQL] column names with - and (


Hi All,
When I am fetching the data from a table,
I am giving the column names with - and ( and ) like IL-a, IL-a(p30)
etc..

select x1 as IL-a, x2 as IL-a(p30) from abc

But I am getting 

ERROR:  syntax error at or near "-" and also t "(" , ")"

Can anyone help me to fix this?

Thank you,
Maria



Re: [SQL] Identifying which column matches a full text search

2008-07-29 Thread Richard Huxton

Ryan Wallace wrote:


UPDATE pgweb SET textsearchable_index_col =
 to_tsvector('english', coalesce(title,'') || coalesce(body,''));



WHERE textsearchable_index_col @@ to_tsquery('create & table')



Using this approach. Is there any way of retrieving which of the original
two columns the match was found in?


Afraid not - you're not indexing two columns, you're indexing one: 
textsearchable_index_col.


You can add up to four weights to a tsvector though, typically for 
title/body matching. See chapter 12.3 for details.


Failing that, where I've had many (a dozen) different sources but want 
to search them all I've built a textsearch_blocks table with columns to 
identify the source and have triggers that keep it up to date.


--
  Richard Huxton
  Archonet Ltd

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql