Problem in sql script


 
Thread Tools Search this Thread
Top Forums Programming Problem in sql script
# 1  
Old 06-06-2012
MySQL Problem in sql script

hi

i have written a sql script for adding 10000 entries in a table in mysql .
Code:
drop table test;
/*create table test (name varchar(10), id int primary key,num int,num1 int);
insert into test (name,id,num) values (1,5,5);*/
create table test (id  int primary key,name varchar(10));
CREATE PROCEDURE display(no int)
BEGIN
        DECLARE counter INT DEFAULT 1;
        simple_loop: LOOP
        SET counter=counter+1;
        insert into test (id,name) values (counter,counter);
IF counter=no THEN
                LEAVE simple_loop;
        END IF;
END LOOP simple_loop;
call display(10001);

this is the script.

But on executing it is giving this error.
Code:
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.08 sec)
ERROR 1064 (42000): You have an error in your SQL syntax; 
check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 11

pls give ur suggestions ...

Moderator's Comments:
Mod Comment Please use next time code tags for your code and data

Last edited by vbe; 06-06-2012 at 06:23 AM..
# 2  
Old 06-06-2012
check the thread it will help you

declare a variable in mysql
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run SQL thru shell script: how to get a new line when run sql query?

Hi, this's Pom. I'm quite a new one for shell script but I have to do sql on shell script to query some information from database. I found a concern to get a new line...When I run my script, it retrieves all data as wondering but it's shown in one line :( What should I do? I'm not sure that... (2 Replies)
Discussion started by: Kapom
2 Replies

2. Shell Programming and Scripting

Problem in formatting output of SQL query in excel sheet in shell script

Hi Guys.. Need your help to format the output of my shell script. I am using spool command to take out put in csv file. below is my code. (for example) col USERNAME for a15 col EMAIL for a30 col FULL_NAME for a20 col LAST_LOGIN for a40 col DATE_CREATED for a40 SPOOL 120.csv... (3 Replies)
Discussion started by: Agupte
3 Replies

3. UNIX for Dummies Questions & Answers

unix script with SQL statement problem

Hello, I have a script to get the information from database, however, it's look like the loop is not work, can someone help? :confused: echo Input file list to check: read filelist for file in 'cat $filelist.txt' do echo "select FILENAME from FILE_TABLE where filename like '${file}'%;" >>... (9 Replies)
Discussion started by: happyv
9 Replies

4. UNIX for Dummies Questions & Answers

Execute PL/SQL function from Unix script (.sql file)

Hi guys, I am new on here, I have a function in oracle that returns a specific value: create or replace PACKAGE BODY "CTC_ASDGET_SCHED" AS FUNCTION FN_ASDSCHEDULE_GET RETURN VARCHAR2 AS BEGIN DECLARE ASDSchedule varchar2(6); ASDComplete... (1 Reply)
Discussion started by: reptile
1 Replies

5. Shell Programming and Scripting

Problem in Passing sql query for a script

Unix prompt ========= echo "Enter the query" read q ========== User has entered : SELECT * FROM employee ===================== Now the problem starts.. echo $q Output: SELECT "all files names in the PWD" FROM employee ================================================ ... (5 Replies)
Discussion started by: Niroj
5 Replies

6. Shell Programming and Scripting

pl/sql in unix problem

hi all i have written this small code. sqlplus $schema_name/$passwrd@$instance <<eof set serveroutput on; declare lv_count pls_integer; lv_option varchar2(20); begin select count(*) into lv_count from all_objects where upper(object_name)=upper('$temp_file1');... (1 Reply)
Discussion started by: infyanurag
1 Replies

7. Shell Programming and Scripting

Calling SQL LDR and SQL plus scripts in a shell script

Hi- I am trying to achieve the following in a script so I can schedule it on a cron job. I am fairly new to the unix environment... I have written a shell script that reads a flat file and loads the data into an Oracle table (Table1) via SQLLDR. This Works fine. Then, I run a nested insert... (5 Replies)
Discussion started by: rajagavini
5 Replies

8. UNIX for Dummies Questions & Answers

problem to run sql startment in script

Hello, I have a script to run a list of customer information, but it not work. can anyone help below: echo "Please input list to check customer detail:" read list for file in 'cat $list.txt' do echo "select cuname as "FROM CUNAME", invo_num as "RECS", total_amount as "AMOUNT", tax_amount as... (7 Replies)
Discussion started by: happyv
7 Replies

9. UNIX for Dummies Questions & Answers

Problem with while loop and SQL

Connected to oracle database sqlplus << EOF $CONNECTSTR set heading off set trimspool on set feedback off select ID,DATE from sysadm.TEST where VALUE = 'A' order by ID; value_id = ID value_date = DATE EOF 1. Is it possible to reference the values, ID,DATE in unix shell script. 2.... (20 Replies)
Discussion started by: nandajk
20 Replies

10. Shell Programming and Scripting

Problem with Calling sql file from shell script

I have created abc.sh file which will set the environment variables (UNIX env variables as well as ORACLE required variables like ORACLE_SID,ORACLE_HOME etc) and then calls a function file which checks for starts some logs and then it will try to execute the .sql file. The .sh, function file are as... (1 Reply)
Discussion started by: sskc
1 Replies
Login or Register to Ask a Question