default-value

how to pass default value to date parametere in storedprocedure - Sqlserver 2008?

青春壹個敷衍的年華 提交于 2019-12-04 06:30:00
问题 Here it is my stored procedure: ALTER proc [dbo].[allrecp] @peid int=0, @pename varchar(20)='', @pdes varchar(20)='', @pdoj date='1111-1-1', @sal money=0, @dept int=0, @loc int=0,@i int=0 as begin if(@i=1) begin insert into Employee values(@pename,@pdes,@pdoj,@sal,@dept,@loc) end if(@i=2) begin update Employee set ENAME=@pename,DESEGNATION=@pdes,DOJ=@pdoj,SALARY=@sal,DEPTID=@dept,LOCATIONID=@loc WHERE EMPID=@peid end if(@i=3) delete EMPLOYEE where EMPID=@peid end And my c# code is: private

setting a default value to an undefined variable in javascript

≯℡__Kan透↙ 提交于 2019-12-04 05:01:42
Ideally I want to be able to write something like: function a( b ) { b.defaultVal( 1 ); return b; } The intention of this is that if b is any defined value, b will remain as that value; but if b is undefined, then b will be set to the value specified in the parameter of defaultVal() , in this case 1 . Is this even possible? Ive been toying about with something like this: String.prototype.defaultVal=function(valOnUndefined){ if(typeof this==='undefined'){ return valOnUndefined; }else{ return this; } }; But I'm not having any success applying this kind of logic to any variable, particularly

WCF DataMember EmitDefaultValue on value type? (but set my own default value)

爷,独闯天下 提交于 2019-12-04 04:55:25
问题 I have the following: [DataContract] public class Foo { [DataMember(EmitDefaultValue = true) public bool Bar { get; set; } } 2 Questions: What really happens here because my bool can't really be null, so if I emit the default value then what? How do I make it so that if someone passes a message without the Bar part then it my server sets it to true instead of false by default? Basically, my bar member is not required to be transmitted over the soap message and if it isn't I want it to default

Inserting NULL into NOT NULL columns with Default Value

試著忘記壹切 提交于 2019-12-04 04:02:30
For a bit of background, we use Zend Framework 2 and Doctrine at work. Doctrine will always insert NULL for values we do not populate ourselves. Usually this is okay as if the field has a default value, then it SHOULD populate the field with this default value. For one of our servers running MySQL 5.6.16 a query such as the one below runs and executes fine. Although NULL is being inserted into a field which is not nullable, MySQL populates the field with its default value on insert. On another of our servers running MySQL 5.6.20 , we run the query below and it falls over because it complains

how to initialize function arguments that are classes with default value

帅比萌擦擦* 提交于 2019-12-04 00:23:28
问题 I'm working on Linux gcc environment and I need to initilize function arguments that are classes with default values. When I do that with temporary instance of the class it makes an error like this: "default argument for [function argument] has type [class name]. for example: void foo(std::wstring& str = std::wstring()) error: default argument for 'std::wstring& str' has type 'std::wstring' P.S. this code is compiled without any error or warning with VC++. How can I initilize the default

Why does using a default-valued Java Integer result in a NullPointerException?

青春壹個敷衍的年華 提交于 2019-12-03 22:57:11
I am new to Java. I just read that class variables in Java have default value. I tried the following program and was expecting to get the output as 0 , which is the default value on an integer, but I get the NullPointerException . What am I missing? class Test{ static Integer iVar; public static void main(String...args) { System.out.println(iVar.intValue()); } } codaddict You are right, uninitialized class variables in Java have default value assigned to them. Integer type in Java are not same as int . Integer is the wrapper class which wraps the value of primitive type int in an object. In

django-admin formfield_for_* change default value per/depending on instance

霸气de小男生 提交于 2019-12-03 21:54:19
I'm trying to change the default value of a foreignkey-formfield to set a Value of an other model depending on the logged in user . But I'm racking my brain on it... This: Changing ForeignKey’s defaults in admin site would an option to change the empty_label, but I need the default_value. #Now I tried the following without errors but it didn't had the desired effect: class EmployeeAdmin(admin.ModelAdmin): ... def formfield_for_foreignkey(self, db_field, request=None, **kwargs): formfields= super(EmployeeAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) if request.user.is

Difference between default-initialize and value-initialize in C++03?

好久不见. 提交于 2019-12-03 19:59:50
问题 I had always thought that creating a new object would always call the default constructor on an object, and whether the constructor was explicit or automatically generated by the compiler made no difference. According to this highly regarded answer to a different question, this changed in a subtle way between C++98 and C++03 and now works like so: struct B { ~B(); int m; }; // non-POD, compiler generated default ctor new B; // default-initializes (leaves B::m uninitialized) new B(); // value

Using a class member as a default argument for a member function

馋奶兔 提交于 2019-12-03 17:39:28
问题 Is there another way than manually overloading the corresponding member function and calling the first overload with the member as the argument? I am trying something along the lines of class test { string t1="test"; testfun( string& val = this->t1 ) { /* modify val somehow */ } }; (Test it: http://goo.gl/36p4CF) Currently I guess there is no technical reason why this should not work. Is there a solution doing it this way except overloading and setting the parameter manually? Why is this not

Scala: how to initialize an object using default values

情到浓时终转凉″ 提交于 2019-12-03 16:08:39
问题 I think this will be better explained with an example I have the following case class case class Person(name: String = "no name", surname: String = "no surname") And I want to make a general function to populate it from, for example, a json message, that might not specify all fields I know that to use the default values the simple answer is not to pass them to the constructor, but if I have several fields that may or may not appear in the json, I should have to use a huge switch sentence