我想知道是否有某种方法可以立即将数据结构读取/更新到PostgreSQL表中,就像文件一样。
Public Structure myStuct
Dim p_id As Integer
Dim p_myInt As Integer
Dim p_myString As String
Dim p_myDecNumber As Double
End Structure
Dim st as myStruct
FileGet (ff, recordnum, st)
OR
st.p_id = 1234
st.myInt = 14
st.myString = "tarzan"
st.myDecNumber = 3.14
FilePut (ff, recordnum, st)
问题是,如果我们有形成数据的表格,类似于结构“st”的成员,则无法在表格中的某个索引处插入/更新整个结构,而不是单独写入每个成员 - 像我现在一样?
答案 0 :(得分:1)
您是否尝试过postgresql复合类型? E.g。
CREATE TYPE myStruct AS (
p_Id integer,
myInt integer,
myString text,
myDecNumber double precision
);
CREATE TABLE myStructs (
value myStruct
);
INSERT INTO myStructs VALUES ( ROW(1234, 14, 'tarzan', 3.14) );
http://www.postgresql.org/docs/9.2/static/rowtypes.html#AEN7268