-
create procedure view_select
-
(coll int(11))
-
begin
-
declare x int;
-
declare y int;
-
set x=0;
-
select count(*) into y from s_details where college_code=coll;
-
while(x<y) do
-
select day_number,title,first_name,middle_name,last_name,
-
date_of_birth,e_mail,ref_number,
-
date_of_entry_of_details,course_id,x+1 from s_details;
-
set x=x+1;
-
end while;
-
end//
-
How to increment the value of x alone for each record being displayed?
In this the select statement is repeated as many times as x?
How to solve this problem?
9 4569 pbmods 5,821
Recognized Expert Expert
Heya, Praveena.
Changed thread title to better describe the problem (did you know that threads whose titles do not follow the Posting Guidelines actually get FEWER responses?).
Change: - date_of_entry_of_details,course_id,x+1 FROM s_details;
To: - date_of_entry_of_details,course_id, x := x + 1 FROM s_details;
Heya, Praveena.
Changed thread title to better describe the problem (did you know that threads whose titles do not follow the Posting Guidelines actually get FEWER responses?).
Change: - date_of_entry_of_details,course_id,x+1 FROM s_details;
To: - date_of_entry_of_details,course_id, x := x + 1 FROM s_details;
it becomes infinite loop.
I want x to act like serial number for my table.
Everytime wen a record is displayed x shud be incremented by 1.
Can u pls help me to implement this?
pbmods 5,821
Recognized Expert Expert
Heya, Praveena.
Are you trying to set a variable LIMIT for your SELECT query?
Try using a Prepared Statement.
Heya, Praveena.
Are you trying to set a variable LIMIT for your SELECT query?
Try using a Prepared Statement.
I jus want to view the records what i ve entered in my table.
But with one more field added while displaying that is the serial number x.
I am getting the count of total number of records in the table into variable y.
So until x<y the loop should execute but it is not happening why?
pbmods 5,821
Recognized Expert Expert
Heya, Praveena.
This line: -
SELECT day_number,title,first_name,middle_name,last_name,
-
date_of_birth,e_mail,ref_number,
-
date_of_entry_of_details,course_id,x := x + 1 FROM s_details;
-
does select every record from the table. You don't need to use a loop here.
Heya, Praveena.
This line: -
SELECT day_number,title,first_name,middle_name,last_name,
-
date_of_birth,e_mail,ref_number,
-
date_of_entry_of_details,course_id,x := x + 1 FROM s_details;
-
does select every record from the table. You don't need to use a loop here.
i even tried without a loop but that x=x+1 doesnt get incremented.
each time it is displaying zero only for x. Why?
pbmods 5,821
Recognized Expert Expert
Heya, Praveena.
The colon is important.
Heya, Praveena.
The colon is important.
-
CREATE PROCEDURE view_select
-
(coll INT(11))
-
BEGIN
-
DECLARE x INT;
-
set x=0
-
SELECT course_id,x:=x+1 FROM s_details;
-
end//
-
this is what u asked me to do right?
but this gives an error.
if i remove the colon it is working
-
CREATE PROCEDURE view_select
-
(coll INT(11))
-
BEGIN
-
DECLARE x INT;
-
set x=0
-
SELECT course_id,x:=x+1 FROM s_details;
-
end//
-
this is what u asked me to do right?
but this gives an error.
if i remove the colon it is working
it is working in the sense the query is ok..
but x is always displayed as 0.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: J. Campbell |
last post by:
Hi everyone. I'm sure that this is common knowledge for many/most
here. However, it was rather illuminating for me (someone learning
c++) and I thought it might be helpful for someone else. I'm...
|
by: Ken |
last post by:
The fact that you can not reassign a variable in XSL is an endless
source of frustration, causing you to jump through all sorts of
non-intuitive hoops.
In this case, however, the lack of...
|
by: John Wilkinson |
last post by:
Hi,
I am new to XSLT. My problem is that I wish to create an HTML table, and
give each row an incrementing number from 1.This would increment every
itteration of a for-each loop.
The XSLT...
|
by: dan |
last post by:
I have 2 tables, tab1 ( integer incremented sequence , col2, col3 )
and tab2 ( integer from tab1, col4, col5 ). When I call this function
to add a record to each table:
LOOP
select...
|
by: Erik de Castro Lopo |
last post by:
Hi all,
The GNU C compiler allows a void pointer to be incremented and
the behaviour is equivalent to incrementing a char pointer.
Is this legal C99 or is this a GNU C extention?
Thanks in...
| |
by: boaring |
last post by:
I need to use Macro's in Excel and always the same changes to 31 Sheets. (31 days in the Month).
I'm trying to use a FOR loop but cannot get the correct format to have the sheet number to increment...
|
by: masterpaladin38 |
last post by:
I've been working on this problem for some time and I must say I'm
stump. Any help would be appreciated.
Basically what I'm trying to do is write the results of a loop to a new
text file with...
|
by: Arekkusu |
last post by:
Hi, nice to meet everyone, im Arekkusu and im new to the forums.
I have a slight problem..hopeing you guys and gals can help with. Its about trying to get a variable ($i), to increase by one every...
|
by: Elementary |
last post by:
I have a number of variables, e.g. X1, X2, X3, X4, X5.
I want to select only the ones that are non zero(there will only be 2 or 3 at any time), and record them as Y1, Y2 and Y3
I want to know...
|
by: subramanian100in |
last post by:
The following portion is from c-faq.com - comp.lang.c FAQ list ·
Question 6.13
int a1 = {0, 1, 2};
int a2 = {{3, 4, 5}, {6, 7, 8}};
int *ip; /* pointer to int */
int (*ap); /* pointer to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |