Cannot execute If Else statement based on value of edited dropdown in Google Sheets Script

I have a dropdown field on a sheet (consisting of wheat, wood, stone, etc.). When that drop-down field is edited, I want it to run one of some similar functions, based on the drop-down selection (when the drop-down selection is Wheat, select from range X, for example). I have a function that seems to be accurately recording which cell the dropdown menu is in, the old value and the updated value. But now that I have an if else statement for each of the selections, it seems to give conflicting values ​​in the registry.

I think I am either not setting the value as a string correctly, or I am incorrectly instantiating the variables so that they are one thing for parts of the method and another for different parts. Here is the code below as it is current

function onEdit (evt) {

  var selection = evt.value;
  var range = evt.range;

  Logger.log("Hex Changed from: " + evt.oldValue + " to : " + selection);

    if (selection = "Brick") {
    Logger.log("It was " + selection);
    Logger.log("The Paste Area is from row " +(range.getRow()+2) + " and column " +(range.getColumn()-1) + " to row " + (range.getRow()+6) + " and column " + (range.getColumn()+1));
  } else if (selection = "Gold") {
    Logger.log("It was " + selection);
    Logger.log("The Paste Area is from row " +(range.getRow()+2) + " and column " +(range.getColumn()-1) + " to row " + (range.getRow()+6) + " and column " + (range.getColumn()+1));
  } else if (selection = "Sheep") {
    Logger.log("It was " + selection);
    Logger.log("The Paste Area is from row " +(range.getRow()+2) + " and column " +(range.getColumn()-1) + " to row " + (range.getRow()+6) + " and column " + (range.getColumn()+1));
  } else if (selection = "Stone") {
    Logger.log("It was " + selection);
    Logger.log("The Paste Area is from row " +(range.getRow()+2) + " and column " +(range.getColumn()-1) + " to row " + (range.getRow()+6) + " and column " + (range.getColumn()+1));
  } else if (selection = "Wheat") {
    Logger.log("It was " + selection);
    Logger.log("The Paste Area is from row " +(range.getRow()+2) + " and column " +(range.getColumn()-1) + " to row " + (range.getRow()+6) + " and column " + (range.getColumn()+1));
  } else if (selection = "Wood") {
    Logger.log("It was " + selection);
    Logger.log("The Paste Area is from row " +(range.getRow()+2) + " and column " +(range.getColumn()-1) + " to row " + (range.getRow()+6) + " and column " + (range.getColumn()+1));
  } else {
    Logger.log("Something went wrong");
  }
}

The problem is that it seems that when it comes to if statements, that the value of & # 39; selection & # 39; is ALWAYS "Brick", even when the selection in the first part of the record was correctly identified as what was edited for the drop-down menu (see screenshot below).

So my question is, how can I get the code to run so that when I correctly select what is the updated "select" variable (it's happening now), it will do the correct if statement (it's not happening now)?

Script registration

UK visit visa rejected due to unexplained deposits, how to approach. complex statement

I had applied for a UK visitor visa for General Medical Council registration, however I did not mention some recent deposits to my account.

The first bank statement is in your name (account number
ending at 9901) the Standard Chartered Bank showing a close
balance of USD $ 5,092 (£ 3,971). I have noticed that the account contains
an unexplained deposit of USD $ 700 (£ 545) on 02/12/2019, origins
of which are not clear. The documents presented do not show where this
The money has come. Therefore, I am not satisfied that the balance
indicated on your bank statement is an accurate reflection of your
habitual financial position and that your personal circumstances are so
set. This undermines the credibility of your application.

My second statement withdrawal on the same date and converted to USD was lost. The question is how to approach it.

