Posts by Sorack • 27,430 points
864 posts
-
1
votes2
answers230
viewsA: Query returns "Invalid column name 'result'. " where 'result' is a column generated by select (SQL SERVER)
The field result does not actually exist in the table, so to use it in the WHERE you must indicate how the field is formed. SELECT x.* FROM (SELECT cte, (CONVERT(VARCHAR, c.manifesto) + ' ' +…
-
2
votes2
answers164
viewsQ: Search field with rounded edge
I’d like to make a input adjacent to a button with a rounded edge that fits together as follows: Is there any way to do this with CSS pure, preferably without using the search field above the…
-
0
votes1
answer1010
viewsA: NODE.js Insert in MS SQL
It seems to me that the names of your columns are incorrect, but without the correct error message it is practically identifying the problem. So I rewrote your code in a slightly more readable way…
-
4
votes1
answer90
viewsA: Inner Join with Where and multiple tables
A comma was missing after the declaration of one of the fields: SELECT DATE_FORMAT(b.dt_lancamento, '%d-%m-%Y') as dt_lancamento_F, DATE_FORMAT(b.dt_abertura, '%d-%m-%Y') as dt_abertura_F,…
-
1
votes1
answer70
viewsA: Error while escaping an express js url from a middleware
You can use regular expression within your middleware to check whether the URL is one of the paths you want to avoid validation. const { originalUrl: url } = request; if…
-
3
votes1
answer271
viewsA: What use are the keys in the variables of Node.js
The name for the expression given as an example is "Assignment via structuring (destructuring assignment)". Assignment via structuring (destructuring assignment). The syntax of assignment via…
-
2
votes1
answer3904
viewsA: Cannot find module
By what was reported the file name is dialogflow.js and you are importing dialogFlow. Use the require in the following way, if the files are in the same folder: const dialogFlow =…
-
1
votes1
answer228
viewsA: A Rigger can "undo/undo" the action that triggers it?
By the description you gave the ideal would use a trigger of the kind instead of: ALTER TRIGGER tr_tabela ON tabela INSTEAD OF INSERT AS BEGIN SET NOCOUNT ON; IF -- Sua condição para o erro aqui…
-
0
votes1
answer160
viewsA: Error when using ISDATE in CASE WHEN
Your date format is not equal for both fields: UPDATE A SET DIVERGENCIA_DE_VENCIMENTO = 'NÃO' FROM TMP_LAYOUT_DIRETRIZES A WHERE ISDATE(A.VENCIMENTO_ORIGINAL) = 1 AND CASE WHEN…
-
3
votes1
answer47
viewsA: Error: More than one value was returned by a subquery
You have to relate your subqueries with the queryleading: SELECT (SELECT ID_FUNC FROM P_ISIDB.TB_DIM_FUNCIONARIO WHERE STG_VNDA.COD_FUNC = P_ISIDB.TB_DIM_FUNCIONARIO.COD_FUNC) AS ID_FUNC , (SELECT…
-
1
votes2
answers1828
viewsA: How to make a draw of words and letters by clicking the start button?
You can use the function Math.random to select a random value based on the total size of the array/String. In the example below I used only one function to select random values: const randomizar =…
-
1
votes1
answer390
viewsA: How to send html form to route Node?
The body-parser does not provide support for the Content-Type multipart/form-data. For this you can use a middleware like the multer. For this just adapt your routes that will receive the contents…
-
1
votes2
answers44
viewsA: Column 'discount' cannot be resolved. How to use a column that is the result of a calculation to calculate another column in the same query?
One option is to use a subquery in the FROM: SELECT x.*, x.price * x.desconto AS finalprice FROM ( SELECT price, col2, col3 * 7.5 AS desconto FROM tab1 ) x…
-
0
votes1
answer67
viewsA: Uncaught Error - Sending email using nodemailer and Angularjs
It seems to me you’re making a mess between the responsibilities of Angular and of Node.js. The NodeMailer is a package that must be executed on the server side, i.e., by Node.js. The Angular must…
-
0
votes1
answer181
viewsA: How to interpret React Native error messages
Install the module react-transoform-hmr with the following command: npm install react-transform-hmr --save
-
1
votes3
answers720
viewsA: Separating text with Javascript
One way is using the position of the separators as below: const separar = endereco => { let posicao = endereco.indexOf(','); const rua = endereco.substring(0, posicao).trim(); let aux =…
javascriptanswered Sorack 27,430 -
1
votes1
answer139
viewsA: Replace xml tag with nodejs
You can use the following regular expression within a replace to have the result you want: /<COLUMN NAME="(.+)">(.+)<\/COLUMN>/gm The complete code will be as follows:: const REGEX =…
-
0
votes1
answer59
viewsA: How to name each row of a url list
Change the execute function to receive one array of objects instead of a array of string and relay this to the line recording. ... await executar([ { assinatura: 'Bocaiúva do Sul', url:…
-
1
votes1
answer1428
viewsA: Read user input without using the prompt function
In the Node.js you can use the module readline: const readline = require('readline'); const input = readline.createInterface({ input: process.stdin, output: process.stdout, });…
-
1
votes1
answer201
viewsA: Use data from a request in a global variable
In reality what happens is that as the variable is populated within the callback, which is asynchronous, when the console.log the variable has not yet been completed. If you want to run the…
-
1
votes1
answer1411
viewsA: Comment on files . env
The application only looks at the keys you determine so you can put, for example, the character # in front of the comment without problems
-
0
votes1
answer4666
viewsA: HTTP (Post) Bad Request 400 - How to resolve?
The problem is that the INSERT you understand, the way your code is, that you have a column called quote, which is not reality. You must pass as second parameter an object with columns and values.…
-
2
votes3
answers801
viewsA: Explanation of the function and application of the javascript Sort function
Array.prototype.Sort() ... Syntax: arr.sort([funcaoDeComparacao]) ... If the Deparacao function parameter is provided, the array will be ordered according to the function’s return value. Whereas a…
-
0
votes1
answer161
viewsA: Crawler - how to access several pages
Rewriting your code to use promises and carry a list of URLs would look something like this: const cheerio = require('cheerio'); const { get } = require('request'); const { writeFileSync } =…
-
2
votes1
answer34
viewsA: Filter the month inside a extracted object with Object.Keys
In your case you can use the map to form a array and after that use the filter to keep only those who are with mar in the attribute month: const original = { '1': { month: 'fev', name: 'xxxxxxx',…
-
2
votes1
answer178
viewsA: How to improve this: Hell callback?
First let’s solve your problem setInterval. To ensure that there will not be two simultaneous executions of the same code, I suggest you change to setTimeout and restart the counter after running…
-
1
votes1
answer630
viewsA: Nodejs query in SQL Server
Rewriting your code and applying best practices defined in airbnb guide I got the following code: // REQUIRES const lerData = async (pool) => { const resultado = await pool .request()…
-
1
votes1
answer45
viewsA: Remove Group_concat and list each one separately
SELECT U.login, AC.course FROM users U INNER JOIN students_courses AC ON AC.student = U.id LEFT JOIN courses C ON AC.course= C.id WHERE level_access = 0 AND AC.avaliable…
-
1
votes7
answers1322
viewsA: Push element from one array to another array
Using the syntax for...of introduced into the ES6 you can do it this way: const PickIt = elementos => { let pares = []; let impares = []; // Percorre cada item for (let elemento of elementos) {…
javascriptanswered Sorack 27,430 -
1
votes3
answers69
viewsA: standard argument in javascript function
It would actually be like this: function func(parametro = 'valor padrão') { } It’s not very good to use arg or args as a parameter name also.…
javascriptanswered Sorack 27,430 -
0
votes1
answer667
viewsA: Return value from a request!
If by "return" you mean "serve as an answer to a endpoint", you can use the express as follows: const express = require('express'); const fetch = require('node-fetch'); const app = express(); const…
-
1
votes1
answer43
viewsA: Sort by month without repeating the year
What happens is that new lines will be created for each term in the GROUP BY which was added, therefore with the EXTRACT MONTH who is in your query, one SET results will be created for each month…
-
2
votes1
answer1170
viewsA: Remove aquifers with File System
Your mistake says the file is in use. The suggestion I give you is to make the following change so that, if any problem happens, it becomes clearer to identify it. With the change the files will be…
-
0
votes1
answer68
viewsA: Registration is not being sent to the database
I suggest you make the following changes to your code so that at least one error is returned if the operation is not performed successfully. First change your model to the following: const {…
-
1
votes1
answer217
viewsA: Read data from a url
The first thing to do to recreate a requisition HTTP within the Node.js is to identify the information that is sent in such a request. I will suggest a step by step using the URL / as an example.…
-
2
votes2
answers76
viewsA: How to use Firebird 2.1 > ABS in Firebird 2.0?
You can use the DLL's of the default installation folder of Firebird: DECLARE EXTERNAL FUNCTION abs DOUBLE PRECISION RETURNS DOUBLE PRECISION BY VALUE ENTRY_POINT 'IB_UDF_abs' MODULE_NAME 'ib_udf';…
-
3
votes1
answer385
viewsA: How to PIVOT a column by concatenating strings into Sqlserver
As of 2017 version of SQL Server you can use the function STRING_AGG that allows grouping and concatenating results: SELECT x.TABLE_NAME, STRING_AGG(x.COLUMN_NAME, ', ') AS COLUMN_NAMES FROM ( --…
-
0
votes2
answers137
viewsA: values of a Java list
You only need to break the line when your variable cont is divisible by 20. For this you can use the operator Remainder or Modulus represented by the character % which will return the rest of a…
-
1
votes1
answer93
viewsA: Filter issues in lib API QUERY PARAMS
You did not present the data you have in your database, but by subtended in your question you want to search the items that contain the text that was passed, so you should use a regular expression…
-
2
votes1
answer2626
viewsA: How to get a URL parameter in Express?
Checking the expected result I see that you have two problems. The first is that you want to get the parameters according to the string presented in the parameters of query. To do so you need to use…
-
0
votes1
answer145
viewsA: Check if value is in a column
Actually your table was incorrectly designed. The correct one would be to have a support table with the codes and a link to this table. But if there is no possibility to change the table you can use…
-
0
votes2
answers86
viewsA: How do I use parseFloat in this algorithm?
The problem is that in your ifs you are not covering the values between the notes (such as 7.3). Modifying the checks to the following code your logic should meet the expected: if (media ==10) {…
-
0
votes3
answers51
viewsA: I can’t get average
In his query you are grouping by purchase amount, which turns out to be wrong, since from what I understand you want the purchase frequency per day. Adjusting your query would look like this: SELECT…
-
0
votes1
answer146
viewsA: I can create a table in mysql that shows the person’s age by subtracting today’s year - her birth year?
The best would be for you to bring age into one SELECT as follows: SELECT YEAR(CURRENT_TIMESTAMP) - YEAR(data_nasc) - (RIGHT(CURRENT_TIMESTAMP, 5) < RIGHT(data_nasc, 5)) as idade FROM TABELA It…
-
2
votes1
answer34
viewsA: How to provide module configuration correctly?
I decided assigning values in the variable itself and checking the fill in the configuration function: let opcoes = { prefixo: 'padrao' }; function imprimir(texto) { console.log(opcoes.prefixo,…
-
0
votes3
answers96
viewsA: How to get information in a text?
Consider using a parser HTML like the Cheerio. For your example would look like: const cheerio = require('cheerio'); const $ = cheerio.load(response.data); console.log($('h2').text()); With it you…
-
1
votes2
answers269
views -
1
votes1
answer364
viewsA: Inner Join with like, Mysql and Datatable
Separate your responsibilities from your own query. Leave on ON only the link of the tables: SELECT n_contribuintes.id_cont, n_contribuintes.nome_cont, n_contribuintes_param.tipo_param,…
-
3
votes3
answers4418
viewsA: Error in a simple SELECT with Group By - SQL Server
In free translation the error says: The 'Stockphotos.Pack.Name' column is invalid in the selection list because it is neither contained in a grouped function nor in the clause GROUP BY. I mean, the…
-
5
votes1
answer34
viewsQ: How to provide module configuration correctly?
I’m creating a module of Node.js and wanted to provide usage settings. Let’s say I wanted to provide a prefix for the console.log just as an example: let opcoes = {}; function imprimir(texto) {…