List item can not be inserted with Javascript if custom list columns are used

I'm adding JavaScript to a SharePoint site. Part of the functionality is to insert elements into a SharePoint list. I have previously done this with a single column ("Title") and try to update it to insert multiple columns for each new item (especially "Title" and "AIT #"). Here is the function I use:

/**
 * Inserts new items to a List
 * 
 * @params 
 * @params string listName
 * @params string() listItemFields
 * 
 * @returns void
**/
function insertListItems(newListItems, listName, listItemFields) {  
    console.log(newListItems);
    var clientContext = new SP.ClientContext.get_current();
    var olist = clientContext.get_web().get_lists().getByTitle(listName); 

    // Get SP list   
    var itemCreateInfo = new SP.ListItemCreationInformation();

    for(var i = 0; i < newListItems.length; i++) {

        oListItem = olist.addItem(itemCreateInfo);
        oListItem.set_item("Title", newListItems(i)("Title"));
        oListItem.set_item("AIT#", newListItems(i)("AIT#"));
        // for(var j = 0; j < listItemFields.length; j++) {
        //  oListItem.set_item(listItemFields(j), newListItems(i)(listItemFields(j)));
        // }

        oListItem.update();
    }

    clientContext.load(oListItem); 
    clientContext.executeQueryAsync(
        this.successHandler("Items inserted to " + listName), 
        this.errorHandler()
    );  
}

If I only use the title column, this works fine even if there are several elements. However, if you add the AIT # column (a custom column I've added to the list), the response will be reported as successful, but the list will not contain any of the items that were allegedly added. Can someone give me an insight why that is?

Also, I've noticed that if the function queries SharePoint like this, calling the successHandler also calls the errorHandler, even if the answer is a success.

mysql – How do you specify multiple columns for the key as part of a hash subpartition?

I'm creating a table with composite partitioning (RANGE, then HASH)

My actual table is huge, so here's a slimmed dummy table showing the important parts:

CREATE TABLE table1(
    id INT NOT NULL AUTO_INCREMENT,

    dtvalue DATETIME NOT NULL, -- Used for RANGE partitions

    v1 INT NOT NULL, -- Used for HASH partitions
    v2 INT NOT NULL,

    CONSTRAINT pk_table1 PRIMARY KEY(id),

    CONSTRAINT uk_table1 UNIQUE(v1,v2) -- Unique key for v1 and v2
)
ROW_FORMAT=COMPRESSED
PARTITION BY RANGE(dtvalue)
SUBPARTITION BY HASH(v1,v2) SUBPARTITIONS 32 -- Does this HASH subpartition work?
(PARTITION p20191101 VALUES LESS THAN('2019-11-01'),
 PARTITION p20191102 VALUES LESS THAN('2019-11-02'),
 PARTITION pMax VALUES LESS THAN MAXVALUE);

This table is often linked by v1 and v2 combined as a unique identifier, so both columns for the HASH Key is critical.

My question is, you can specify multiple columns as part of the HASH Key?

Or you can specify the unique key for yourself HASH Key?
e.g. SUBPARTITION BY HASH(uk_table1) SUBPARTITIONS 32

How do I empty a calculated column if other columns have no values?

This is my format in the calculated format:

=TEXT((Column2)-(Column1);"hh:mm:ss")

I have the value "2018-12-13 10:10:23" in column1, but if column2 is empty, the calculated column will read "10:10:23" based on column 1. Is there still the possibility to empty the field or to say something instead?

Tried this code in the calculated column, but to no avail:

=IF(ISBLANK((Column2));"no value";)=TEXT((Column2)-(Column1);"hh:mm:ss")

Restore the MySQL database, with some columns of "and others not included

We need to recover a database in MySQL, but some columns do not contain the content of "and others do not, as in this example:

00.168.93.70,null,ES,0,htc,33a48a1515b20691,"htc;HTC One (REL4.4.2)",m7,53e4b0f1e733a4a95e,-Free-2.1.0.6.f,4.4.2,unknown,13,"Internet app",com.app.android.free.debug,null,"HTC One",test@gmail.com,"31.5000,34.7500",APA91bE1E-7-tO1fgbYCs5kbiUapri1zm5Bda5ehyXmTgTOabx5GQHprbYhfB62w0BgdJ7Nbe3qevehFmhCmGXwArSkCr8qpyjoL_WIGq7IA0tsyC4pmpxT0RO9gJ2K3ErfaMQevHviUR4ZJrm_,"en_EN,zh_CN"
unknown,unknown,unknown,0,htc,33a48515b20691,"htc;HTC One (REL4.4.2)",m7,5385a31e733a4a95f,Free-2.1.0.6.f,4.4.2,unknown,0,unknown,com.app.android.free.debug,unknown,"HTC One",test@gmail.com,unknown,APA9zm5Bda5ehyXmTgTOabx5GQHprbYhfB62w0BgdJ7Nbe3qeveAtIxxi0X3mCr8qpyjoL_WIGq7IA0tsyC4pmpxT0RO9gJ2K3ErfaMQevHviUR4ZJrm,

