gpt4 book ai didi

java - 复合类型Postgres的GetString?

转载 作者:行者123 更新时间:2023-11-29 12:23:58 24 4
gpt4 key购买 nike

我创建了这个表:

CREATE TABLE public.luogo
(
id_luogo integer NOT NULL DEFAULT nextval('luogo_id_luogo_seq'::regclass),
tipo character varying(30) NOT NULL,
indirizzo indirizzo,
CONSTRAINT luogo_pk PRIMARY KEY (id_luogo)
)

indirizzo 类型在哪里

CREATE TYPE public.indirizzo AS
(
citta character varying(50),
via character varying(50),
cap integer,
civico integer
);

所以我正在使用 JDBC 并且我需要这个查询

"SELECT * FROM luogo WHERE id_luogo= '"+variable+"'";

问题是 resultset.getstring("indirizzo") 显然会返回一个字符串,例如:“(value,value,value)”。如何将 indirizzo 的奇异参数作为字符串获取?

最佳答案

正确的 SQL 语法是:

"SELECT id_luogo,(indirizzo).citta FROM luogo"

在Java中获取String是:resultset.getString("citta")

关于java - 复合类型Postgres的GetString?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51789999/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com