Page 1 of 2

Se agregan registros en una consulta

PostPosted: Sat Mar 05, 2016 12:06 pm
by gusgusl
tengo el siguiente problema en este codigo:
Donde la Cantidad de Articulos es : 3
Se supone que tengo 2 articulos guardados que cumplen la condicion de que Guardada=No

SetVar "[Medidas]" "5"
Loop "1" "[CantidadArticulos]" "[x]"
dbpShowAll "SoulTrain" "Ventas"
dbpQuery "SoulTrain" "Ventas" "Guardada=[#34]No[#34] AND Articulo=[#34][Articulo[x]][#34]"
If "[SoulTrain.Ventas.$RecCount]" ">=" "[Medidas]"
Loop "1" "[Medidas]" "[xxx]"
dbpGotoRecord "SoulTrain" "Ventas" "[xxx]"
SetVar "[SoulTrain.Ventas.Guardada]" "Si"
endloop
endif
endloop

al terminar de recorrer el Loop y donde los registros no superan la cantidad necesaria para hacer la accion igualmente me agrega registros en blanco a la tabla al finalizar
lo cual no deberia y no encuentro donde esta el error
Agradezco si alguien me puede ayudar

Re: Se agregan registros en una consulta

PostPosted: Sat Mar 05, 2016 4:08 pm
by Gaev
gusgusl:

1) You will get a lot more people to assist you if you do not restrict your language to Spanish ... provide the Google Translation as well.

2) Google Translate ...
I have the following problem in this code:
Where the number of items is: 3
Is supposed to have 2 saved items that meet the condition that Saved = No


SetVar "[Medidas]" "5"
Loop "1" "[CantidadArticulos]" "[x]"
dbpShowAll "SoulTrain" "Ventas"
dbpQuery "SoulTrain" "Ventas" "Guardada=[#34]No[#34] AND Articulo=[#34][Articulo[x]][#34]"
If "[SoulTrain.Ventas.$RecCount]" ">=" "[Medidas]"
Loop "1" "[Medidas]" "[xxx]"
dbpGotoRecord "SoulTrain" "Ventas" "[xxx]"
SetVar "[SoulTrain.Ventas.Guardada]" "Si"
endloop
endif
endloop

to finish touring the Loop and where records do not exceed the amount necessary to make the action I also add blank records to the table at the end
which should not and can not find where this error
I appreciate if someone can help me

... as you can see, Google Translate does not tell us (in English) what you are saying in Spanish.

3) So, I suggest that, as a first step, try ...
Code: Select all
SetVar "[Medidas]" "5"
Loop "1" "[CantidadArticulos]" "[x]"
   dbpShowAll "SoulTrain" "Ventas"
   dbpQuery "SoulTrain" "Ventas" "Guardada=[#34]No[#34] AND Articulo=[#34][Articulo[x]][#34]"
   AlertBox "Trace1" "x=[x] ... $RecCount=[SoulTrain.Ventas.$RecCount]"
   If "[SoulTrain.Ventas.$RecCount]" ">=" "[Medidas]"
      Loop "1" "[Medidas]" "[xxx]"
         dbpGotoRecord "SoulTrain" "Ventas" "[xxx]"
         SetVar "[SoulTrain.Ventas.Guardada]" "Si"
      endloop
   endif
endloop

... and post the results of the Alertbox here.

Then tell us which of the values are NOT as expected.

4) If all the results are as expected, try changing the second Loop command to ...
Code: Select all
Loop "[Medidas]" "1" "[xxx]"

Re: Se agregan registros en una consulta

PostPosted: Sat Mar 05, 2016 4:54 pm
by gusgusl
el resultado del loop es el esperado:
the result is the expected loop:

x=1...$RecCount=0
x=2...$RecCount=2
x=3...$RecCount=0

sigue agregando registros vacios al finalizar

continues to add empty records at the end

hize el cambio en el segundo loop y el resultado es el mismo, me agrega registros vacios a la tabla
I made the change in the second loop and the result is the same , I add empty records to the table

Re: Se agregan registros en una consulta

PostPosted: Sat Mar 05, 2016 5:35 pm
by Gaev
gusgusl:

