Should I use CAST?

Поиск
Список
Период
Сортировка
От Campano, Troy
Тема Should I use CAST?
Дата
Msg-id 9534B16F750ED2118CF90008C724C4460C22228B@lmig-msg-20.lmig.com
обсуждение исходный текст
Ответы Re: Should I use CAST?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general

I have two tables that are basically the same.  They have different data types through.  I am trying to load data from one table to another and I get the error:

ERROR:  Attribute 'cert_expiration' is of type 'date' but expression is of type 'varchar'
        You will need to rewrite or cast the expression

So I tried this:

-----------------------------------------------------
INSERT INTO ebs_webserver_t (
install_directory,
server_instance_nme,
docs_directory_nme,
other_info,
port_num,
host_nme,
ip_num,
cert_expiration,
dns_nme,
url_nme,
app_contact_id,
cert_type_id,
domain_id,
node_id, 
environment_id,
sbu_id,
server_type_id
)
SELECT
install_directory,
server_instance_nme,
docs_directory_nme,
other_info,
port_num,
host_nme,
ip_num,
CAST(cert_expiration AS DATE),
dns_nme,
url_nme,
app_contact_nme,
cert_type_id,
domain_id,
node_id,
environment_id,
sbu_id,
server_type_id
FROM ebs_webserver_tmp2;
---------------------------------------------------------

Notice I used CAST in the SELECT.  But I get this error:

ERROR:  Cannot cast type 'varchar' to 'date'


Any ideas what I can do to make a VARCHAR column a date?
All the dates are in this format: 10/23/2002




Thanks!

[:==> Troy Campano <==:]
Database (Request Manager/web/database)
http://intranet:3000/infosys/infra/software/database/dbapp/
http://intranet2/reqman/
Microsoft gave you Windows, UNIX the whole house.

В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Determining current database programmatically
Следующее
От: Doug McNaught
Дата:
Сообщение: Re: Determining current database programmatically