Formatting psql output

Started by Mark Morgan Lloydover 23 years ago16 messagesgeneral
Jump to latest
#1Mark Morgan Lloyd
markMLl.pgsql-general@telemetry.co.uk

I'm sure I'm missing something obvious here, but how can I tell either
the server or psql to limit the number of digits presented in a set of
results? Is there a facility somewhere for applying something like a
printf format string?

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or
colleagues]

#2Florian Litot
flitot@besancon.sema.slb.com
In reply to: Mark Morgan Lloyd (#1)
i have got an error

DEBUG: recycled transaction log file 0000000000000018
DEBUG: ServerLoop: select failed: Permission denied
PGSTATBUFF: select(2)Permission denied
: Permission denied

i have got this
why i have got this error?

#3Savita
savita@india.hp.com
In reply to: Florian Litot (#2)
How to cast as numeric

Hi ,

I would like to know how to cast as numeric.For examlple

I can use cast as

cast(to_number(substring(os_crm_exchange_call_id, 4), 999999999999) as
smallint)

but here I will have the restriction of the field so If I want to cast it as
numeric how
do I do that.
--
Best Regards
- Savita
----------------------------------------------------
Hewlett Packard (India)
+91 80 2051288 (Phone)
847 1288 (HP Telnet)
----------------------------------------------------
#4Bruce Momjian
bruce@momjian.us
In reply to: Mark Morgan Lloyd (#1)
Re: Formatting psql output

markMLl.pgsql-general@telemetry.co.uk wrote:

I'm sure I'm missing something obvious here, but how can I tell either
the server or psql to limit the number of digits presented in a set of
results? Is there a facility somewhere for applying something like a
printf format string?

We will implement that in 7.4. Not done yet.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#4)
Re: Formatting psql output

Bruce Momjian <pgman@candle.pha.pa.us> writes:

markMLl.pgsql-general@telemetry.co.uk wrote:

I'm sure I'm missing something obvious here, but how can I tell either
the server or psql to limit the number of digits presented in a set of
results? Is there a facility somewhere for applying something like a
printf format string?

We will implement that in 7.4. Not done yet.

There's always to_char() ...

regards, tom lane

#6Mark Morgan Lloyd
markMLl.pgsql-general@telemetry.co.uk
In reply to: Bruce Momjian (#4)
Re: Formatting psql output

Thanks everybody. It's not urgent (the normal apps are doing their own
thing and I only use psql for maintenance) so for heavens sake /don't/
let it detract from the effort going into replication <grin>.

Tom Lane wrote:

Bruce Momjian <pgman@candle.pha.pa.us> writes:

markMLl.pgsql-general@telemetry.co.uk wrote:

I'm sure I'm missing something obvious here, but how can I tell either
the server or psql to limit the number of digits presented in a set of
results? Is there a facility somewhere for applying something like a
printf format string?

We will implement that in 7.4. Not done yet.

There's always to_char() ...

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or
colleagues]

#7Bruno Wolff III
bruno@wolff.to
In reply to: Mark Morgan Lloyd (#1)
Re: Formatting psql output

On Wed, Nov 06, 2002 at 10:47:59 +0000,
markMLl.pgsql-general@telemetry.co.uk wrote:

I'm sure I'm missing something obvious here, but how can I tell either
the server or psql to limit the number of digits presented in a set of
results? Is there a facility somewhere for applying something like a
printf format string?

The to_char function can do this.

#8Bruno Wolff III
bruno@wolff.to
In reply to: Savita (#3)
Re: How to cast as numeric

On Wed, Nov 06, 2002 at 18:21:08 +0530,
Savita <savita@india.hp.com> wrote:

Hi ,

I would like to know how to cast as numeric.For examlple

I can use cast as

cast(to_number(substring(os_crm_exchange_call_id, 4), 999999999999) as
smallint)

::numeric

numeric has 2 option paramters that allow you to limit the precision
and specify a scale. The default is to not limit precision.

#9scott.marlowe
scott.marlowe@ihs.com
In reply to: Florian Litot (#2)
Re: i have got an error

On Wed, 6 Nov 2002, Florian Litot wrote:

DEBUG: recycled transaction log file 0000000000000018
DEBUG: ServerLoop: select failed: Permission denied
PGSTATBUFF: select(2)Permission denied
: Permission denied

It sounds like the ownership of the files is wrong. Do the files in
$PGDATGA/pg_xlog belong to the postgres super user? Does the directory?

#10Mark Wilson
mark@mediasculpt.com
In reply to: scott.marlowe (#9)
replace text function

Hi all,

I'm trying to find a function that will replace one word with another in a
string.

e.g. select <replace function>('bob was here, bobina wasnt', 'bob', 'mike');
will return "mike was here, mikeina wasnt"

Is there such a function already written in PostGreSQL?

Thanks in advance,
Mark

#11Joe Conway
mail@joeconway.com
In reply to: scott.marlowe (#9)
Re: replace text function

Mark Wilson wrote:

Hi all,

I'm trying to find a function that will replace one word with another in a
string.

e.g. select <replace function>('bob was here, bobina wasnt', 'bob', 'mike');
will return "mike was here, mikeina wasnt"

Is there such a function already written in PostGreSQL?

It is new in 7.3 (currently in beta). See the function called "replace" at:
http://developer.postgresql.org/docs/postgres/functions-string.html

test=# select replace('bob was here, bobina wasnt', 'bob', 'mike');
replace
------------------------------
mike was here, mikeina wasnt
(1 row)

HTH,

Joe

#12Darren Ferguson
darren@crystalballinc.com
In reply to: Mark Wilson (#10)
Re: replace text function

There is a function called TRANSLATE

This will do the trick

HTH

On Thu, 7 Nov 2002, Mark Wilson wrote:

Hi all,

I'm trying to find a function that will replace one word with another in a
string.

e.g. select <replace function>('bob was here, bobina wasnt', 'bob', 'mike');
will return "mike was here, mikeina wasnt"

Is there such a function already written in PostGreSQL?

Thanks in advance,
Mark

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

--
Darren Ferguson

#13Mike Mascari
mascarm@mascari.com
In reply to: Darren Ferguson (#12)
Re: replace text function

Darren Ferguson wrote:

There is a function called TRANSLATE

This will do the trick

HTH

TRANSLATE performs a character-by-character replacement. You
cannot use TRANSLATE to substitute words or phrases. Example:

SELECT TRANSLATE('mikei', 'ike', '*8p');

m*8p*

all i's->*
all k's->8
all e's->p

You must either write your own replace(), or use the one
included in 7.3 as Joe Conway mentioned.

Mike Mascari
mascarm@mascari.com

Show quoted text

On Thu, 7 Nov 2002, Mark Wilson wrote:

Hi all,

I'm trying to find a function that will replace one word with another in a
string.

e.g. select <replace function>('bob was here, bobina wasnt', 'bob', 'mike');
will return "mike was here, mikeina wasnt"

Is there such a function already written in PostGreSQL?

#14Mark Wilson
mark@mediasculpt.com
In reply to: scott.marlowe (#9)
Re: replace text function

Must be a slow posting day today :~)

Thanks everyone. I'm running PostGreSQL 7.2.1 and have run in the replace
function that numerous people sent me. It works exactly as I would expect
it to.

Cheers,
Mark

----- Original Message -----
From: "Joe Conway" <mail@joeconway.com>
To: "Mark Wilson" <mark@mediasculpt.com>
Cc: <pgsql-general@postgresql.org>
Sent: Thursday, November 07, 2002 11:51 AM
Subject: Re: [GENERAL] replace text function

Mark Wilson wrote:

Hi all,

I'm trying to find a function that will replace one word with another in

a

string.

e.g. select <replace function>('bob was here, bobina wasnt', 'bob',

'mike');

will return "mike was here, mikeina wasnt"

Is there such a function already written in PostGreSQL?

It is new in 7.3 (currently in beta). See the function called "replace"

at:

Show quoted text

http://developer.postgresql.org/docs/postgres/functions-string.html

test=# select replace('bob was here, bobina wasnt', 'bob', 'mike');
replace
------------------------------
mike was here, mikeina wasnt
(1 row)

HTH,

Joe

#15Florian Litot
flitot@besancon.sema.slb.com
In reply to: scott.marlowe (#9)
trace

how i can configure postgre to ahve the maximum of trace?

#16Lee Kindness
lkindness@csl.co.uk
In reply to: Mark Wilson (#14)
Re: replace text function

I know you're sorted with a solution, but the responses must have been
off-list. For the record, and to point others to useful additional
functionality the PostgreSQL Cookbook is always useful and has a
REPLACE function:

http://www.brasileiro.net/postgres/cookbook/
http://www.brasileiro.net:8080/postgres/cookbook/view-one-recipe.adp?recipe_id=8886

Lee.

Mark Wilson writes:

Show quoted text

Must be a slow posting day today :~)

Thanks everyone. I'm running PostGreSQL 7.2.1 and have run in the replace
function that numerous people sent me. It works exactly as I would expect
it to.

Mark Wilson wrote:

Hi all,

I'm trying to find a function that will replace one word with another in

a

string.

e.g. select <replace function>('bob was here, bobina wasnt', 'bob',

'mike');

will return "mike was here, mikeina wasnt"

Is there such a function already written in PostGreSQL?