Thank you for the detailed results.

continues to add empty records at the end

I don't know why it would add records.

1) How many empty records it adds ?

2) Try this ...
Code: Select all
SetVar "[NL]' "[#13][#10]"
SetVar "[myTrace]" ""

SetVar "[Medidas]" "5"
Loop "1" "[CantidadArticulos]" "[x]"
   dbpShowAll "SoulTrain" "Ventas"
   SetVar "[myTrace]" "[myTrace]1. x=[x] ... $RecCount=[SoulTrain.Ventas.$RecCount][NL]"
   dbpQuery "SoulTrain" "Ventas" "Guardada=[#34]No[#34] AND Articulo=[#34][Articulo[x]][#34]"
   SetVar "[myTrace]" "[myTrace]2. x=[x] ... $RecCount=[SoulTrain.Ventas.$RecCount][NL]"
   If "[SoulTrain.Ventas.$RecCount]" ">=" "[Medidas]"
      Loop "1" "[Medidas]" "[xxx]"
         dbpGotoRecord "SoulTrain" "Ventas" "[xxx]"
         SetVar "[SoulTrain.Ventas.Guardada]" "Si"
         SetVar "[myTrace]" "[myTrace]3. xxx=[xxx] ... $RecCount=[SoulTrain.Ventas.$RecCount][NL]"
      endloop
   endif
   SetVar "[myTrace]" "[myTrace]4. x=[x] ... $RecCount=[SoulTrain.Ventas.$RecCount][NL]"
endloop
dbpShowAll "SoulTrain" "Ventas"
SetVar "[myTrace]" "[myTrace]5. x=[x] ... $RecCount=[SoulTrain.Ventas.$RecCount][NL]"
AlertBox "myTrace" "[myTrace]"

... and post your results here.

Re: Se agregan registros en una consulta

PostPosted: Sun Mar 06, 2016 6:53 am
by gusgusl
El resultado es el siguiente:
The result is as follows

1.x=1...$RecCount=7
2.x=1...$RecCount=0
4.x=1...$RecCount=0
1.x=2...$RecCount=8
2.x=2...$RecCount=2
4.x=2...$RecCount=2
1.x=3...$RecCount=8
2.x=3...$RecCount=0
4.x=3...$RecCount=0
5.x=3...$RecCount=9

me agrego 2 registros vacios en la tabla
I add 2 empty rows in the table

Re: Se agregan registros en una consulta

PostPosted: Sun Mar 06, 2016 8:25 am
by Gaev
gusgusl:

Thanks again for the results.

You may have found a defect in the program/plugin.

From your results, it looks like ... each time there is a Query resulting in zero matching records, it adds an empty record (notice that the overall $RecCount does not increase when the query found 2 matching records).

You can prove this by doing this ...
Code: Select all
SetVar "[NL]' "[#13][#10]"
SetVar "[myTrace]" ""

SetVar "[Medidas]" "5"
Loop "1" "[CantidadArticulos]" "[x]"
   dbpShowAll "SoulTrain" "Ventas"
   SetVar "[myTrace]" "[myTrace]1. x=[x] ... $RecCount=[SoulTrain.Ventas.$RecCount][NL]"
   dbpQuery "SoulTrain" "Ventas" "Guardada=[#34]No[#34] AND Articulo=[#34][Articulo[x]][#34]"
   SetVar "[myTrace]" "[myTrace]2. x=[x] ... $RecCount=[SoulTrain.Ventas.$RecCount][NL]"
endloop
dbpShowAll "SoulTrain" "Ventas"
SetVar "[myTrace]" "[myTrace]5. x=[x] ... $RecCount=[SoulTrain.Ventas.$RecCount][NL]"
AlertBox "myTrace" "[myTrace]"


If it still adds empty records ...

1) In your command ...

dbpOpenTable SoulTrain" "Ventas" "subroutine"

... do you have a subroutine defined ? ... if so, can you post its contents here ?

2) Try and replace ...
Code: Select all
   dbpQuery "SoulTrain" "Ventas" "Guardada=[#34]No[#34] AND Articulo=[#34][Articulo[x]][#34]"

