struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yoge <yogend...@adventnet.com>
Subject Re: how to insert null using sql query in java code
Date Mon, 26 Apr 2004 06:11:59 GMT
Hi,

Try the below code.

if(webpurchased != null)
{
    webpurchased="'"+webpurchased+"'";
}

stmt.executeQuery("INSERT INTO advt_spns_soln VALUES "+
        
 "(advt_spns_soln_id.nextval,'"+firstName+"','"+lastName+"','"+title+ 
"','"+
company+"','"+companyAddress+"','"+city+"','"+stateId+"',"+postalcode+",'"+
country+"','"+email+"',"+phone+",'"+url+"','"+campaign+"',"+webpurchased+",'"+
targetAdvt+"','"+trial+"','"+budget+"','"+marketobjective+"','"+emailupdate+"')");    
   

Dont forget to remove single quotes for the variable webpurchased in the 
query statement.

Thanks
Yoge

Jignesh Patel wrote:

>Hi All,
>I am following query to insert value in databse now suppose value of 
>"webpurchased","targetadvt" and 'trial" is null then how can I can insert 
>same null value in database. 
>Because my parameter is like String webpurchased=null --In this case value of 
>webpurchase will be replaced by string 'null' while insering, which is 
>meaning less. I want to insert real null.
>
>MY query:
>   		stmt.executeQuery("INSERT INTO advt_spns_soln VALUES "+ 
>		 "(advt_spns_soln_id.nextval,'"+firstName+"','"+lastName+"','"+title+ "','"+ 
>company+"','"+companyAddress+"','"+city+"','"+stateId+"',"+postalcode+",'"+
>country+"','"+email+"',"+phone+",'"+url+"','"+campaign+"','"+webpurchased+"','"+
>targetAdvt+"','"+trial+"','"+budget+"','"+marketobjective+"','"+emailupdate+"')");		
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message