## SQL Server – Difference in location of the transaction isolation level statement – inside / outside a transaction?

I have reviewed some stored procedures on our system today when I saw the following structure:

(pseudocode indicating the actual SP, the server uses the default isolation level):

``````CREATE A PROCEDURE ...
AS
TO START
IF NOT EXISTING (SELECT ...)
TO START
RETURN;
END

START TRAN
ADJUST THE LEVEL OF ISOLATION OF SERIOUS TRANSACTIONS;

DML ...
DML ...
DML ...
COMMIT
END
``````

I have not seen the level of transaction isolation declared in the interior a transaction boundary and wondered what was the effect?

Is the isolation level restored once the transaction is committed (thus, if there were additional instructions after validation, what would be their isolation level)?

In this case, I suppose there would be no difference if the isolation level had to be declared just before the start of the transaction. Is that the case?

Most of the time, I was somewhat surprised to see this because I had never seen the isolation of a transaction declared outside of a transaction, not at all. inside and I was wondering – why? What are the benefits of doing it?

## java – How to give this statement if-else a taste of kotlin?

This piece of code looks more like Java than Kotlin. Can I make improvements to make it look more Kotlin than Java?

``````fun receive (message: SentEmailMessage, messageHeader: MessageHeaders) {
val date = OffsetDateTime.ofInstant (Instant.ofEpochMilli (longValue), ZoneId.systemDefault ())
message.messageTime = date

val templateEntity = templateService.findByName (message.templateName)

if (templateEntity! = null) {
dataService.save (Data.toEntity (message, templateEntity))
} other {
templateService.save (TemplateEntity (name = message.templateName)). also {
dataService.save (Data.toEntity (message, it))
}
}
``````

## Number Theory – Is it possible to obtain an interesting statement about even perfect numbers from the equation \$ 1 / operatorname {rad} (n) = 1 / 2-2 varphi (n) / sigma (n) \$?

It is well known that the problem concerning even perfect numbers is to prove or disprove whether they are infinitely numerous. A few weeks ago, I wrote the following conjecture: $$varphi (n)$$ denotes the total function of Euler, $$sigma (n) = sum_ {1 leq d mid n} d$$ the sum of the divisors and $$operatorname {rad} (n) = prod _ { substack {p mid n \ p text {prime}}} p$$
is the product of the division of distinct prime numbers $$n> 1$$ with the definition $$operatorname {rad} (1) = 1$$, see the Radical Wikipedia of an integer.

The total function of Euler and the sum of the divisors can be found in formulas of equivalence to the Riemann hypothesis, and the radical of an integer is the famous arithmetic function that appears in the formulation of the conjecture abc.

Conjecture. An integer $$n geq 1$$ is an even number if and only if
$$operatorname {rad} (n) = frac {1} { frac {1} {2} -2 frac { varphi (n)} { sigma (n)}}. tag {1}$$

I quoted this conjecture a few days ago in MSE. My intention is to know if it is possible to obtain a statement on the problem of even perfect nubmers, if there is an infinity of them, using the equation or if you can argue that it seems that the equation $$(1)$$ is not useful for this purpose.

Question. Is it possible to get an interesting statement about the infinitude of even perfect numbers, or a fact about their distribution, using this equation $$(1)$$ or invoke previous Conjecture (It's easy to prove that even perfect numbers $$n$$ satisfy, but my proof attempt for the other part of the conjecture failed)? If you think this is not possible for an obstruction, please explain it. Thank you so much.

You can invoke propositions about perfect numbers, tools or conjectures from the analytic number theory (we can search for and read these statements in the literature). I hope this is a nice exercise for this site, in any case I hope comments.

## postgresql – Control the state of a long-running COPY statement

I need to migrate a table from one PostgreSQL database to another. It was possible that I needed to fix some data. I have therefore exported to CSV format. Then I imported the CSV file into the second database with `COPY` declaration.

This process has been running for 5 days now. The only way I found to watch his progress was to compare the sizes on the disc. The original table was 95 GB (after psql's ` dt +`), and the CSV was 40 GB. So I thought I could compare the new size of the table to these numbers. I thought the new table would stop at 95 GB or even before. Instead, he is now at 103 GB and who knows when he is going to stop.

Of course, `select the account (*)` does not work because the copy occurs in its own transaction, so that the lines are protected until the operation is complete. But I know that the table has about 1500 million lines. So, if I could get an estimate of the number of lines currently in the new chart, I could compare.

## node.js – How to insert a value into a select statement with the help of JavaScript, especially when using express and postgres?

How to insert a value in a select statement with the help of JavaScript, especially when using express and postgres?

CreateUser and listAllUsers work (included below for reference). The test / capture works and satisfies the request or returns the error for those two as well.

Any help would be greatly appreciated!

When using Postman, the result I get when I send the object get (localhost: 4000 / user / id with a key value x-www-formurlencoded, user_id = 3) is…

``````{
"name": "error",
"length": 90,
"severity": "ERROR",
"code": "42601",
"position": "37",
"file": "scan.l",
"line": "1134",
"routine": "scanner_yyerror"
}
``````

And in the terminal, it shows the following (trapped in my console.log).

``````3
QUERY: SELECT * FROM users WHERE user_id = \$ {user_id}
``````

When I loop user, he says the same thing in the terminal. Here is the command curl and putput …

``````curl -X GET localhost: 4000 / user / 3
``````

{"name": "error", "length": 90, "severity": "ERROR", "code": "42601", "position": "37", "file": "scan.l", " line ":" 1134 "," routine ":" scanner_yyerror "} ww10sc2353621: ~ james.mcgregor \$ curl -X localhost GET: 4000 / user / 3

In the end, the 3 that I pass as user_id is not substituted in the select statement. That's my problem. I can not understand how to do this properly. Should I even adopt this approach or should I try to pass it as a parameter in the URL?

``````const db = require (& # 39; ../ connectors / db.js & # 39;);
User class {

constructor (id, user_id, firstname, middle_initial, last_name, email, type) {
this.id = id;
this.first_name = firstname;
this.middle_initial = middle_initial;
this.last_name = last_name;
this.email = email;
this.type = type;
this.user_id = user_id;
}

static newUser (user_id, firstname, middle_initial, last_name, email, type) {
returns db.one (`
INSERT INTO users ("user_id", "firstname", "middle_initial", "last_name", "email", "type")
VALUES (& # 39; \$ {user_id} & # 39;; & # 39; \$ {firstname} & # 39; \$ {middle_initial} & # 39; \$ {last_name} & # 39; \$ {email} & # 39;; & # 39; \$ {type} & # 39;)
Return ID
`)
}

static async allUsers () {
const findAllQuery = SELECT * FROM users; & # 39 ;;
return db.query (findAllQuery)
}

static async selectUser (user_id) {
console.log (user_id);
const findOneQuery = SELECT * FROM users WHERE user_id = \$ {user_id} & # 39 ;;
return db.query (findOneQuery)
}
}

module.exports = User;
``````
``````const express = require (& # 39;);
const dataFunctions = require (& # 39; ./ catalog.js & # 39;);

const AppRouter = express.Router ();

AppRouter.post (& # 39; / user & # 39 ;, dataFunctions.createUser);
AppRouter.get (& # 39; / users & # 39 ;, dataFunctions.listAllUsers);
AppRouter.get (& # 39; / user /: id, dataFunctions.listUserByUserID);
AppRouter.delete (& # 39; / user /: id, dataFunctions.deleteUserByUserID);

module.exports = AppRouter;
``````
``````const Users = require (& # 39; ../models/users.js & # 39;)

// Create

Async function. createUser (req, res) {
try {
console.log (req.body);
const userId = wait Users.newUser (req.body.user_id, req.body.first_name, req.body.middle_initial, req.body.last_name, req.body.email, req.body.type)
res.status (201) .send (`user ID: \$ {userId.id}`);
} catch (error) {
res.status (400) .send (error);
}
}

// List All

async function listAllUsers (req, res) {
try {
const userList = wait Users.allUsers ();
console.log (userList);
res.status (200) .send (userList);
} catch (error) {
res.status (400) .send (error);
}
}

// List by ID

function async listUserByUserID (req, res) {
try {
const userList = wait Users.selectUser (req.body.user_id);
console.log (userList);
res.status (200) .send (userList);
} catch (error) {
res.status (400) .send (error);
}
}

module.exports = {
Create a user,
listAllUsers,
listUserByUserID
}
``````

## google sheets – The Else statement is running when TRUE

I am completely new to coding. I am a teacher and I am trying to design a course planning tool with the help of Google Sheets scripts. The idea is to have a template sheet for the lesson that will be copied to a new tab. This part works well. However, to delete the lesson, I want to prevent any accidental deletion of the model. It manages not to delete the template's tab if you click on "Delete lesson".

However, it displays the alert that you can not delete the template for other tabs (but delete it as needed). This is the document.

Any help is greatly appreciated!

I used this code at the beginning:

``````DeleteTab1 function () {
var sheet = worksheet.getActiveSheet ();
var sheetname = sheet.getName ();

if (sheetname! = "Template") {

}

other {
SpreadsheetApp.getUi (). Alert ('The template can not be deleted');
}
}
``````

So I tried this and had the same problem:

``````DeleteTab1 function () {

var sheet = worksheet.getActiveSheet ();
var sheetname = sheet.getName ();

if (sheetname! = "Template") {

}

if (sheetname = "Template") {
SpreadsheetApp.getUi (). Alert ('The template can not be deleted');
}

}
``````

## SQL Server – WHERE statement on an inner join with GROUP BY

I need help with the underside. Essentially, I enter all the lines that correspond to certain parameters (corresponding itemid, custaccount, qtyordered). I also need to add a where statement to my inner join, that is, where b.salesstatus in "3," & # 39; 4 & # 39;. The problem I have is that I can not select the sales status in my internal join unless also grouping by sales status? How can I add a where statement for the inner join that will be acceptable?

``````TO SELECT
ST.DATAAREAID
, ST.CREATEDDATETIME
, ST.SALESID
, ST.SALESNAME
, SL.ITEMID
, SL.CUSTACCOUNT
, SL.QTYORDERED
, SL.SALESQTY
, SL.LINEAMOUNT
, SL.CUSTOMERREF
, ST.SALESPOOLID
, ST.RETURNITEMNUM
, CASE WHEN CONVERT (nvarchar (12), SL.SAB_PICKINGSTATUS) = & # 39; 1 & # 39; THEN & # 39; Confirmed & # 39; WHEN CONVERT (nvarchar (12), SL.SAB_PICKINGSTATUS) = & # 39; 2 & # 39; THEN & # 39; confirmed & # 39; WHEN & # 39; CONVERT (nvarchar (12), SL.SAB_PICKINGSTATUS) = = 2 SL.SAB_PICKINGSTATUS = 0 & # 39; THEN & # 39; OpenOrder & # 39; ELSE & # 39; UNKNOWN & # 39; END AS PickStatus
, WHEN CONVERT CASE (nvarchar (12), SL.SALESSTATUS) = & # 39; 1 & # 39; THEN & # 39; OpenOrder & # 39; WHEN CONVERT (nvarchar (12), SL.SALESSTATUS) = & # 39; 3 & # 39; THEN & # 39; invoiced & # 39; WHEN CONVERT (nvarchar (12), SL.SALESSTATUS) = & # 39; 4 & # 39; THEN & # 39; canceled & # 39; ELSE & # 39; UNKNOWN & # 39; END AS LineStatus
DE dbo.SALESLINE AS SL
INNER JOIN dbo.SALESTABLE AS ST
ON SL.SALESID = ST.SALESID
AND SL.DATAAREAID = ST.DATAAREAID
INNER JOIN dbo.INVENTTABLE ON SL.ITEMID = dbo.INVENTTABLE.ITEMID
AND ST.DATAAREAID = dbo.INVENTTABLE.DATAAREAID
INTERNAL JOINTING (
TO SELECT
LINE.ITEMID
, LINE.CUSTACCOUNT
, LINE.QTYORDERED
FROM dbo.SALESLINE AS LINE
INNER JOIN dbo.SALESTABLE AS STABLE
ON LINE.SALESID = STABLE.SALESID
AND LINE.DATAAREAID = STABLE.DATAAREAID
BY GROUP
LINE.CUSTACCOUNT
, LINE.QTYORDERED
, LINE.ITEMID
ACCOUNT HELD (*)> 1
) AS B
ON B.CUSTACCOUNT = SL.CUSTACCOUNT
AND B.QTYORDERED = SL.QTYORDERED
AND B.ITEMID = SL.ITEMID
** strong text ** WHERE (SL.CREATEDDATETIME> = 2019-01-01 00: 00: 00 & # 39;) AND (SL.SALESSTATUS! = & # 39;) & (SL) .CUSTACCOUNT NOT IN (2ALD217) AND (SL.ITEMID NOT IN (15MEGA, 15TACK, 10MEGA & # 10; 39 ;, NOT 10TACK & # 39;)) AND (NOT (dbo.INVENTTABLE.SAB_INVENTCLASSGROUPID IN (NO CATBRO & # 39 ;, LOADS & # 39;), N & # 39; KIPLREG & , "MERCH", "POS", "SAMPLES", "SWAFLD" AND "SL.QTYORDERED" 1) AND (SL.CUSTOMERREF NOT IN (N & # 39;)) AND (ST.SALESPOOLID NOT IN (N & # 39; POSE, # DISP, # 39) INTC & # 39;))
``````

## magento2.3 – Error Statement Magento 2.3.2 XML allowed only at the beginning of the document

I need a program for (webwinkelfacturen.nl) read my rates so that I can be pushed into an accounting system. But I get this error when I want to call domainname / ndex.php / rest / V1 / taxRates. I receive this error:

error on row 2 of column 6: XML declaration allowed only at the beginning of the document
The following is a rendering of the page at the first error.

The program uses this to obtain tax rates:

https://www.bakmina.com/index.php/rest/V1/taxRates/search?searchCriteria%5Bpage_size%5D=100

And that gives the same error. What is it? And how can I FIX?

## Is it worth using the if-else statement as an optional Java template?

I got to a point by rebilling using `if not {}` code with Java options. When optimizing the code, the result is as follows:

``````Optional.of (myBoolean) .filter (b -> b) .ifPresent (b -> {/ * my code if true * /});
``````

I recognized `filter (b -> b)` is not the way I wanted to use the optional ones so I turned to

``````If.is (myBoolean) .then (b -> {/ * my code if true * /}). OrElse (b -> {/ * my code if false * /});
``````

The code for the `If.class` is

``````public class If {

private boolean isTrue;

public If (final Boolean value) {
isTrue = value;
}

public If then (final consumer s) {
if (isTrue) {
s.accept (null);
}
return this;
}

public null orElse (final consumer) {
if (! isTrue) {
s.accept (null);
}
}

static public If is (final Boolean value) {
returns a new If (value);
}
}
``````

Is it a good approach (whatever it is or should be) using the `if not {}` declaration in Java?

## ACF repeater field, IF statement needed if the subfield has content

As noted in the ACF documentation, to search for a value before displaying it, simply use:

``````
My field value:

``````

So in your case, you already get the subfield in `\$ instruction`, just use this:

``````    if (\$ statement):
``````