On Thu, 31 Jul 2003, [big5] Eric Tan wrote:
> The command only work in command prompt - putty":
> ALTER DATABASE "CA_care" SET client_enconding TO 'big5';
>
> But it fail when inserting from jsp & VB.
> I have to run this code in all program which may access database.
> pgsql.execute("set client_encoding to 'Big5';");
>
> Any other solution?
The idea is that you run the ALTER DATABASE command once and then every
time you connect it will already be set, so you do not need to make that
call in your client. Notice the second time I connect the client_encoding
is already set.
jurka@doug:~$ psql tantest
Welcome to psql 7.3.3, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit
tantest=# show client_encoding;
client_encoding
-----------------
SQL_ASCII
(1 row)
tantest=# alter database tantest set client_encoding to big5;
ALTER DATABASE
tantest=# \q
jurka@doug:~$ psql tantest
Welcome to psql 7.3.3, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit
tantest=# show client_encoding;
client_encoding
-----------------
big5
(1 row)
To check if you have correctly run the ALTER DATABASE statement, check
SELECT datconfig FROM pg_database WHERE datname='<dbname>';
You should see
tantest=# select datconfig FROM pg_database where datname='tantest';
datconfig
------------------------
{client_encoding=big5}
(1 row)
Kris Jurka