Inserting data in composite types! - Mailing list pgsql-sql
From | Rodrigo Sakai |
---|---|
Subject | Inserting data in composite types! |
Date | |
Msg-id | 00fc01c70720$7364c400$4700a8c0@TREEZANTHUS Whole thread Raw |
Responses |
Re: Inserting data in composite types!
Re: Inserting data in composite types! Re: Inserting data in composite types! |
List | pgsql-sql |
<div class="Section1"><p class="MsoNormal"><font face="Arial" size="2"><span lang="EN-US" style="font-size: 10.0pt;font-family:Arial"> Hi, I have a question about how to insert data in composite types!</span></font><p class="MsoNormal"><fontface="Arial" size="2"><span lang="EN-US" style="font-size: 10.0pt;font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span lang="EN-US" style="font-size: 10.0pt;font-family:Arial"> Imagine the exemple:</span></font><p class="MsoNormal"><font face="Arial" size="2"><span lang="EN-US"style="font-size: 10.0pt;font-family:Arial"> </span></font><p class="MsoNormal"><b><font face="Arial" size="2"><span lang="EN-US" style="font-size:10.0pt;font-family:Arial;font-weight:bold">CREATETYPE t_time AS (</span></font></b><p class="MsoNormal"><b><fontface="Arial" size="2"><span lang="EN-US" style="font-size:10.0pt;font-family:Arial;font-weight:bold"> a date,</span></font></b><p class="MsoNormal"><b><font face="Arial"size="2"><span lang="EN-US" style="font-size:10.0pt;font-family:Arial;font-weight:bold"> b date</span></font></b><pclass="MsoNormal"><b><font face="Arial" size="2"><span lang="EN-US" style="font-size:10.0pt;font-family:Arial;font-weight:bold">);</span></font></b><pclass="MsoNormal"><font face="Arial" size="2"><spanlang="EN-US" style="font-size: 10.0pt;font-family:Arial"> </span></font><p class="MsoNormal"><b><font face="Arial" size="2"><span lang="EN-US" style="font-size:10.0pt;font-family:Arial;font-weight:bold">CREATETABLE salary (</span></font></b><p class="MsoNormal"><b><fontface="Arial" size="2"><span lang="EN-US" style="font-size:10.0pt;font-family:Arial;font-weight:bold"> salary numeric(10,2),</span></font></b><p class="MsoNormal"><b><fontface="Arial" size="2"><span lang="EN-US" style="font-size:10.0pt;font-family:Arial;font-weight:bold"> t_date t_time</span></font></b><p class="MsoNormal"><b><fontface="Arial" size="2"><span lang="EN-US" style="font-size:10.0pt;font-family:Arial;font-weight:bold">);</span></font></b><pclass="MsoNormal"><font face="Arial" size="2"><spanlang="EN-US" style="font-size: 10.0pt;font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span lang="EN-US" style="font-size: 10.0pt;font-family:Arial">I know that if I want to insert data in the table SALARY I just have to do like:</span></font><pclass="MsoNormal"><font face="Arial" size="2"><span lang="EN-US" style="font-size: 10.0pt;font-family:Arial"> </span></font><p class="MsoNormal"><b><font face="Arial" size="2"><span lang="EN-US" style="font-size:10.0pt;font-family:Arial;font-weight:bold"> INSERT INTO salary VALUES (1000.00, ‘(2006/10/10, 2006/12/10)’);</span></font></b><pclass="MsoNormal"><font face="Arial" size="2"><span lang="EN-US" style="font-size: 10.0pt;font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span lang="EN-US" style="font-size: 10.0pt;font-family:Arial">But if I have another table:</span></font><p class="MsoNormal"><font face="Arial" size="2"><spanlang="EN-US" style="font-size: 10.0pt;font-family:Arial"> </span></font><p class="MsoNormal"><b><font face="Arial" size="2"><span lang="EN-US" style="font-size:10.0pt;font-family:Arial;font-weight:bold">CREATETABLE employee (</span></font></b><p class="MsoNormal"><b><fontface="Arial" size="2"><span lang="EN-US" style="font-size:10.0pt;font-family:Arial;font-weight:bold"> employee_id int,</span></font></b><p class="MsoNormal"><b><fontface="Arial" size="2"><span lang="EN-US" style="font-size:10.0pt;font-family:Arial;font-weight:bold"> name varchar(30),</span></font></b><p class="MsoNormal"><b><fontface="Arial" size="2"><span lang="EN-US" style="font-size:10.0pt;font-family:Arial;font-weight:bold"> emp_salary salary</span></font></b><p class="MsoNormal"><b><fontface="Arial" size="2"><span lang="EN-US" style="font-size:10.0pt;font-family:Arial;font-weight:bold">)</span></font></b><pclass="MsoNormal"><font face="Arial" size="2"><spanlang="EN-US" style="font-size: 10.0pt;font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span lang="EN-US" style="font-size: 10.0pt;font-family:Arial">How can I insert a single row in this table???</span></font><p class="MsoNormal"><font face="Arial"size="2"><span lang="EN-US" style="font-size: 10.0pt;font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span lang="EN-US" style="font-size: 10.0pt;font-family:Arial">Thanks in advamce!</span></font><p class="MsoNormal"><font face="Arial" size="2"><span lang="EN-US"style="font-size: 10.0pt;font-family:Arial"> </span></font></div>