default-value

MySQL 5.5 & 5.6 default values

纵然是瞬间 提交于 2019-12-03 02:10:24
I'd like some clarification on the behaviour of default values in MySQL 5.5 & 5.6. Lets say we have the following table on a MySQL 5.5 server: CREATE TABLE `test` ( `TestColumn` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=INNODB DEFAULT CHARSET=utf8; I am able to run the following query without issue: INSERT INTO `test` VALUES (NULL); Which creates the following row: TestColumn 2014-02-20 14:55:05 Now if I repeat the same test on a MySQL 5.6 server, the insert fails: Error Code: 1048 Column 'TestColumn' cannot be null I understand that timestamp automatic initilisation has changed in

How to set a Postgresql default value datestamp like 'YYYYMM'?

只愿长相守 提交于 2019-12-03 00:59:11
As title, how can I set a table's column to have the default value the current year and month, in format 'YYYYMM', like 200905 for today? Nic Gibson Please bear in mind that the formatting of the date is independent of the storage. If it's essential to you that the date is stored in that format you will need to either define a custom data type or store it as a string. Then you can use a combination of extract , typecasting and concatenation to get that format. However, I suspect that you want to store a date and get the format on output. So, something like this will do the trick for you:

DateTime ParseExact string was not recognize as a DateTime C#

跟風遠走 提交于 2019-12-03 00:43:54
问题 I'm trying to parse string as DateTime but I'm getting an error. here my code return DateTime.ParseExact("01/01/0001 12:00:00 AM", "dd/MM/yyyy HH:mm:ss tt", CultureInfo.InvariantCulture); The date and its format is got from DataBase as string and I'm trying to add it to a DataColumn DateTime data type. What's the problem? Thanks. 回答1: You are trying to parse the DateTime exactly , therefore the format has to be exact DateTime.ParseExact("01/01/0001 12:00:00 AM", "dd/MM/yyyy hh:mm:ss tt",

React - change input defaultValue by passing props

╄→гoц情女王★ 提交于 2019-12-03 00:01:33
Consider this example: var Field = React.createClass({ render: function () { // never renders new value... return ( <div> <input type="text" defaultValue={this.props.value || ''} /> </div> ); } }); var App = React.createClass({ getInitialState: function () { return {value: 'Hello!'}; }, changeTo: function (str) { this.setState({value: str}); }, render: function () { return ( <div> <Field value={this.state.value} /> <button onClick={this.changeTo.bind(null, 'Whyyyy?')}>Change to "Whyyyy?"</button> <button onClick={this.changeTo.bind(null, void 0)}>Change to undefined</button> </div> ); } });

Setting a checkbox “check” property in React

丶灬走出姿态 提交于 2019-12-02 23:30:48
I am having a very annoying issue with React and checkboxes. The application I am working with requires a list of checkboxes that represent settings that are persisted in the back-end. There is an option to restore the settings to their original state . At first, I created a component that has an object like a map of settings. Each setting has a key and a boolean value. Hence: { bubbles: true, gregory: false } Is to be represented as: <input type="checkbox" value="bubbles" checked="checked" /> <input type="checkbox" value="gregory" /> Now, it seems React is ignorant about how a checkbox is

Default values on empty user input

我们两清 提交于 2019-12-02 21:35:21
Here I have to set the default value if the user will enter the value from the keyboard. Here is the code that user can enter value: input = int(raw_input("Enter the inputs : ")) Here the value will be assigned to a variable input after entering the value and hitting Enter . Is there any method that if we don't enter the value and directly hit the Enter key, the variable will be directly assigned to a default value, say as input = 0.025 ? input = int(raw_input("Enter the inputs : ") or "42") How does it work? If nothing was entered then raw_input returns empty string. Empty string in python is

What is the element value in an uninitialized vector?

孤街醉人 提交于 2019-12-02 19:00:16
问题 If I create a vector like vector<myClass> v(10); what is the default value of each element? Also, what if it is a vector<myUnion> v(10) ? 回答1: The constructor of std::vector<> that you are using when you declare your vector as vector<myClass> v(10); actually has more than one parameter. It has three parameters: initial size (that you specified as 10), the initial value for new elements and the allocator value. explicit vector(size_type n, const T& value = T(), const Allocator& = Allocator());

Default value of an Objective-C struct and how to test

我怕爱的太早我们不能终老 提交于 2019-12-02 17:26:58
I'm trying to test if a property has been set yet. I know that with objects that I've got: CGRect ppGoalFrame; LocalPlaySetup *localPlaySetup; and I can test if (localPlaySetup == nil) but if I attempt to test the CGRect with == nil or == NULL if (ppGoalFrame == nil) I get invalid operands to binary == (have 'CGRect' and 'void *') So is the CGRect "void", null, nil...? before it's set? Obviously I can't compare CGrect to a void pointer (I can't use ppGoalFrame == void ); is there another way to test this? The Objective-C so far is pretty easy to understand but as soon as the C looms, I get a

DateTime ParseExact string was not recognize as a DateTime C#

早过忘川 提交于 2019-12-02 13:28:11
I'm trying to parse string as DateTime but I'm getting an error. here my code return DateTime.ParseExact("01/01/0001 12:00:00 AM", "dd/MM/yyyy HH:mm:ss tt", CultureInfo.InvariantCulture); The date and its format is got from DataBase as string and I'm trying to add it to a DataColumn DateTime data type. What's the problem? Thanks. You are trying to parse the DateTime exactly , therefore the format has to be exact DateTime.ParseExact("01/01/0001 12:00:00 AM", "dd/MM/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture); You're using ParseExact, meaning you're specifying the whole format of the date

Column with DEFAULT function, pass parameter or determine insert values?

时光毁灭记忆、已成空白 提交于 2019-12-02 13:08:45
In MS-SQL Server, is it possible to pass a parameter to a DEFAULT function, or somehow base the DEFAULT value on the values inserted in the record? You can assign a function as a DEFAULT value for a column in MS-SQL Server. Using this, I'm trying to achieve the following. For a table with study ids and patient ids, I want to automatically assign a new patient number within that study. CREATE TABLE [dbo].[PATIENT_STUDY]( [PatientStudyID] [int] IDENTITY(1,1) NOT NULL, [PatientID] [int] NOT NULL, [StudyID] [int] NOT NULL, [PatientCode] [varchar(30)] NULL, [ActiveParticipant] [tinyint] NULL -- 1