The second bank statement is in your own name (account number
ending at 9901) the Standard Chartered Bank showing a close
PKR 177,159 balance (£ 893). I have noticed that the account contains
unexplained deposits totaling PKR 247,744 (£ 1,249) between 07/01/2020
and 01/22/2020 whose origins are not clear. Documents
presented does not show where this money comes from. Therefore i am
you are not satisfied that the balance indicated on your bank statement is
accurate reflection of your usual financial position and that your
Personal circumstances are as indicated. This undermines credibility.
of your application

This has two components, first are some bank deposits made by my friends who used my credit card to pay the exam fee and returned my money, these amount to 5 deposits, how can I make an acceptable statement for that?

The second is the money my brother sent me, this was sent to my inactive bank account that I use very little (I had not mentioned it on the visa). Now, should I mention this statement and my brother's statement as evidence? Do I make a statement for this?

WinSCP statement will not connect when SQL Server Agent job runs

Situation
We use WinSCP to receive daily csv files from a provider, which we then extract and upload to our data warehouse. To accomplish this, we have a SQL Agent job scheduled that runs a process task that starts a batch file. This batch file runs an FTP script that downloads the WinSCP folders to a local drive that then goes through the ETL process.

Complication
Our provider recently updated their FTP site. We were required to update the session in WinSCP. I have updated the session and can log in to the WinSCP session manually (by double-clicking the .bat file from a local box), but when the SQL server agent starts the batch process by running the process task, I get the following error.

Network error: connection timeout to "ftp.hostsite.com" timed out
The server rejected the SFTP connection, but listens for the FTP connections.
Do you want to use the FTP protocol instead of SFTP? I prefer to use encryption.

enter the image description here

Batch file

"\sharedfolderwinscp.exe" compdata /console /script=\sharedFolderDataAppDownloadFlatFile.ftp

DownloadFlatFile.ftp

