Posts by Jeferson Almeida • 3,076 points
74 posts
-
1
votes1
answer64
viewsA: Subquery with the records of a column
With the query below you will be able to transform your string list into lines, with it you can use inside your subselect SELECT trim(regexp_substr(FIELD_MODEL_IDS, '[^;]+', 1, LEVEL)) str FROM…
-
4
votes1
answer54
viewsQ: Expression generation for EF with dynamic properties
I’d like to conduct a search on where for Entity Framework passing the name of the property you would like to compare as a string. For example, I have the following classes: public class ClientData…
-
0
votes1
answer63
viewsA: How to convert a function to view
Views do not accept parameters, what you can do in this case is a new function with all his JOIN or call your function in their consultations.
-
4
votes2
answers176
viewsQ: Doing a LINQ function that can be called in an EF query
I have the following expression: Where(cd => cd.Modal == modal) .Select(s => s.Volume) .DefaultIfEmpty(0) .Sum() what use to make a same calculation several times within a few querys through…
-
1
votes1
answer54
viewsA: When the property is not int how to force Entity to create a field in the table as nullable:false
As in C# string are always of the type by reference and with this they always accept null values because they are nullable, EF create fields as if they accept null data by default. To place a…
-
2
votes1
answer145
viewsQ: Highcharts limit the amount of items that will be displayed in the categories on the y-axis
I have the following chart in Highcharts, I wanted to limit the number of items that will be displayed in the Y axis, for example in 7 items, and will always show the first and last item of the…
-
6
votes1
answer900
viewsQ: Daylight Saving Time date conversion
Currently in my system I use the following code, to convert the dates coming in ajax. new Date(parseInt(data.replace(/\/Date\((-?\d+)\)\//, '$1'))) Where the variable data is a string that comes in…
javascriptasked Jeferson Almeida 3,076 -
2
votes1
answer1353
viewsQ: C# Decimal field accept value equal to or greater than 0 in validation
I’m having trouble validating my type fields decimal using Razor, when I try to enter 0 in the field it gives the following error message. The field XXXX must be a number. Follow down my class and…
-
7
votes2
answers753
viewsQ: Daylight saving time with old dates
In my system save all dates on UTC, but in the user view I show in GMT -3. The problem is when I save a date in summer time, because in case it will no longer be made the difference of 3 hours, it…
-
0
votes7
answers412
viewsA: Mount an sql query filtering data
SELECT id, nf, status, data FROM documentos WHERE status = EXCLUIDO' and nf not in ('000002') Like your field status will always be "EXCLUDED", when it is not to be displayed, make an equal…
sqlanswered Jeferson Almeida 3,076 -
5
votes4
answers8025
viewsA: Check if int is "null" in C#
In C#, a int cannot be null, if you need it to be null you will have to declare it as Nullable<int> or in its sugar syntax int?.
-
3
votes1
answer845
viewsQ: Entity Framework with Oracle
I am trying to use EF, using Code Frist, along with an Oracle database, for this I am using the Nuget package Oracle.ManagedDataAccess.Entityframework, but whenever I try to run the Update-Database…
-
3
votes3
answers2714
viewsA: Failure to log in to an IIS application when trying to connect to Sqlserver
The IIS runs an own user and the same is not authorized to log into your server happens this. Probably the user who is authorized is your windows user and not the IIS. To solve this you can create a…
-
5
votes2
answers75
viewsA: How to make an if in a select when creating an object?
In this case you can use a if ternario for that, would be as follows: listaAgendaDetalhe = (from a in listaAgenda join p in listaProfissional on a.idProfissional equals p.id select new…
-
8
votes4
answers5086
viewsA: How to add values of a column in the table?
You can define a class for your tds and through JS add up these values and wherever you want, follows an example of how to do with jQuery. $(function(){ var valorCalculado = 0; $( ".valor-calculado"…
-
14
votes2
answers790
viewsQ: Perform Stress Test on C#
I have the following scenario: There is a Windows Service, done in C#, which is used to synchronize data from a local database to a cloud base and need to perform some stress and charge, with this,…
-
3
votes1
answer810
viewsA: Check the triggers linked to a given table
To check all Triggers in their respective table, you can use the query below: Select Object_Kind = 'Table', Sys.Tables.Name As Table_Name , Sys.Tables.Object_Id As Table_Object_Id ,…
-
3
votes1
answer1452
viewsA: MYSQL How to delete a row from a table with dependencies?
The correct syntax to disable and enable Fks in Mysql is To deactivate: SET FOREIGN_KEY_CHECKS=0; To activate: SET FOREIGN_KEY_CHECKS=1; The ideal is not to use this to delete the records, because…
mysqlanswered Jeferson Almeida 3,076 -
1
votes1
answer143
viewsA: Validation of the repeated registration
In this case the ideal is before you save, you make a check if you already have such a registration in your Bank, if it returns an error message. A good way to do this validation is by using…
-
5
votes1
answer437
viewsQ: How to work with CHAR-like Enums using C# and Entity Framework
I would like to know how to map my entity using an Enum of the type char by the Entity Framework, using Fluentapi. I have the following Enum: public enum Zona { Norte = 'N', Sul = 'S' } And my…
-
0
votes1
answer401
viewsA: Float variable with 2 digit accuracy after the comma in sql oracle
In that case you could use the decimal, as follows: create table t (a decimal(10,2)); The first number represents the precision, which can vary from 1-31, it represents q total number of digits that…
-
-1
votes2
answers663
viewsA: Insert an html into a table using sql server
The same way you wrote here, you’re gonna save this field like you’re saving one String usually the only concern you should have is to check your HTML content does not exceed the character limit of…
sql-serveranswered Jeferson Almeida 3,076 -
6
votes2
answers2067
viewsA: Order change of Sql columns?
Firstly, this does not bring any benefit, because the order of the columns is something only visual for us, something "cosmetic", SQL Server does not care about it. The only way to do this is by…
-
6
votes3
answers799
viewsA: How to sort by the relevance of Like?
You can do this by checking which position this string is in your field, with the function INSTR, for example: SELECT INSTR('meucarrovermelho','car'); In this case it will return the number 3, since…
-
2
votes2
answers605
viewsA: Trigger updates only to 1 record
This is because when you delete on multiple lines in the same statement, it activates Trigger only once and in its temporary table deleted, will get the list of all deleted. There are various…
-
9
votes3
answers1480
viewsQ: How to make a query through LINQ ignoring accents?
I wonder if it is possible to make a query with LINQ to compare two strings and ignore their accents. That without my Collation in the database is set as AI (Accent Insensitive) and I don’t need to…
-
2
votes3
answers669
viewsA: Field with Cedilla in Mysql
When you have a field with special characters or white spaces in it, this field should be declared within `` Follows how your query should look: INSERT INTO caixa_geral_dc ( `descrição`, empresa,…
-
1
votes1
answer43
viewsA: Statement of 2 PK Sql
First you will have to drop your PK and then recreate it, to do this you will need to execute the following commands. ALTER TABLE Icms DROP CONSTRAINT <constraint_name> ALTER TABLE Icms ADD…
-
1
votes1
answer348
viewsQ: Creation of tables through div
I would like to create a table structure that can have a variable number of columns, for example, an hour may have only 3 columns and at another time may have 5 or 6 columns, this number is not…
-
7
votes1
answer3342
viewsA: Generate database script with structure and data
A good solution to generate the structure of a database and import the data is to use the data itself Microsoft SQL Server Management Studio, he gives all the support for this. First let’s generate…
-
5
votes2
answers304
viewsA: Pick all fields of a class using Lambda + Group By
To make a group by with several fields in the Lake, you need to declare all the desired fields in your group by, would be as follows: var result = (from p in produtosCompletos group p by new…
-
8
votes2
answers441
viewsA: Query that returns if the child has inherited the parent’s and/or mother’s surname
A good way to solve this is by using the CLR, with it we will create a function in . Net to run directly in the database. First, we need to create a new project in Visual Studio of the type SQL…
-
1
votes1
answer29
viewsA: Returning Mysql Table Fields
In your case you would need to realize the join with the treatment table 2 times, your query would look like this below: SELECT tp.descricao as tratamentProfissional, p.nome, tu.descricao as…
-
4
votes2
answers106
viewsA: How to dynamically generate OR comparisons with LINQ?
How you use version 1 of Entity Framework, also known as version 3.5, I see 2 possibilities to solve the problem. 1. One of them is to create an extension method for this. public static…
-
1
votes3
answers2405
viewsA: Export query output as Insert scripts
Usually when I need something like this I make one SELECT who manages the script for me INSERT at hand, follows an example of how I normally do. Considering C1 INT and C2 and C3 STRING. SELECT…
sql-serveranswered Jeferson Almeida 3,076 -
0
votes1
answer605
viewsA: Sum mysql decimal values
The problem lies in yours in the fields you display in your Select, at its junction on Group By If you wanted to display the sum of all items sold in a new column, what you should do is a Subquery…
-
1
votes1
answer631
viewsQ: Differences between $('body'). on('click',...) and $('selector'). click()
I have a doubt in the declaration of click of an element with jQuery, I know I can do the following ways: $('body').on('click', '...selector...', function () {...}) or…
-
2
votes1
answer13534
viewsA: Procedure Oracle return query lines
In the Oracle you can’t return a select directly through a Procedure, what you can do is return a cursor to Procedure or create a Function and use it as a table. Using Function: First you need to…
-
1
votes3
answers1241
viewsA: Add a column with row number in select result
For this you can use the function row_number() follows below the example of how to use it, in case I did ordering by column e.ds_estados select row_number() over (order by e.ds_estados) linha,…
-
2
votes1
answer141
viewsA: Request with Ajax unsuccessful
First you are using a tag a within another tag a, this is not allowed, and with it must be generating your HTML wrong way. The ideal is to join these 2 elements in a single. <td…
-
1
votes1
answer226
viewsA: Update and increment column by sorting (UPDATE and ORDER BY)
In your case it would be something more or less that way, having to adapt their real needs. SET @prev := ''; SET @cnt := 1; UPDATE exemplo e JOIN (SELECT id, nome, IF(@prev <> ano, @cnt := 1,…
mysqlanswered Jeferson Almeida 3,076 -
2
votes1
answer156
viewsA: Codeigniter update works but wrong list
Your problem is in the Join that is being done in consultation, you are doing the Join of id_setor with id_empregado, goes down as it should be done: public function ListarEmpregado(){…
-
36
votes3
answers1249
viewsQ: Why can I create two functions with the same Javascript signature?
I’m having doubts about a certain issue in Javascript, suppose the following scenario below: function teste() { console.log("teste1"); } function teste() { console.log("teste2"); } teste(); In that…
javascriptasked Jeferson Almeida 3,076 -
3
votes2
answers3207
viewsA: Creating table with Primary key ID column with auto increment
One solution to this problem is to create a Function that will return you the next value of your PK, follow an example below as if it were a Identity adding the value of 1 in 1 Table CREATE TABLE…
sql-serveranswered Jeferson Almeida 3,076 -
1
votes1
answer344
viewsA: How to convert SQL command to LINQ?
If based on these 2 classes you can do this query as follows. public class Producao { public int id { get; set; } public int procedimento { get; set; } public int quant { get; set; } public string…
-
3
votes1
answer348
viewsA: How to add elements to an array
Such behaviour is due to the use of the operator [] in its variable $century['decade']. Whenever you use this operator, PHP will create a new element in the array in question, i.e., do:…
-
3
votes1
answer42
viewsA: Reducing line quantities in a query
In the Postgresql 9.0 or later you can use as follows: select f.*, string_agg(ar.nome, ', ') as artistas from filme as f inner join participa_filme as pf on pf.id_filme = f.id_filme inner join…
-
0
votes3
answers304
viewsA: SQL hide query parameter in return
A good way to do this is by using a JOIN with the table you want and group everything from the first table. It could do in its own way also however the LIMIT would have to be in Subquery and not in…
-
1
votes2
answers686
viewsA: Distinguish equal fields in a SELECT with LEFT JOIN
You can create aliases for your fields in your select, so they would be assigned names, e.g.: SELECT a.campo1 as campo1A, a.campo2 as campo2A, a.data as dataA, b.data as dataB FROM tabela_a a LEFT…
-
3
votes3
answers1098
viewsA: Problem with Padleft
The method PadLeft, adds characters to the left until you complete your string complete the number of characters reported, if the string already have at least this amount of characters nothing will…