How can I restore it properly?

sql – MySQL index is not used when returning certain columns

I have a table with one created_on Field that is indexed. A slow query made me realize that the index is not being used, depending on which column I'm returning. In the following two examples I have the foo and bar Columns.

  • foo is part of another index with three more columns.
  • bar is not indexed at all.
EXPLAIN SELECT created_on, foo FROM T1
WHERE created_on > NOW() - INTERVAL 5 DAY;

No index used, +3 mil rows are searched. (Using where)

EXPLAIN SELECT created_on, bar FROM T1
WHERE created_on > NOW() - INTERVAL 5 DAY;

Index is used and only 1.5 mil lines are searched. (Using where; Using index)

Why does MySQL skip the index for one of these queries?

SQL Server – How do I select specific columns in a SQL-prepared statement?

I've created a prepared statement to print a file and add a date to the file name. This part works if I select the entire database. I want to select specific columns for the query, not all.

I'm a newbie in SQL syntax. Please note this when answering. πŸ™‚

Here's what I started before the date in filename was a requirement:

    USE dbx;
SELECT
   custtype.custtype,
   custtype.custtypedesc,
   USER.jobtitle,
   USER.branch,
   log.custid,
   log.username,
   log.actualuser,
   log.timestamp,
   log.action,
   log.data INTO outfile '/inetpub/wwwroot/reports/Activity_Log.csv' fields terminated BY ',' optionally enclosed BY '"' lines terminated BY 'n' 
FROM
   log 
   LEFT OUTER JOIN
      USER 
      ON log.custid = USER.custid 
      AND log.username = USER.username 
   LEFT OUTER JOIN
      custtype 
      ON custtype.custtype = USER.custtype 
WHERE
   USER.email NOT LIKE " % @sample.com" 
   AND USER.email NOT LIKE " % @google.com" 
   AND log.username NOT LIKE "Guest % "

You can see that I select individual columns according to my request. This works fine, but I can not figure out how to select individual columns in the next query as follows …

Here's what I have now, after the date request has been added:

SET
   @TS = DATE_FORMAT(NOW(), '_%m_%d_%Y');
SET
   @FOLDER = '/inetpub/wwwroot/reports/';
SET
   @PREFIX = 'Activity_Report_';
SET
   @EXT = '.csv';
USE webcat_336;
SET
   @CMD = concat("
   SELECT
      custtype.CustType, custtype.CustTypeDesc 
   FROM
      log INTO OUTFILE", @FOLDER , @TS, @EXT);
"' FIELDS ENCLOSED BY '"' TERMINATED BY ';
' ESCAPED BY '"'",
 " LINES TERMINATED BY 'rn';
"

If I replace * "custtype.CustType, custtype.CustTypeDesc" with * in the second example, the file is generated correctly and is expected to be named Activity_Log_m_d_Y.csv.

question

How can I select only certain columns, unlike all the columns in the example above?

mysql – Is the order of the columns in a covering index important?

I have the following coverage indexes:

INDEX (col1, col3); -- index 1
INDEX (col1, col2, col3); -- index 2

because I want to support the following types of queries:

1)

  SELECT ...
    FROM my_table
   WHERE col1 = ... AND
         col2 = ...
ORDER BY col3

2)

  SELECT ...
    FROM my_table
   WHERE col1 = ... 
ORDER BY col3

I am not familiar with how a cover index works. Is index 1 redundant? Or does a coverage index require the columns to be next to each other?

postgresql – How does ON CONFLICT work for composite foreign key columns?

I have problems with ON CONFLICT Does not work for foreign key columns where the foreign key is composed. Here is an example.

create table foreign_table
(
    id_a text    not null,
    id_b text    not null,
    id   integer not null
        constraint ft_pk
            primary key,
    constraint ft_a_b_key
        unique (id_a, id_b)
);

create table my_table
(
    id          integer,
    ftable_id_a text,
    ftable_id_b text,
    constraint my_table_a_b_fk
        foreign key (ftable_id_a, ftable_id_b) references 
    foreign_table (id_a, id_b)
);

With this query:

insert into tcell_test.my_table (id, ftable_id_a, ftable_id_b) 
    values (3, 'a3', 'b3') on conflict do nothing ;

where should I say 'a3' is not in foreign_tableI would expect that ON CONFLICT to handle the mistake.

Instead, I get the error:

(23503) ERROR: insert or update on table "my_table" 
   violates foreign key constraint "my_table_a_b_fk" 
Detail: Key (ftable_id_a, ftable_id_b)=(a3, b3) 
   is not present in table "foreign_table".

Is there a way to correct this? ON CONFLICT handles the mistake?