PostgreSQL
 sql >> Teknologi Basis Data >  >> RDS >> PostgreSQL

Tabel bernilai Parameter Setara di Postgresql

@HamidKhan -Apakah bahasa pengembangan Anda Java atau C #?

CREATE TABLE public.employee (
  emp_id INTEGER NOT NULL,
  emp_nm VARCHAR(40),
  first_in_time TIMESTAMP WITH TIME ZONE DEFAULT clock_timestamp(),
  last_chg_time TIMESTAMP WITH TIME ZONE DEFAULT clock_timestamp(),
  CONSTRAINT employee_pkey PRIMARY KEY(emp_id)
)
WITH (oids = false);

CREATE TYPE public.employee_udt AS (
  emp_id INTEGER,
  emp_nm VARCHAR(40)
);

--c# kode 1

public class EmployeeUdt
{
    [PgName("emp_id")] 
    public int EmpId { get; set; } 

    [PgName("emp_nm")]
    public string EmpNm { get; set; }
}

--c# kode 2

List<EmployeeUdt> lst_param = new List<EmployeeUdt>();

for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
{
lst_param.Add(
new EmployeeUdt
{
    EmpId = Convert.ToInt32(this.dataGridView1[0, i].Value),
    EmpNm = this.dataGridView1[1, i].Value.ToString()
}
);
}

var _param = new[] {
new NpgsqlParameter
{
    ParameterName="p_employee",
    NpgsqlDbType = NpgsqlDbType.Composite,
    SpecificType = typeof(EmployeeUdt[]),
    NpgsqlValue = lst_param
}

};

SqlHelper.ExecuteNonQuery<EmployeeUdt>(this.connstring, "usp_set_emp", _param);


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. PostgreSQL:Menampilkan tabel di PostgreSQL

  2. Instal dan Hubungkan ke PostgreSQL 10 di Ubuntu 16.04

  3. Cara menggunakan struktur data cincin di fungsi jendela

  4. Cara memetakan array PostgreSQL dengan Hibernate

  5. Lima Hal Keren yang Saya Pelajari di PostgreSQL Conference Europe 2018