[SQL] algoritme

2002-07-05 Thread stephane

I have a question : I don't know if in a postgres database, it is
interisting to create an index for a time stamp champ, Information :
data are inerted in a chronological order.


thanks Stephane

--
Dubreuil Stephane
[EMAIL PROTECTED]



---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly





[SQL] Boolean to int

2002-07-04 Thread Stephane Schildknecht

Hi, 

I'd like to get 1 or 0 from a select on a boolean field. 

How could I do ?

I tried the following rule, which I can't insert :

CREATE FUNCTION bool_to_int( boolean ) RETURNS integer AS '
DECLARE
my_bool ALIAS FOR $1 ;
BEGIN
-- Retourne 1 si true, 0 si false
IF my_bool IS FALSE THEN 
RETURN 0 ;
ELSIF my_bool IS TRUE THEN
RETURN 1 ;
ELSE RETURN -1 ;
END IF ;
END ;
' LANGUAGE 'plpgsql';

CREATE RULE boolean_return AS ON SELECT TO DOCUMENT DO INSTEAD
SELECT 
document_id,
workflow_id,
type_document_id,
image_id,
theme_id,
document_version,
document_surtitre,
document_titre,
document_chapeau,
document_synthese,
document_corps,
document_pdf,
document_date_creation,
document_mot_clef,
(bool_to_int(document_online)) as document_online,
bool_to_int(document_valid) as document_valid FROM document;


psql:cnambo_proc_stock.sql:69: ERROR:  select rule's target entry 15
 has different type from attribute document_online

Who could help me ?

S@S

-- 
 _Stéphane SCHILDKNECHT___
| AurorA-SAS 69-71, Av. Pierre Grenier 92100 BOULOGNE |
| Tel : 01.58.17.03.20 Fax : 01.58.17.03.21   | 
| mailto:[EMAIL PROTECTED] - ICQ : 142504394 |
| "Free Markets have taught that innovation is best when  | 
|  ideas flow freely." Adam Smith |
|_|




---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly





Re: [SQL] how to use nextval()

2002-07-05 Thread Stephane Schildknecht

Le ven 05/07/2002 à 14:03, [EMAIL PROTECTED] a écrit :
> Hello there
> 
> I have an idea how to solve my problem on copy a record to a new one in the
> same table. To do so I need the next value for the primary key.
> 
> Using :
> 
> select nextval('pk_auftrag') as nextkey from auftrag;
> 
> I get an error like : Relation pk_auftrag does not exist !
> 
> Thanks for any help ... jr
Try to get the right name of the sequence.
By default, something like auftrag_auftrag_id_seq, if auftrag_id is the
serial primary key.

select nextval('auftrag_auftrag_id_seq') as nextkey;

S@S




---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster





Re: [SQL] Boolean to int

2002-07-05 Thread Stephane Schildknecht

Le jeu 04/07/2002 à 23:32, Arjen van der Meijden a écrit :
> How about this hint in the postgresql-manual:
> 
>"Tip:  Values of the boolean type cannot be cast directly to other 
> types (e.g., CAST (boolval AS integer) does not work). This can be 
> accomplished using the CASE expression: CASE WHEN boolval THEN 'value if 
> true' ELSE 'value if false' END. See also Section 4.12. "
> 
> For more information: 
> http://www.postgresql.org/idocs/index.php?datatype-boolean.html
> and
> http://www.postgresql.org/idocs/index.php?functions-conditional.html

I tried that :

CREATE RULE boolean_return AS ON SELECT TO DOCUMENT DO INSTEAD
SELECT
document_id,
workflow_id,
type_document_id,
image_id,
theme_id,
document_version,
document_surtitre,
document_titre,
document_chapeau,
document_synthese,
document_corps,
document_pdf,
document_date_creation,
document_mot_clef,
document_online,
document_valid,
CASE document_online WHEN TRUE THEN 1
 WHEN FALSE THEN 0
