Inset em duas tabelas diferentes usando procedure MySql

Eu quero inserir um gol na tabela de gols da equipe x, porém quando eu fizer isso a equipe y que ta jogando contra a x deve ter 1 gol inserido na tabela de gols_sofridos.. Alguém pode me da uma luz? Eu creio que meu procedure está muito errado!

DECLARE id_time02, id_time01, id_time1, id_time2;      BEGIN     SELECT E.NOME AS time1, E2.NOME AS time2 FROM tb_partida AS P     INNER JOIN Equipe AS E     ON P.Id_Equipe_1 = E.ID_EQUIPE     INNER JOIN Equipe AS E2     ON P.Id_Equipe_2 = E2.ID_EQUIPE      id_time01 = time1;     id_time02 = time2;     END       if (id_time1 NOT IS NULL)     BEGIN     INSERT INTO tb_gols(Id_Partida, Id_Equipe) VALUES (168,id_time1);     INSERT INTO tb_gols_sofridos(Id_Partida, Id_Equipe) VALUES(168,id_time2);     END      if (id_time2 NOT IS NULL)     BEGIN     INSERT INTO tb_gols(Id_Partida, Id_Equipe) VALUES (168,id_time2);     INSERT INTO tb_gols_sofridos(Id_Partida, Id_Equipe) VALUES (168,id_time1);     END 

How to get date from `DateTime` object returned by stored procedure

I have a datetime object that I am extracting from a datatable returned by a stored procedure called in my Asp.Net app.

DataTable tableInfo = _dtMgr.GetInfoByID(uxGridView.SelectedDataKey.Value.ToString()); tableInfo.Rows[0]["dateOfEvent"]; 

It returns the following: {3/19/2019 10:11:0000 AM}. I am simply trying to get the date ‘3/19/2019’ and have tried the following. No matter what I do, it still returns {3/19/2019 10:11:0000 AM}. Any suggestions?

What I’ve tried:

var dt1 = Convert.ToDateTime(tableInfo.Rows[0]["dateOfEvent"]).Date; //dt1 returns {3/19/2019 10:11:0000 AM} var dt2 = dt1.date //same dt1.Tostring('MM/dd/yyyy'); // too many characters in literal error 

Note: These are all solutions I have seen in similar questions about extracting the date from a datetime object in C#. None of them seem to work.

Solution for “ghost touches” – Procedure to disable a small portion of the screen from being sensitive to touch?

So I ordered a cheap Chinese phone (umidigi) as a secondary device and the unit I got, out of the box, was afflicted with a faulty display. Troubleshooting it I have diagnosed the problem precisely:

  • There is an intermittent false touch input occurring in the bottom right, very far bottom right part only of the screen
  • Lowering the brightness appears to minimize the presence of the false input
  • Is likely to require disassembly of the device to remedy the issue

I alerted the seller I bought the phone from, and they’re sending me a new unit pronto, and told me to just keep this one. Yay.

So, Id like to eventually permanently resolve this phones issue and open it up myself, but in the meantime I’d like to get some use out of it. But, with the ghost touch using the phone with anything other than a Bluetooth mouse is maddening.

The area effected is at the very, very bottom of the phone and may occupy 15px or so at most. I attempted to use a few apps, one called ‘Partial Screen’ and some others like Screen Shift. However, the adjustments to the display only result in cosmetic changes and do not desensitize the adjusted portion of the screen to touch input and thus the false input creating problems.

Can anyone point me to a procedure, adb input or otherwise, that could ensure that some specified portion of the touch screen will not respect any touch input?

Thanks.

Why more ways to stop services? How is the correct procedure to do it? [on hold]

I’m currently using Ubuntu 18.04:

I found that for disable a service I can do:

systemctl disable ServiceName

but some times it works also this:

update-rc.d ServiceName disable

So what is the best way to disable a service? Can you explain or link some tutorials that explain what is the best secure way to disable a service?

Thank you very very much for your work

Ale

show SET variable from procedure mysql with if else statement

How to showing variable SET HasilBKD from procedure in tabel.
Only aliases appear in the table, like (AS Syt_Pendidikan, Pendidikan_Prodi etc…).
But the variable(HasilBKD) in if and else does not appear.
Please help How can I solve this? data in tabel like this, but nothing HasilBKD.
Here is example table.

enter image description here
And here is code:

CREATE DEFINER=`root`@`localhost` PROCEDURE  `hasil_approval_verifikator`(nip varchar(30)) BEGIN DECLARE Pendidikan FLOAT; DECLARE Penelitian FLOAT; DECLARE Pengabdian FLOAT; DECLARE Penunjang FLOAT; DECLARE Points FLOAT; DECLARE SumBKD FLOAT; DECLARE SyaratBKD FLOAT; DECLARE HasilBKD varchar(30); SELECT  a.nip,b.nama_peg,c.id_kat_dosen, MAX(CASE WHEN d.id_bkd = 1 THEN d.sks_bkd ELSE 0 END) AS Syt_Pendidikan, MAX(CASE WHEN d.id_bkd = 2 THEN d.sks_bkd ELSE 0 END) AS Syt_Penelitian, MAX(CASE WHEN d.id_bkd = 3 THEN d.sks_bkd ELSE 0 END) AS Syt_Pengabdian, MAX(CASE WHEN d.id_bkd = 4 THEN d.sks_bkd ELSE 0 END) AS Syt_Penunjang,    FORMAT(SUM(CASE WHEN a.id_bkd = 1 AND a.applaporan_ketuaprodi=1 THEN  a.sks_subkegiatan/8 END),2) AS Pendidikan_Prodi, FORMAT(SUM(CASE WHEN a.id_bkd = 2 AND a.applaporan_ketuaprodi=1 THEN  a.sks_subkegiatan/8 END),2) AS Penelitian_Prodi, FORMAT(SUM(CASE WHEN a.id_bkd = 3 AND a.applaporan_ketuaprodi=1 THEN  a.sks_subkegiatan/8 END),2) AS Pengabdian_Prodi, FORMAT(SUM(CASE WHEN a.id_bkd = 4 AND a.applaporan_ketuaprodi=1 THEN  a.sks_subkegiatan/8 END),2) AS Penunjang_Prodi, FORMAT(SUM(CASE WHEN a.id_bkd IN (1,4) AND a.applaporan_ketuaprodi=1 THEN  a.poin_subkegiatan/8 END),2) AS Points_Prodi, FORMAT(SUM(CASE WHEN a.id_bkd = 1 AND a.app_assesor1=1 AND  a.app_assesor2=1 THEN a.sks_subkegiatan/8 END),2) AS Pendidikan_As1, FORMAT(SUM(CASE WHEN a.id_bkd = 2 AND a.app_assesor1=1 AND  a.app_assesor2=1 THEN a.sks_subkegiatan/8 END),2) AS Penelitian_As1, FORMAT(SUM(CASE WHEN a.id_bkd = 3 AND a.app_assesor1=1 AND  a.app_assesor2=1 THEN a.sks_subkegiatan/8 END),2) AS Pengabdian_As1, FORMAT(SUM(CASE WHEN a.id_bkd = 4 AND a.app_assesor1=1 AND  a.app_assesor2=1 THEN a.sks_subkegiatan/8 END),2) AS Penunjang_As1, FORMAT(SUM(CASE WHEN a.id_bkd IN (1,4) AND a.app_assesor1=1 AND  a.app_assesor2=1 THEN a.poin_subkegiatan/8 END),2) AS Points_As1 FROM bkd_subkegiatan_laporan a JOIN tb_pegawai b on a.nip=b.nip JOIN profil_dosen c on a.nip=c.nip JOIN bkd_remun_dosen d on c.id_kat_dosen=d.id_kat_dosen JOIN periode_lkd e on a.id_periode=e.id_periode WHERE e.status = 1 AND a.nip=nip; IF (c.id_kat_dosen = 3 or c.id_kat_dosen = 7 or c.id_kat_dosen = 9) THEN  SET SyaratBKD = Syt_Penelitian+4; SET Pendidikan = Pendidikan_Prodi+Pendidikan_As1; SET Penelitian = Penelitian_Prodi+Penelitian_As1; SET Pengabdian = Pengabdian_Prodi+Pengabdian_As1; SET Penunjang  = Penunjang_Prodi+Penunjang_As1; SET Points     = Points_Prodi+Points_As1; SET SumBKD     = Pendidikan+Penelitian+Pengabdian+Penunjang IF (Pendidikan>=Syt_Pendidikan and Penelitian>=Syt_Penelitian and  Pengabdian>=Syt_Pengabdian and SumBKD>=12) THEN SET HasilBKD = 'OK'; ELSE     SET HasilBKD = 'NOT OK'; END IF; ELSEIF (c.id_kat_dosen = 1 or c.id_kat_dosen = 2 or c.id_kat_dosen = 4) THEN SET SyaratBKD = Syt_Penelitian+4; SET Pendidikan = Pendidikan_Prodi+Pendidikan_As1; SET Penelitian = Penelitian_Prodi+Penelitian_As1; SET Pengabdian = Pengabdian_Prodi+Pengabdian_As1; SET Penunjang  = Penunjang_Prodi+Penunjang_As1; SET Points     = Points_Prodi+Points_As1; SET SumBKD     = Pendidikan+Penelitian+Pengabdian+Penunjang; IF (Pendidikan>=Syt_Pendidikan) THEN SET HasilBKD = 'OK'; ELSE     SET HasilBKD = 'NOT OK'; END IF; ELSE SET HasilBKD = 'id not available'; END IF; END 

How to write stored procedure in Drupal 8

I have used stored procedure in Drupal 7 like this and this is working fine:

<?php  public function store_process($  db_name, $  var1, $  var2, $  var3, $  var4, $  var5) {     // Connect other database.     db_set_active('other_db');      $  conn = Database::getConnection();     $  saved_class = $  conn->getAttribute(PDO::ATTR_STATEMENT_CLASS);     $  conn->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('PDOStatement'));     // Prepare the statement and bind params.     $  statement = $  conn->prepare("Call " . $  db_name . "(?,?,?,?,?)");      $  op_status = $  statement->bindParam(1, $  var1, \PDO::PARAM_STR | \PDO::PARAM_INPUT_OUTPUT, 10);     $  op_status = $  statement->bindParam(2, $  var2, \PDO::PARAM_INT | \PDO::PARAM_INPUT_OUTPUT);     $  op_status = $  statement->bindParam(3, $  var3, \PDO::PARAM_INT | \PDO::PARAM_INPUT_OUTPUT);     $  op_status = $  statement->bindParam(4, $  var4, \PDO::PARAM_INT | \PDO::PARAM_INPUT_OUTPUT);     $  op_status = $  statement->bindParam(5, $  var5, \PDO::PARAM_INT | \PDO::PARAM_INPUT_OUTPUT);      // Execute the statement and reset the connection's statement class to the original.     $  exec_result = $  statement->execute();     //$  conn->setAttribute(PDO::ATTR_STATEMENT_CLASS, $  saved_class);     while ($  row = $  statement->fetchObject()) {         $  result[] = $  row;     }     db_set_active('default');      return $  result; } 

But in Drupal 8 it is giving error:

 Invalid parameter number: no parameters were bound in Drupal\Pathoffunction (line 102 of Path of File) 

My Drupal 8 Conversion of above query is:

<?php  public function store_process($  db_name, $  var1, $  var2, $  var3, $  var4, $  var5) { // Connect other database. db_set_active('other_db');  $  conn = \Drupal\Core\Database\Database::getConnection() $  statement = $  conn->prepare("Call " . $  db_name . "(?,?,?,?,?)");  $  op_status = $  statement->bindParam(1, $  var1, \PDO::PARAM_STR | \PDO::PARAM_INPUT_OUTPUT, 10); $  op_status = $  statement->bindParam(2, $  var2, \PDO::PARAM_INT | \PDO::PARAM_INPUT_OUTPUT); $  op_status = $  statement->bindParam(3, $  var3, \PDO::PARAM_INT | \PDO::PARAM_INPUT_OUTPUT); $  op_status = $  statement->bindParam(4, $  var4, \PDO::PARAM_INT | \PDO::PARAM_INPUT_OUTPUT); $  op_status = $  statement->bindParam(5, $  var5, \PDO::PARAM_INT | \PDO::PARAM_INPUT_OUTPUT);  // Execute the statement and reset the connection's statement class to the original. $  exec_result = $  statement->execute(); //$  conn->setAttribute(PDO::ATTR_STATEMENT_CLASS, $  saved_class); while ($  row = $  statement->fetchObject()) {     $  result[] = $  row; } db_set_active('default');  return $  result; } 

Explanation of the authentication procedure when using signed certificates

I am using AWS IoT with X.509 self-signed certificates for authentication. To communicate with the cloud I use MQTT.

On my device side, I have a device certificate ( deviceCert.crt ) and the device certificate private key ( deviceCert.key ) , and also the root CA certificate from Amazon (root-CA.crt)

The device certificate is of course already registered on the AWS cloud.

I realize when using an MQTT client on the device that it requires the device to contain both the device certificate and the device private key during authentication.

Why isn’t the private key enough to have on the device? My guess was that the device would sign something with the device private key , and on the server end, it would use the public key from the device certificate (already stored there) to verify the signature.

Or does the device send the device certificate to the server and the server compares it with the one it has stored?

What happens exactly here?

SELECT dentro de variável em PROCEDURE

Não estou conseguindo colocar o resultado de um select dentro de uma variável.

Quero acrescentar a coluna turno dentro do meu WHERE. O problema é que recebo o valor de @turnos nos 3 seguintes formatos:

1 – 'A'

2 – 'A','B'

3 – 'A','B','C'

Situação atual

@tjt = (select sum(duracao) from tabela where fabrica = @fabrica) 

Situação desejada (com erro)

@tjt= (select sum(duracao) from tabela where fabrica = @fabrica and turno IN (@turnos)) 

Já vi que turno IN (@turnos) não funciona, e por isso tentei colocar o select todo entre aspas concatenando as variáveis da seguinte maneira:

@query = '(select sum(duracao) from tabela where fabrica = '+@fabrica+' and turno IN ('+@turnos+'))' 

Mas ainda não entendi como fazer para colocar o resultado dessa @query na variavel @tjt.