... with ...
Code: Select all
   SetVar "[queryString]" "!Guardada=[#34]No[#34] AND Articulo=[#34][Articulo[x]][#34]"
   SetVar "[myTrace]" "![myTrace][queryString][NL]"
   dbpQuery "SoulTrain" "Ventas" "![queryString]"

Re: Se agregan registros en una consulta

PostPosted: Sun Mar 06, 2016 9:44 am
by gusgusl
con el ejemplo que me distes me sigue agregando registros vacios
with the example that you gave me I still adding empty records

tambien intente con la segunda opcion que me distes y el resultado fue el mismo,registros vacios agregados a la tabla
also try the second option that you gave me and the result was the same , empty records added to the table

no uso ninguna subrutina al abrir la tabla

do not use any subroutine to open the table

Re: Se agregan registros en una consulta

PostPosted: Sun Mar 06, 2016 1:02 pm
by Gaev
gusgusl:

with the example that you gave me I still adding empty records

I was expecting that ... so it confirms that the record is being added during the ShowAll/Query sequence ... if you can post the [myTrace] values, it will help to pinpoint the cause a bit further.

also try the second option that you gave me and the result was the same , empty records added to the table

Thanks ... just wanted to eliminate that as a possible cause.

do not use any subroutine to open the table

I can't think of anything else ... later, I will try and recreate this in my own computer ... but this might be something you might direct to NeoSoft Support.

Re: Se agregan registros en una consulta

PostPosted: Mon Mar 07, 2016 5:10 am
by stu
Maybe too late but I would suggest to try the other way and implicitly write the queries yourself. Additionally I see you have "Si" and "No" stored in the database on a varchar field I'm guessing, use boolean fields to store values that can be either true or false.
Code: Select all
SetVar "[Medidas]" "5"
Loop "1" "[CantidadArticulos]" "[x]"
     dbpexecsql "SoulTrain" "SELECT * FROM Ventas WHERE Guardada = 0 AND Articulo = [#34][Articulo[x]][#34]" ""
     If "[SoulTrain.Ventas.$RecCount]" ">=" "[Medidas]"
        Loop "1" "[Medidas]" "[xxx]"
             dbpexecsql "SourTrain" "UPDATE Ventas SET Guardada = 1 WHERE SomeID = [xxx]" ""
        endloop
     endif
endloop


Notice that the value of Guardada on this example is of boolean type.

Re: Se agregan registros en una consulta

PostPosted: Mon Mar 07, 2016 8:17 am
by gusgusl
cambie la definicion de la variable "Guardada" a Boolean pero el resultado es el mismo,
me agrega registros en blanco al final

change the definition of the variable " Saved " a Boolean but the result is the same ,
I added blank records at the end


voy a probar ahora realizar el query mediante sql como esta en tu ejemplo a ver que sucede

I'll try now perform the query using SQL like this in your example and see what happens

Re: Se agregan registros en una consulta

PostPosted: Mon Mar 07, 2016 8:23 am
by gusgusl
usando la opcion mysql para la consulta me sigue agregando registros en blanco al final

using the mysql query option for me keeps adding blank records at the end

Re: Se agregan registros en una consulta

PostPosted: Mon Mar 07, 2016 11:23 am
by stu
gusgusl wrote:usando la opcion mysql para la consulta me sigue agregando registros en blanco al final

using the mysql query option for me keeps adding blank records at the end


Yeah the boolean field type was a side note, really, wasnt suggesting it would have make a difference... Can you please post a small part of your program so I test here on my pc...

Re: Se agregan registros en una consulta

PostPosted: Mon Mar 07, 2016 12:34 pm
by gusgusl
he subido el pub a la siguiente direccion:

http://guaviyu.org/BarraBoliche.pub

Re: Se agregan registros en una consulta

PostPosted: Tue Mar 08, 2016 6:00 am
by stu
gusgusl wrote:he subido el pub a la siguiente direccion:

http://guaviyu.org/BarraBoliche.pub


404 Error

Re: Se agregan registros en una consulta

PostPosted: Tue Mar 08, 2016 8:54 am
by gusgusl
Ya quedo solucionado el link:
http://guaviyu.org/BarraBoliche.pub