My resultset has 2958 rows. I’m trying to Loop over the result set and select each row, assigning a new id to it, but each new Id is printing 2958 times. What am I doing wrong and how could I fix this? After the select is correct, I want to use it with the Insert. Answer The main problem in
Tag: while-loop
SQL: Capturing first row in WHILE loop
I’m thinking my issue is based on how I’ve written the loop, but how it is written is how I’ve come to understand loops. So I’m really wondering if there is a way to consolidate this? As it sits, I have 2 sections: the first which captures the very first row, and it exists solely because my second section will
Why does my procedure have error when I’m trying to do loop?
i try to do loop to load data in MySQL Workbench 8.0. but it keep error and i cannot figure it out. here is my code Answer You cant use VARCHAR() in CAST(). You need to change that to CHAR() and with length defined. Try this:
SQL Trigger with loop from another table
I’ve got 2 tables : Table A Table B The table A contains the following values : The Table B contains the following values : My goal is to set the column B.chk with the number of occurence from table A when a new row is created on table B. For example : The trigger on table B should set
How can I output text until it is ascii in SQL?
How can I output text until it is ascii in SQL? Here is what I am trying to do: But in the end I am getting an empty string. Why? What am I missing here? I am expecting the value of the @output to be ‘text’ in the end of the script. UPDATE If I update the script to the
How to remove While loop inside stored procedure in MS SQL Server? [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year. Improve this question I have a stored procedure with a cursor inside for the logic which is taking long time for execution . I
T-SQL – adding more date values to a table all rows
I have a table that contains many IDs as random numbers and I would like to create another table that contains all the IDs with another column having dates from first day of the year until a specific date. For example: My actual table looks like: And I would like to have a table if my specific end date is
mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, string given in while-loop
I currently have this code but it gives me the error mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, string given on line 22 The code is this: I can’t seem to find the error, I am running the same code in another file and there is no issues. Answer You are overwritting $result So you need to give your variables
WHILE / LOOP inside CASE expression SQL – ORACLE
I am testing a select statement containing a CASE expression and I need to add a WHILE / LOOP inside one of the WHEN conditions. The logic from this statement will eventually be included inside a PL/…
While loop SQL Server
Help me please. I need to write two functions, one that calculates the factorial and another that calculates the sums of euler. To make the euler sums I need to use the function that calculates the factory. I already have the function of factorial but when doing the sums the result I get “NULL” Note: it needs to be done