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. inserting data using union

inserting data using union

Scheduled Pinned Locked Moved Database
regexhelpquestion
5 Posts 3 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.
  • U Offline
    U Offline
    uglyeyes
    wrote on last edited by
    #1

    Hi, I need to handle missing select values programattically. this is what i have insert into A(id, name, age, value, DOB) select 1,'Max','21','a','100928' union select 2,'x','100948'   union select 3,'Rex','32','b','100928' union select 4,'xx','100938'   union select 5 'Fed','24','xx','100928' all my insert statement are stripped off via regex. the structure of insert statement is as show above. but at times it may miss "name" and "age" and it gives me error something like All queries combined using a UNION, INTERSECT or EXCEPT operator must have an equal number of expressions now those insert scripts are quite bulky. sometime 100MB I would like to automatically handle missing name and age.   I am not sure how could i do that? could you please give me some idea?

    W A 2 Replies Last reply
    0
    • U uglyeyes

      Hi, I need to handle missing select values programattically. this is what i have insert into A(id, name, age, value, DOB) select 1,'Max','21','a','100928' union select 2,'x','100948'   union select 3,'Rex','32','b','100928' union select 4,'xx','100938'   union select 5 'Fed','24','xx','100928' all my insert statement are stripped off via regex. the structure of insert statement is as show above. but at times it may miss "name" and "age" and it gives me error something like All queries combined using a UNION, INTERSECT or EXCEPT operator must have an equal number of expressions now those insert scripts are quite bulky. sometime 100MB I would like to automatically handle missing name and age.   I am not sure how could i do that? could you please give me some idea?

      W Offline
      W Offline
      WoutL
      wrote on last edited by
      #2

      You could pass Null as the value if you don't know the name or age.

      Wout Louwers

      U 1 Reply Last reply
      0
      • W WoutL

        You could pass Null as the value if you don't know the name or age.

        Wout Louwers

        U Offline
        U Offline
        uglyeyes
        wrote on last edited by
        #3

        how do i pass null value without modifying below block of query select 1,'Max','21','a','100928' union select 2,'x','100948'   union select 3,'Rex','32','b','100928' union select 4,'xx','100938'   union select 5 'Fed','24','xx','100928' Lets just assume above text is a read only text.

        W 1 Reply Last reply
        0
        • U uglyeyes

          how do i pass null value without modifying below block of query select 1,'Max','21','a','100928' union select 2,'x','100948'   union select 3,'Rex','32','b','100928' union select 4,'xx','100938'   union select 5 'Fed','24','xx','100928' Lets just assume above text is a read only text.

          W Offline
          W Offline
          WoutL
          wrote on last edited by
          #4

          If you don't change the query, the insert will not work. The query should look like this:

          select 1,'Max','21','a','100928' union
          select 2, Null, Null,'x','100948' union
          select 3,'Rex','32','b','100928' union
          select 4, Null, Null,'xx','100938' union
          select 5 'Fed','24','xx','100928'

          Wout Louwers

          1 Reply Last reply
          0
          • U uglyeyes

            Hi, I need to handle missing select values programattically. this is what i have insert into A(id, name, age, value, DOB) select 1,'Max','21','a','100928' union select 2,'x','100948'   union select 3,'Rex','32','b','100928' union select 4,'xx','100938'   union select 5 'Fed','24','xx','100928' all my insert statement are stripped off via regex. the structure of insert statement is as show above. but at times it may miss "name" and "age" and it gives me error something like All queries combined using a UNION, INTERSECT or EXCEPT operator must have an equal number of expressions now those insert scripts are quite bulky. sometime 100MB I would like to automatically handle missing name and age.   I am not sure how could i do that? could you please give me some idea?

            A Offline
            A Offline
            Ashfield
            wrote on last edited by
            #5

            Its not the insert you need to change, its the code that generates it. Without seeing the code its difficult to help further.

            Bob Ashfield Consultants Ltd

            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