473,385 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to insert Null, after selecting values

I have 2 tables. TabA and TabAdup

both table structure is same. I executed a select query (with some condition) on TabA & fetched the values to local variables.

Then I ran insert query to TabAdup with values from local variables.

These are carried out in a for loop for all the values

Here there are 8 column have structure as NULL ALLOWED.(NOT NULL - is not there)
During insertion for any of these 8 columns when their value is NULL, insert is not happening properly.

In both the table definition, I have not given default value but still it is inserted with 0 when the original value is null. I want exact insertion if null then that column should have null in TabAdup.

I cannot have so many insert statements by removing the null field from insert statement because the combinations will come 2 power 8 = 1024 insert statements.

Please clarify/resolve.

Code has to be in PRO C/ C Sharp
Jan 17 '12 #1
5 2372
Rabbit
12,516 Expert Mod 8TB
How come you're doing the inserts one at a time in code instead of using SQL? Is there a reason you can't use insert into?
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO TabADup
  2. SELECT ...
  3. FROM TabA
Jan 17 '12 #2
Actually the select statement is at one function & the insert statement is another function. In the insert function before insert statement fetch is executed to populate the values to local variables & then by these local variables, insertion is done in the loop for every record.
Actually after select query execution before insertion some more tasks are performed & that's why both these things are separated by presenting them in different functions.
So now how can we avoid this 0 insertion from local variable when null is the value for the column in original table?
Jan 18 '12 #3
PsychoCoder
465 Expert Mod 256MB
If I'm understanding your question why not pass DbNull.Value when you know the value will be null. If you pass and empty string that's not going to translate to NULL in your table
Jan 18 '12 #4
Hi Richard, What you are saying is correct but I am using Unix OS & not windows & thus tell me what should i include to make this DbNull working at this environment?
Jan 18 '12 #5
Rabbit
12,516 Expert Mod 8TB
Show us the code.
Jan 18 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mark Davenport | last post by:
Hi, Here's my question: How do I pass a NULL value in a variable to a MySQL DB? Here's an overview of my problem: I have a PHP page that processes code, then inserts the code into a database....
1
by: Keith | last post by:
I am Using Dreamweaver MX to create my site and have come accross a problem no one in the DW groups seems to be able to help with. When I submit an insert to my SQL database, any form value which...
2
by: schumacker | last post by:
Hi everyone! I am working with Delphi v7 and MS SQLServer. I am trying to insert data in a table with a SQL sentence. Some of the fields of my table are type char or varchar, and they can have...
10
by: Python_it | last post by:
Python 2.4 MySQL-python.exe-1.2.0.win32-py2.4.zip How can I insert a NULL value in a table (MySQL-database). I can't set a var to NULL? Or is there a other possibility? My var must be variable...
6
by: FatboyCanteen | last post by:
When I using dataset to append a null value to the datetime field. It throw a error -> can not convert db.null to system.date Can there is any standard to pass a Null value to the DateTime...
6
by: Dean Slindee | last post by:
I am looking for the "right" way to handle inserting and presenting null date values. Public Const c_NullDate As Date = #12:00:00 AM# If I set the value of a date variable in an SQL Server insert...
4
by: J | last post by:
I am editing a pre-existing view. This view is already bringing data from 40+ tables so I am to modify it without screwing with anything else that is already in there. I need to (left) join it...
1
by: praveena mani | last post by:
Can we insert null values in stored procedures? When we tried to insert null inprocedures its giving query ok... But wen we try to display the values from table it shows empty set... Y???
3
by: rc | last post by:
How to insert NULL values in to int field using params. I'm trying to use pymssql.execute, passing the operation and list of params. One of the values in the params is a NULL value going to int...
2
by: dmorand | last post by:
I have this query that I'm using in coldfusion: Insert into ps_manager_employee_ids (manager_emplid,emp_id,last_name,first_name,hire_dt,rehire_dt,emp_status,union_status) values...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.