null

Setting variable's database value to NULL instead of empty string

寵の児 提交于 2019-12-11 05:30:37
问题 In my SQL database there're many fields like this: Field Type:Text Null:Yes Default:NULL My INSERT looks like this: INSERT INTO tbl (col,col,col,...) VALUES ('val','val','val',...) Now, those quotes in my INSERT statement's values are inserting '' (empty string) in to the database when what I really want is nothing (NULL). So I tried if (isset($_POST['title'])) {$newTitle = mysql_real_escape_string(trim($_POST['title']));} else {$newTitle = NULL;} and that just inserts 'NULL' - the string

Unexpected nil in JSON strings

岁酱吖の 提交于 2019-12-11 05:21:37
问题 I parse JSON in my application and some of the JSONs have nil values which I handled. However, the app still shows me the error that JSON contains nil values. My code: struct Response : Decodable { let articles: [Article] } struct Article: Decodable { let title: String let description : String let url : String let urlToImage : String } URLSession.shared.dataTask(with: url) { (data, response, error) in guard let data = data else { return } do { let article = try JSONDecoder().decode(Response

PostgreSQL last_value ignore nulls

女生的网名这么多〃 提交于 2019-12-11 05:18:08
问题 I know this already been asked, but why doesn't the solution below work? I want to fill value with the last non-null value ordered by idx . What I see: idx | coalesce -----+---------- 1 | 2 2 | 4 3 | 4 | 5 | 10 (5 rows) What I want: idx | coalesce -----+---------- 1 | 2 2 | 4 3 | 4 4 | 4 5 | 10 (5 rows) Code: with base as ( select 1 as idx , 2 as value union select 2 as idx , 4 as value union select 3 as idx , null as value union select 4 as idx , null as value union select 5 as idx , 10 as

Obtaining values of an attribute through relationships using Core Data - Currently passing NULL

ε祈祈猫儿з 提交于 2019-12-11 05:12:00
问题 I have a Core Data Model with three entities: Transaction, Occasion, Person and when I'm currently fetching in the Transaction Entity, I am getting "NULL" as the value in the database. Let me explain. Transaction is in my case, the Entity that has relationships to Person and Occasion. The person entity has a name attribute and a relationship to the transaction entity. transactions (Person Entity) < ------ >> whoBy (Transaction entity). There is also a relationship from the categories

final variable issue in an inner class

血红的双手。 提交于 2019-12-11 05:10:07
问题 Could you please tell me what is the error here? it tells me that "gender" in toast make must be set to final but when I do, the if statements complain that it should not be final @Override protected void onCreate(Bundle savedInstanceState) { String gender = null; Toast.makeText(this, R.string.ok, Toast.LENGTH_LONG).show(); super.onCreate(savedInstanceState); setContentView(R.layout.createprofile); RadioButton rb_male = (RadioButton) findViewById(R.id.maleradiobutton); String male=rb_male

Why does this program keep on running after null is returned?

浪尽此生 提交于 2019-12-11 05:05:48
问题 I'm learning recursion and I understand how the program generally works, but I'm confused why the program continues to work after null is first returned when the value, at 16, is too big. Basically the code below will run and add 5 to the argument for start each time from 1,6,11 to 16. Since 16 is > 13 it says to return null. How does JavaScript know to go back and try to calculate 13 when it just says return null on line 6? I'd really appreciate any help. Here's the code from the book I'm

Getting EmailAddress NULL from Active Directory (AccountManagement UserPrincipal)

落爺英雄遲暮 提交于 2019-12-11 04:59:47
问题 I have a problem and can not find solution: I have the code below to retrieve the e-mail ( EmailAddress ) user that is accessing the web application. var pc = new System.DirectoryServices.AccountManagement.PrincipalContext(System.DirectoryServices.AccountManagement.ContextType.Domain); var user = System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity(pc, System.DirectoryServices.AccountManagement.IdentityType.SamAccountName, username.ToLower()); email = user.EmailAddress; For

Is there a way to set a variable up to place output to stdout or null?

夙愿已清 提交于 2019-12-11 04:58:56
问题 I would like to set up a variable in my code that would ultimately define if I'll see some output or not. "hello" writes to stdout "hello" > $null supresses output My idea is something like this: $debugOutputSwitch = $true $outputVar = $null if ($debugOutputSwitch){ $outputVar = **STDOUT** } ... Write-Host "Something I want out anyway" "Something I might not want on STDOUT" > $outputVar If this general idea is a way to go, then STDOUT is what I'm looking for If this idea is completely wrong..

Objective-C nil Outlets

霸气de小男生 提交于 2019-12-11 04:58:15
问题 I have a class used for a user interface, with two constructors: - (id)initWithBanner:(NSMutableArray *)banner { if ( ( self = [super initWithNibName:@"UIBanner" bundle:nil] ) ) { // ... code... } return self; } - (id)initWithPreview:(NSMutableArray *)previews { if ( ( self = [super initWithNibName:@"UIBanner" bundle:nil] ) ) { // ... code... } return self; } Inside this two constructors, I use two outlets, a UIPageControl and a UIScrollView, linked with the new XCode 4. Now, if I use the

SQL Server: set NULL value to today's value

吃可爱长大的小学妹 提交于 2019-12-11 04:57:43
问题 I have a column EntryDate in a SQL Server database. How can I set a NULL value to fill it with today's date (server time) if value was not provided in a query? 回答1: Disallow Nulls on the column and set a default on the column of getdate() /*Deal with any existing NULLs*/ UPDATE YourTable SET EntryDate=GETDATE() WHERE EntryDate IS NULL /*Disallow NULLs*/ ALTER TABLE YourTable ALTER COLUMN EntryDate DATE NOT NULL /*Add default constraint*/ ALTER TABLE YourTable ADD CONSTRAINT DF_YourTable