On 11/18/2013 7:24 AM, d b wrote:
bool delete_emp(int key, string name = "")
{
         string query = ???;

         if(name.length() > 0)
         {
             //needs to delete specific row. by unique key.
         }
         else
         {
             //needs to delete rows belongs to key
         }
}

delete from emp where key = :key and (:name='' or name=:name);

Just bind both parameters - you don't need an if statement in your host application, the condition is baked into the query.
--
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to