END,
CASE document_valid WHEN TRUE THEN 1
WHEN FALSE THEN 0
END 
FROM document;

And, that doesn't work either...

psql:cnambo_proc_stock.sql:76: ERROR:  select rule's target list has too
many entries


> 
-- 
 _Stéphane SCHILDKNECHT___
| AurorA-SAS 69-71, Av. Pierre Grenier 92100 BOULOGNE |
| Tel : 01.58.17.03.20 Fax : 01.58.17.03.21   | 
| mailto:[EMAIL PROTECTED] - ICQ : 142504394 |
| "Free Markets have taught that innovation is best when  | 
|  ideas flow freely." Adam Smith |
|_|




---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html





[SQL] Problem with my query whithout double-quotes

2002-07-24 Thread ROUWEZ Stephane

Hi, 
My pgsql runs on WinNT Server 4. When I try to 
SELECT nom, prenom FROM individu WHERE numero=2 
I have : ERROR: Relation "individu" does not exist 
It only works if I write : 
SELECT "Individu"."Nom","Individu"."Prenom" FROM "Individu" WHERE
"Individu"."NumIndiv"=2 
Can someone help me ? 
Thanks 
Stephane



-- 
http://www.ecolo.be 


---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



Re: [SQL] Change size of a field

2002-08-02 Thread ROUWEZ Stephane

Hi,

Thank you, it works but I loose my foreign keys and the privileges for
groups and users. 

Is there a solution ?

Stef


-Message d'origine-
De : Achilleus Mantzios [mailto:[EMAIL PROTECTED]]
Envoye : vendredi 26 juillet 2002 14:50
A : ROUWEZ Stephane
Cc : '[EMAIL PROTECTED]'; LESNE Philippe
Objet : Re: [SQL] Change size of a field


On Fri, 26 Jul 2002, ROUWEZ Stephane wrote:

> Hi,
> 
> Is it possible to change the size of a field ?
> Actually, I have a field called 'nom' in varchar(50) and I want this field
> in varchar(80). 
> I can't do it with PgAdmin. Is it normal ?

Pretty normal!
just 
1) % pg_dump -t   > -DUMP.sql
2) % psql
   # drop sequence _id_seq;
3) vi -DUMP.sql
   change your varchar(50) to varchar(80)
4) psql
   #\i -DUMP.sql

There you go

> 
> Tanks
> 
> 
> -- 
> http://www.ecolo.be 
> 
> 
> ---(end of broadcast)---
> TIP 6: Have you searched our list archives?
> 
> http://archives.postgresql.org
> 

-- 
Achilleus Mantzios
S/W Engineer
IT dept
Dynacom Tankers Mngmt
Nikis 4, Glyfada
Athens 16610
Greece
tel:+30-10-8981112
fax:+30-10-8981877
email:  [EMAIL PROTECTED]
[EMAIL PROTECTED]


-- 
http://www.ecolo.be 


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html



[SQL] Re: How to Insert and retrieve multilingual (Hindi "an Indian language") into PostgreSQL

2010-06-25 Thread Stephane Bortzmeyer
On Tue, Jun 22, 2010 at 04:18:48PM +0530,
 venkat  wrote 
 a message of 39 lines which said:

> I want to insert and retrieve multilingual (Hindi) into database.is
> PostgreSQL supports that ?

[Currently, I'm storing arabic texts in a PostgreSQL database.
]

Actually, PostgreSQL does not know about languages (except for
services like full-text search): it stores text, period. For a long
time, PostgreSQL was able to store texts in various encodings. The
recommended one is UTF-8, which allows you to store the whole Unicode
character set.

% createdb --encoding=UTF-8 venkat

% psql venkat
venkat=> CREATE TABLE Misc (id SERIAL, content TEXT);
NOTICE:  CREATE TABLE will create implicit sequence "misc_id_seq" for serial 
column "misc.id"
CREATE TABLE
venkat=> INSERT INTO Misc (content) VALUES ('Texte en français');
INSERT 0 1


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