get /home/*.csv \sharedfileData 
mv /home/*.csv  \sharedfileData
exit```

Here is WinSCP session info.
File protocol: SFTP
Hostname: ftp.site.com
Port number: 22
Username: privateusername
Password: none

Then under advanced settings >> SSH >> Authentication I have the path to the ppk file

8 – Use of the if else statement in Views "FILTER CRITERIA"

I added a field type "isFirst" Boolean to the content type "Publication". I create a block that shows only the the last post that your field (isFirst == true). I want the block to show the last one if no posts field was checked (isFirst). How can you do that with VISTA FILTER CRITERIA?

if we have post with isFirst == true:
show this latest post
plus
show latest post

Java: a simple method with a return statement inside a loop

I am new to programming and would like to know if I will continue looping even if it returns false?

    boolean boardIsFull(char() board){
        for(char mark : board){
            if(mark == EMPTY){ return false; }
        }
        return true;
    }

optimization – Optimize SELECT statement for mysql database

I have this query:

SELECT COUNT(*) AS "Other"
FROM events
JOIN triggers ON events.objectid = triggers.triggerid
WHERE events.name REGEXP "No data from SAM0056(.FTG|.REC|.LEFT|.RIGHT|.BACK), .* offline"
AND events.value = 1 
AND triggers.value = 1;

Altogether I need to execute 32 variants of these queries depending on REGEXP. And I also need to run these queries every 15. So I have a lot of select statements. How can I optimize the database for these queries?

In this case, should I create indexes and on which tables? These are the tables involved (events and triggers):

| Table  | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| events |          0 | PRIMARY  |            1 | eventid     | A         |        7633 |     NULL | NULL   |      | BTREE      |         |               |
| events |          1 | events_1 |            1 | source      | A         |           2 |     NULL | NULL   |      | BTREE      |         |               |
| events |          1 | events_1 |            2 | object      | A         |           2 |     NULL | NULL   |      | BTREE      |         |               |
| events |          1 | events_1 |            3 | objectid    | A         |         954 |     NULL | NULL   |      | BTREE      |         |               |
| events |          1 | events_1 |            4 | clock       | A         |        7633 |     NULL | NULL   |      | BTREE      |         |               |
| events |          1 | events_2 |            1 | source      | A         |           2 |     NULL | NULL   |      | BTREE      |         |               |
| events |          1 | events_2 |            2 | object      | A         |           2 |     NULL | NULL   |      | BTREE      |         |               |
| events |          1 | events_2 |            3 | clock       | A         |        7633 |     NULL | NULL   |      | BTREE      |         |               |
+--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+

Y

| Table    | Non_unique | Key_name   | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+----------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| triggers |          0 | PRIMARY    |            1 | triggerid   | A         |        1826 |     NULL | NULL   |      | BTREE      |         |               |
| triggers |          1 | triggers_1 |            1 | status      | A         |           4 |     NULL | NULL   |      | BTREE      |         |               |
| triggers |          1 | triggers_2 |            1 | value       | A         |           4 |     NULL | NULL   |      | BTREE      |         |               |
| triggers |          1 | triggers_2 |            2 | lastchange  | A         |        1826 |     NULL | NULL   |      | BTREE      |         |               |
| triggers |          1 | triggers_3 |            1 | templateid  | A         |         228 |     NULL | NULL   | YES  | BTREE      |         |               |
+----------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+

I also see some absurd results in my interface for this query, like vb: 264 or 84 or 56. This is not possible if you look at the were clause. Could it be a hardware problem or the database can't keep up with the selections? How can I diagnose these absurd results?

I use mariadb version 10.1.44 in an Ubuntu version 18.04.4.

javascript – Refactor nested & # 39; if & # 39; statement

I have the following deeply nested if statement, is there any way to refactor it in a better way?

if (child.isCriteria) {
    if (child.answer.mark && child.answer.mark != 0) {
        fields.markedCriteria++;
        if (child.answer.mark != -1) {
            fields.markTotal += child.answer.mark * parseInt(child.importance);
        }
    }
    if (child.answer.target && child.answer.target != 0) {
        fields.targetedCriteria++;
        if (child.answer.target != -1) {
            fields.targetTotal += child.answer.target * parseInt(child.importance);
        }
    }
}

MariaDb: right syntax of PREPARE statement for tables of type CONNECT when passing string variable

I run 10.4.12-MariaDB on Windows 10 and use a 64-bit ODBC driver to connect MS Access tables to MariaDB database. I am struggling with the correct syntax of the PREPARE statement for the CONNECT type tables.

Having a table named fff that is ENGINE = CONNECT TABLE_TYPE = ODBC, I try to execute prepared statements on it.
While I have No problem to execute a statement with parameter of type integer:

set @createStr = ("select * from fff where reltpfak = ? ");
prepare theSQL from @createStr ;
set @i = 1;
execute theSQL using @i;
-- works! 

I can't find a correct syntax to pass string variable. My tests lead to a error:

set @createStr = ("select reltpfak from fa where Firma = ? ;");
prepare theSQL from @createStr ;
set @i = "NameOfCompany";
execute theSQL using @i; 

returns Incorrect arguments to EXECUTE .

The same one you just added & # 39; around & # 39 ;?

set @createStr = ("select reltpfak from fa where Firma = '?' ;")
prepare theSQL from @createStr ;
set @i = "NameOfCompany";
execute theSQL using @i

returns Error: Got error 174 'SQLExecDirect: (Microsoft)(ODBC Microsoft Access Driver) Syntax error (missing operator) in query expression 'Firma= NameOfCompany'.' from CONNECT .

What is the correct syntax for the PREPARE statement for tables of type CONNECT when passing the string variable?

postgresql 11: add case statement where clause leads to bad plan choice

We have a lot of procedures that use case declarations in the where clauses; Essentially, we want to run the same procedures at different times, and we set "flags" in the database to change the behavior of the procedures as a function of time, so that we reprocess the least amount of data needed when we execute these procedures. The case statements take those flags into account.

I think it is clear as mud, so let me give an example:
At times, we may want to rebuild the entire contents of a table, so we could run something like

insert into table_a select * from table_b

At other times, we just want to rebuild rows that match certain conditions:

insert into table_a select * from table_b where (business logic)

Queries can get quite complex, and we do this in many different procedures, so it would be bad practice to rewrite all queries for each scenario. So instead we do this:

update flag_table set flag = 't';

then at the top of the procedure we declare a variable:

declare _flag boolean;

. . .

_flag = (select a.flag from from flag_table a);

. . .

insert into table_a select * from table_b where case when _flag then (business logic) end

Obviously, this is a rough approximation of our practices; I also say "procedures", but they are postgres user-defined functions, just to be exhaustive.

The following code recreates the problem that inspired this thread:

drop table if exists t_test; create temp table t_test as
    select  md5(random()::text) as test_text,
            (current_date - (random() * interval '5 years'))::date as date
    from generate_series (1,1000000);

drop table if exists t_sub; create temp table t_sub as
    select * from t_test order by random() limit 100000;

--efficient:
drop table if exists t_result; create temp table t_result as
    select  a.*
    from t_test a
    where   exists
        (
            select 1 from t_sub b where a.test_text = b.test_text and a.date between b.date - interval '6 months' and b.date + interval '6 months'
        );

--inefficient:
drop table if exists t_result; create temp table t_result as
    select  a.*
    from t_test a
    where   case when 1=1 then 
               exists
               (
                   select 1 from t_sub b where a.test_text = b.test_text and a.date between b.date - interval '6 months' and b.date + interval '6 months'
               )
            end;

Here is the query plan for the query labeled efficient:

Hash Semi Join  (cost=7453.88..54133.48 rows=58801 width=36)
  Hash Cond: (a.test_text = b.test_text)
  Join Filter: ((a.date >= (b.date - '6 mons'::interval)) AND (a.date <= (b.date + '6 mons'::interval)))
  ->  Seq Scan on t_test a  (cost=0.00..40086.54 rows=1058418 width=36)
  ->  Hash  (cost=4011.54..4011.54 rows=105918 width=36)
        ->  Seq Scan on t_sub b  (cost=0.00..4011.54 rows=105918 width=36)

Here is the query plan for the query that I have tagged as inefficient:

Seq Scan on t_test a  (cost=0.00..95755427.48 rows=529209 width=36)
  Filter: (SubPlan 1)
  SubPlan 1
    ->  Seq Scan on t_sub b  (cost=0.00..5335.51 rows=59 width=0)
          Filter: ((a.test_text = test_text) AND (a.date >= (date - '6 mons'::interval)) AND (a.date <= (date + '6 mons'::interval)))

The inefficient plan takes forever to execute (I gave up after 30 seconds anyway). In our actual case, we're not actually running this on millions of rows, just 10s of thousands, but due to what I'll call server issues beyond our control, even in our smallest case, the second query took several minutes to complete . So of course my question is, why is a different plan chosen for the second consultation, and is there anything we can do about it?

Please yell at me if I have left something essential; This is just my second question here. Thank you.

combinatorial: how can you write a count if else statement as a mathematical formula?

I want to express the following statement as a formula:

All probability values ​​of $ max (x, y) $ should be counted if and only if they have reached a certain limit value, otherwise the value will not be counted. Therefore, only valid values ​​should be counted. For example, I have the values
begin {matrix}
2 and 3 \
4 and 4 \
5 and 1
end {matrix}

and a limit of (4), that the output should be 66.7% since in the first row neither 2 or 3 is> = 4.

My approach to the part function:

begin {equation}
Coverage = sum ^ n_ {i = 1}
begin {cases}
max (P (x ^ {(i)}), P (x ^ {(j)}) & text {if} & P (x ^ {(i)}) lor P (x ^ {(j )}) geq t in (0.5 … 0.95) \
0 & text {otherwise}
end {cases}
end {equation}

Is this formula correct and how can it be improved?