Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. How to define a null-ignoring unique constraint

How to define a null-ignoring unique constraint

Scheduled Pinned Locked Moved Database
questioncsharppostgresqlsysadmintutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    supercali
    wrote on last edited by
    #1

    Hi. Is there a "ignore null's" property, or a way to implement it, in the Constraint or the UniqueConstraint of a DataTable? I have in the server (postgres 8.1.4) a field with a unique contraint, and this constraint can ignore nulls. How can i define such a thing in ADO.NET? Thanks.

    F 1 Reply Last reply
    0
    • S supercali

      Hi. Is there a "ignore null's" property, or a way to implement it, in the Constraint or the UniqueConstraint of a DataTable? I have in the server (postgres 8.1.4) a field with a unique contraint, and this constraint can ignore nulls. How can i define such a thing in ADO.NET? Thanks.

      F Offline
      F Offline
      Farhan Noor Qureshi
      wrote on last edited by
      #2

      If the field allows null then you can have a unique key constraint on it. BTW: aggregate functions ignore NULLs by design.


      Farhan Noor Qureshi

      S 1 Reply Last reply
      0
      • F Farhan Noor Qureshi

        If the field allows null then you can have a unique key constraint on it. BTW: aggregate functions ignore NULLs by design.


        Farhan Noor Qureshi

        S Offline
        S Offline
        supercali
        wrote on last edited by
        #3

        no... I have a UniqueConstraint on a field called 'cve_unidad', this field has .AllowDBNull = true, and i put DefaultValue = null in this field, but, there is still a the problem... when i put two rows in then datagrid, the second null value raises the error message: "Value Column 'cve_unidad' is constrained to be unique. Value '' is already present. Do you want to correct this value?" this is a example: cve_unidad | nom_unidad (null) | 'un nombre' <-- here is ok (null) | 'another nombre' <-- here raises the "already present" error This is an "autonumeric-like" scenario, i want to send some values at once, then clear an refill the datagrid with the data (with de autonumeric updated). I don't want to use the .AutoIncrement properte beacuse the value displayed will not neccesary equals the autonumeric value in the database. thanks

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups