Posts by Sorack • 27,430 points
864 posts
-
1
votes3
answers70
viewsA: SQL with two different information
You can transfer the conditions that are on WHERE for a CASE within the COUNT and thus count only the status you want for each column: SELECT COUNT(CASE WHEN status IN (3, 13) THEN 1 ELSE NULL END)…
-
0
votes2
answers1815
viewsA: Download files in API Restfull Nodejs
If you do not need any validation to access the files you can just serve the files statically. To do this add in your file Server.js the following lines: const path = require('path'); // ...…
-
1
votes1
answer27
views -
3
votes1
answer39
viewsA: How to make this condition correctly in Mysql?
First you don’t need the condition filiados.`Filiado_MatriculaEmpresa` = filiados.`Filiado_MatriculaEmpresa` because his GROUP BY filiados.`Filiado_MatriculaEmpresa` Already groups all records with…
-
3
votes1
answer525
viewsA: Inner Join in Procedure
The message: Mensagem 201, Nível 16, Estado 4, Procedimento sp_select_produto, Linha 225 O procedimento ou a função 'sp_select_produto' espera o parâmetro '@id_prato', que não foi fornecido.…
-
1
votes2
answers61
viewsA: Calling an object of an array by the index in a loop
Your object does not appear to be an array, since it has named attributes. Therefore to be able to stream it you will need to get your keys with the Object.keys or its values with Object.values and…
javascriptanswered Sorack 27,430 -
3
votes1
answer505
viewsA: Convert sum of minutes to hours format (eg 70min = 01:10) with jquery
You can create a function that will receive the value in minutes, will use the function Math.floor to remove the entire part and a mod (operator %) to get the rest of the split by 60: const…
-
0
votes2
answers92
viewsA: Error doing Insert in BD SQL using JDBC
The error says: com.microsoft.sqlserver.jdbc.SQLServerException: Conversion failed when converting date and/or time from character string. Or in free translation: Conversão falhou ao converter data…
-
1
votes3
answers1324
viewsA: Select records from one record to another in sql server
The syntax OFFSET/FETCH NEXT is only available from SQL Server 2012. Instead of using it, create a query which will return all your data together with the function ROW_NUMBER which will assign a…
-
1
votes2
answers936
views -
1
votes1
answer240
viewsA: Request returning Cannot PUT with express
You’re making the call http://localhost:3000/todos/5c7b50cb4a73110d68704251 in the plural but defined the route in the singular. Change the creation of the route to: routes.put('/todos/:id',…
-
1
votes1
answer57
viewsA: Changing tags automatically
You can use a function that extracts the parameters and replaces the respective values as the following: // Substitui na String de texto a assinatura entre "{}" pelo valor no objeto const repor =…
-
0
votes3
answers240
viewsA: Randomly choose files in Nodejs
Use the function fs.readdirSync to read the contents of the directory and Filtre by the file extension. After this select a random record with the function Math.random together with the Math.floor:…
-
2
votes1
answer28
viewsA: Sum of values in Mysql
Use the GROUP BY together with a COUNT conditional. SELECT COUNT(CASE examefuncionario.examefunc_natureza WHEN 'A' THEN 1 ELSE NULL END) AS A, COUNT(CASE examefuncionario.examefunc_natureza WHEN 'D'…
-
0
votes1
answer49
viewsA: Exception in thread "main" in String array
Your code has some problems, among which: The stopping condition of the while is that the value inserted is equal to 0, but the value is only reported before the loop. So the loop will never end;…
-
2
votes1
answer55
viewsA: Does document.links take all links from the website?
According to the documentation, all elements <a> with href defined are listed by the function Document.links. Document.links The links read-only Property of the Document interface Returns a…
-
2
votes1
answer1424
viewsA: Oracle SQL Developer Table Creation
You should create tables that are used as references in foreign keys first. I suggest the following order: CREATE TABLE situacao ( Id_Situacao INTEGER NOT NULL, Situacao VARCHAR(10) NOT NULL,…
-
2
votes1
answer882
viewsA: How to read a local txt file in Javascript
To request a module on Node use the require: const fs = require('fs'); And to read the file use the function readFile or readFileSync: fs.readFile('<diretório>', (err, data) => { // =>…
-
2
votes2
answers171
viewsA: Select within select where condition exists
Considering the following structure: CREATE TABLE artigos ( referencia VARCHAR(1), quantidade INTEGER, preco NUMERIC(15, 2) ); INSERT INTO artigos(referencia, quantidade, preco) VALUES ('X', 2,…
-
2
votes1
answer75
viewsA: Asynchronous mysql queries in nodejs
You can cuddle in a array of promises and then use the Promise.all to run them in parallel with the await to await the execution of all: // ... const promessas = [ sql_op.select(null, targets,…
-
11
votes4
answers1103
viewsA: What is the Kubernetes?
According to the manufacturer’s own website, Kubernetes is a system to automate the deployment, scalability and management of containerized applications. What is the purpose and benefit of using…
-
1
votes1
answer37
viewsA: Control the data that Mysql sends to Nodejs
The first amendment that will be required is to declare a parameter of the type OUT in his PROCEDURE: -- ... CREATE PROCEDURE clone_quote_and_products(IN quoteID INT, IN editedClone TINYINT(1), OUT…
-
1
votes1
answer58
viewsA: split(" ") in String " Java Essential " generates 3 tokens. Why?
You have spaces at the beginning and end of String. To get the result you want (In case 2 pieces) you must use the method trim before performing the split: String[] ss = s.trim().split(" "); This…
-
1
votes1
answer30
viewsA: Show HTML only from a div
You can achieve this using the function Document.querySelector() to get the element you want the source code from and then the attribute Element.outerHTML to get the desired information. In the…
-
6
votes2
answers101
viewsA: Limit typed number
You can do it directly at the event onchange field. In the example below the value will be changed to the limits if they are exceeded: <input type="number" min="1" max="25" class="form-control"…
-
6
votes2
answers2885
viewsA: Retry Case Gives Timeout with Axios
I created my own function to retry: const axios = require('axios'); /** * Waits a determined time to fulfill a Promise * * @param {number} ms - The milliseconds to fulfill the Promise * * @returns…
-
2
votes1
answer32
viewsA: Scan 4 selects and display message
SELECT 'ABC' WHERE EXISTS(SELECT 1 FROM tblA) OR EXISTS(SELECT 1 FROM tblB) OR EXISTS(SELECT 1 FROM tblC) OR EXISTS(SELECT 1 FROM tblD)…
-
2
votes1
answer695
viewsA: SELECT within variable in PROCEDURE
You can use the SP_EXECUTESQL with a parameter OUTPUT to obtain the desired result: DECLARE @tjt INT; DECLARE @query NVARCHAR(MAX); SET @query = '(select @tjt = sum(duracao) from tabela where…
-
0
votes1
answer88
viewsA: Filter empty or null value in JSP file using SQL
You can use a OR together with the AND: SELECT * FROM tabela t WHERE (:condicao1 = '' OR t.condicao1 = :condicao1) AND (:condicao2 = '' OR t.condicao2 = :condicao2) Just don’t forget to isolate the…
-
7
votes3
answers689
viewsA: Convert nested loops to recursive function to compute combinations
You can use the recursion to pass the last parameter array generated until reaching the desired size: const montar = (opcoes, calculado = []) => { // Verifica o critério de parada, que neste caso…
-
1
votes2
answers240
viewsA: Compare a field in the same table
So you will bring all the codes you must delete: SELECT c1.* FROM CADCLI c1, CADCLI c2 WHERE c1.CODIGO > c2.CODIGO AND c1.CNPJ = c2.CNPJ;
-
6
votes2
answers3945
viewsA: Javascript usage of ${variable}
The name of this resource is Template string. Template String Template literals are string literals that allow embedded expressions. You can use multi-line string and string interpolation with them.…
-
0
votes2
answers4491
viewsA: Query Search Specific Word in a Field - SQL Server
If the text follows this pattern you can do a search with the LIKE: SELECT t.* FROM tabela t WHERE t.descricao LIKE '%, validade %2019%, dívida%';
-
1
votes1
answer16
viewsA: End of file, incorrect SQL SERVER syntax
You created a WITH without using for anything in your code. The WITH only groups the information in the alias that you’ve determined, what to do with her determines you: WITH subresults AS ( -- ...…
-
3
votes1
answer32
viewsA: Refer to a table by entering "" in Oracle number field
SELECT a.ds_endereco, '"' || TO_CHAR(a.nr_endereco) || '"', a.nm_bairro, c.nm_cidade, c.cd_uf, a.nr_cep, A.nr_fone, a.nr_celular FROM paciente A, cidade c WHERE a.cd_cidade = c.cd_cidade AND…
-
5
votes5
answers9010
viewsA: How do I multiply an array within a function in JS?
The array has a function reduce that returns a single value according to the existing elements. reduce The method reduce() performs a function reducer (provided by you) for each member of the array,…
-
1
votes1
answer365
views -
4
votes3
answers1018
viewsA: Convert to date type 'yyyy-mm-dd'
SELECT CONVERT(char(10), GETDATE(), 126); Set size 10 separates time from date. In the link below CAST and CONVERT (Transact-SQL) - Date and time styles from the documentation you can check the…
-
0
votes1
answer52
viewsA: json Object in array this with java error
If you’re getting one array ([]) you should turn into a list: Type tipo = new TypeToken<ArrayList<ItensPedido>>(){}.getType(); List<ItensPedido> lista = (new…
-
1
votes3
answers60
viewsA: Javascript - Show function result in class
You can use the event onload: function getData() { var today = new Date(); var dd = today.getDate(); var mm = today.getMonth() + 1; //January is 0! var yyyy = today.getFullYear(); if (dd < 10) {…
-
1
votes1
answer415
viewsA: Loading before displaying content
You can use the option loading ofHighcharts with a CSS personalized: var chart = new Highcharts.Chart({ // ... loading: { labelStyle: { backgroundImage: 'url("http://jsfiddle.net/img/logo.png")',…
-
0
votes1
answer65
viewsA: Calculating values in column
You just need to create a function that totals and then call it in your template: $scope.totalizar = function(){ var total = 0.0; for(var i = 0; i < $scope.result.length; i++){ var output =…
-
1
votes4
answers84
viewsA: How to do a sequential for with nodejs version 8?
The operator await, which was added in the ES6, serves to simplify the chain of promises, which is what you specified. await The operator await is used to wait for a Promise. It can be used only…
-
2
votes1
answer445
views -
2
votes2
answers613
views -
1
votes3
answers133
viewsA: SUM of one table minus the SUM of another in the same field
Use the clause HAVING to filter the results you want (With the remaining output greater than 0): SELECT f.docnum AS Doc, f.clienteid AS Cliente, f.valor AS ValorDocumento, f.valor -…
-
1
votes1
answer108
viewsA: Input returns string,
I didn’t evaluate your code, but with parseInt worked the way it apparently should. const num_1 = document.querySelector("#num_1"); const num_2 = document.querySelector("#num_2"); const num_3 =…
-
2
votes1
answer418
viewsA: Help with a PIVOT ( Sql Server )
You did not correctly state what the SGBD used, did not inform the structure of the tables and did not say if the types vary or if they are fixed. I used the following structure to MySQL but it will…
-
3
votes1
answer66
viewsA: Incomplete sum with JOINS in Mysql
Just link the tables by id_balanco and use a GROUP BY for the month and year using the SUM to sum the values of each table: SELECT DATE_FORMAT(b.data,'%m-%Y') AS mes, SUM(b.dinheiro) AS dinheiro,…
-
0
votes2
answers325
viewsA: How to insert data into another database with Linked Server
First ensure that the "Distributed Transaction Coordinator" is running on all servers: Squeeze R; Typo services.msc; Squeeze Enter; Start the "Distributed Transaction Coordinator" if it is not…