0

Hello every1,

I want to ENTER Sr.No. and Name in the table using procedures.
My table has attributes
1. Sr.No. (which is my primary key(int datatype))
2. Name (which is not null(string datatype))

I want to write a procedure in mysql to automate the process of entering data in the table using procedures..It would be like ..

--At first table is empty
--CALL the procedure
--After Calling procedure table will have 400,000 (4lacs) entries..


Thanking you in advance
Thank You

2
Contributors
9
Replies
10
Views
6 Years
Discussion Span
Last Post by smantscheff
0

What exactly is your problem? Go ahead and code a procedure. Come back if it does not work and show us what you did.

0
create procedure enter_data()
begin
declare x int default 0;
repeat
insert into Person values('AAAA');
x=x+1;
until X>10000
end repeat;
end //

this gives me an error :(

Edited by shanker31: n/a

0

What exactly is your problem? Go ahead and code a procedure. Come back if it does not work and show us what you did.

sorry for late reply...

0

In collaborative debugging it's deemed good practice not only to state that an error occured but to cite the error message as precisely as possible.
Your code in my test installation gives not only one but two errors.
1) You have to set the delimiter to //
2) x = x + 1 is not a valid SQL statement. Probably you mean set x = x + 1 Also it's deemed good practice to stick to the spelling of variable names. Try this one:

delimiter //
create procedure enter_data()
begin
	declare x int default 0;
	repeat
		insert into Person values('AAAA');
		set x=x+1;
		until x > 10000
	end repeat;
end //

Edited by smantscheff: n/a

0

@smantscheff How to enter random name in the table, i m aware of using rand() function but cant get the logic..

0

@smantscheff How to declare global variables:
is it like :
@@var=0;
or
set @@var=0;
or
set global var=0;

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.