Home Answers Viewqa SQL Purge Data from Mysql tables

 
 


Venkatesan
Purge Data from Mysql tables
0 Answer(s)      a year and 5 months ago
Posted in : SQL

Hi,

i have to write a mysql procedure to purge data from tables. but written procedure clear entire tables data. Please give me the solution for purging data.

CREATE DEFINER=`root`@`localhost` PROCEDURE `purgedata_main`()
BEGIN 
    DECLARE listID BIGINT DEFAULT -1;
    DECLARE reserveID BIGINT DEFAULT -1;
    DECLARE CPIN BIGINT DEFAULT -1;
    DECLARE listCount INT DEFAULT 0;
    DECLARE reserveCount INT DEFAULT 0;
    DECLARE done INT DEFAULT 0;
    DECLARE confRefNo INT DEFAULT 0;
    DECLARE pinCount INT DEFAULT 0;
    DECLARE loopCount INT;
    DECLARE startDate DATE DEFAULT '0000-00-00';

    DECLARE cur CURSOR FOR SELECT confrefno,listid,chairperson_pinno,reservationid FROM movedata_table;
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
    OPEN cur;
    SET loopCount = 0;

    read_loop: LOOP 

        FETCH cur INTO confRefNo,listID,CPIN,reserveID;
        IF done THEN    
            LEAVE read_loop;
        END IF; 

        DELETE FROM attendance_table WHERE confrefno= confRefNo;
        DELETE FROM codr_detail_table WHERE confrefno= confRefNo;
        DELETE FROM recordfile_table WHERE confrefno= confRefNo;
        DELETE FROM reminder_table WHERE confrefno= confRefNo;
        DELETE FROM operatorreminder_table WHERE confrefno= confRefNo;
        DELETE FROM qa_table WHERE confrefno= confRefNo;
        DELETE FROM helpqueue_table WHERE confrefno= confRefNo;
        DELETE FROM conferencerunningengine_table WHERE confrefno= confRefNo;
        DELETE FROM odo_details_table WHERE confrefno= confRefNo;
        DELETE FROM running_conference_cos_table WHERE confrefno= confRefNo;
        DELETE FROM conference_table WHERE confrefno= confRefNo;
        SELECT COUNT(listid) INTO listCount FROM conference_table WHERE listid=listID;
        IF listCount = 0 THEN
        DELETE FROM conferee_table WHERE listid=listID;
        DELETE FROM listid_table WHERE listid=listID;
        END IF;
        SELECT COUNT(chairperson_pinno) INTO pinCount FROM conference_table WHERE chairperson_pinno=CPIN;
        IF pinCount = 0 THEN
            DELETE FROM pinnumber_table WHERE chairperson_pinno=CPIN;
        END IF;
        SELECT COUNT(reservationid) INTO reserveCount FROM conference_table WHERE reservationid=reserveID;
        IF reserveCount = 0 THEN
        DELETE FROM conference_schedule_table WHERE reservationid=reserveID;
        DELETE FROM requisitionid_table WHERE reservationid=reserveID;
        DELETE FROM uid_table WHERE reservationid=reserveID;
        DELETE FROM reservation_table WHERE reservationid=reserveID;    
        END IF;

    END LOOP;   

    CLOSE cur;
END$$
View Answers









Related Pages:
Purge Data from Mysql tables
Purge Data from Mysql tables  Hi, i have to write a mysql procedure to purge data from tables. but written procedure clear entire tables data. Please give me the solution for purging data. CREATE DEFINER=`root`@`localhost
mysql select from multiple tables
mysql select from multiple tables   how can i select the date field from multiple tables in mysql?   "UNION" can be used to select data from multiple tables in my sql... for example (SELECT * from name where `name
Mysql Join 3 Tables
an example from 'Mysql Join 3 Tables' using Left Join. To grasp this example... Mysql Join 3 Tables       Mysql Join 3 Tables is used to join 3 Tables using left join
Mysql List Tables
Mysql List Tables       The Tutorial illustrate an example from 'Mysql  List Tables'. To understand this example we use show tables query that return the list of tables
how to retrieve data from multiple tables in jsp using javabeans
how to retrieve data from multiple tables in jsp using javabeans   ... for retrieving data fromm two tables : first table having fields: bookid,name...).second .java file for getting data from second table- package pack; public
how to retrieve data from multiple tables in jsp using javabeans
how to retrieve data from multiple tables in jsp using javabeans   ... for retrieving data fromm two tables : first table having fields: bookid,name...).second .java file for getting data from second table- package pack; public
how to retrieve data from multiple tables in jsp using javabeans
how to retrieve data from multiple tables in jsp using javabeans   ... for retrieving data fromm two tables : first table having fields: bookid,name...).second .java file for getting data from second table- package pack; public
How to Generate XML files from the data in DB tables?
How to Generate XML files from the data in DB tables?  HI Experts, I...").newInstance(); Connection conn = DriverManager.getConnection("jdbc:mysql...(); ResultSet rs=st.executeQuery("select * from employee where id=1
search in Two Tables to Find data and view by jsp
search in Two Tables to Find data and view by jsp  hi i want search in Two Tables to Find data and view by jsp <%@page import...(); %> <% conn = DriverManager.getConnection("jdbc:mysql://localhost
what is the jsp coding to insert a data in database tables
what is the jsp coding to insert a data in database tables  Dear Sir, I Want to know the coding for insert the data from jsp to oracle database.. my... departmentname and departmentid and click submit i want to save this data in my
sql query to get data from two tables
sql query to get data from two tables  how can i get the data from two different tables?   Hi Friend, Please visit the following link: JOIN Query Simple Query Thanks
Data fetch from multiple SQL tables - Hibernate
that would use table classes to retrieve data from 8 or 9 tables. Any example of HQL fetching data from multiple tables would be a help. I have tried...Data fetch from multiple SQL tables   I am in the process of writing
Mysql List Tables
Mysql List Tables       The Tutorial illustrate an example from 'Mysql  List Tables'. To understand this example we use show tables query that return the list of tables
Joins tables in jsp
Joins tables in jsp       When we want to select data from two or more tables... are two tables and result will be from both tables on the basis of 'ID' which
Retrieving Tables from a Database
Retrieving Tables from a Database   ... for retrieving tables from a specific database through an example. In relational.... It tells about the data of the data like number of tables in the database
Retrieve The Data From MySql Datbase
Retrieve The Data From MySql Datbase   How to Retrieve The Data From MYSQL database TO Use Select the Emp_id Option.And Also Search Option
inserting same data to different tables in oracle
inserting same data to different tables in oracle  Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracle
inserting same data to different tables in oracle  Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracle
inserting same data to different tables in oracle  Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracle
inserting same data to different tables in oracle  Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracle
inserting same data to different tables in oracle  Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracle
inserting same data to different tables in oracle  Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
Selecting particular data from multiple tables at database and perfoming calculations
Selecting particular data from multiple tables at database and perfoming... the output based on month) .. I have created 12 tables with table name - month1,month2,....,upto month12.. each table contains the data like name,amount,paiddate
store data from a variable in mysql?
store data from a variable in mysql?  sir last time asked you tell me how to retrieve data from a database mysql and store it in an int variable... of the calculation from an int variable into mysql in a new table of database. how
Cross Join Tables in a Specific Database
and outer join operation. The cross join is used to retrieve data from tables... join between two tables. The cross join operation retrieves data between two..., Emp_sal : This code is used to retrieve data form both tables as Cartesian
retrieve data from mysql database
retrieve data from mysql database  hi am not familiar in php.....even... selected value on combobox which is to be retrieve the relevant data from mysql...;/html> retcombosearch.php form is <?php mysql_connect ("localhost
Data retrieve from mysql database
Data retrieve from mysql database  Hi sir, please give some example of jsp code for retrieving mysql database values in multiple dropdown list... from the dropdown, related data will get displayed on the textboxes. Here we have
Join tables in the specific database
and tables in a database. Now to retrieve a particular row from a table...: It is a type of join that retrieves data within specified tables to specific... but it retrieves the data from the second table in the database. Description
types of relationships in tables
are implemented by splitting the data into two tables with primary key and foreign... table with the keys from both the tables forming the composite primary key...-to-many and many-to-many relationships while designing tables?   hi
JDBC Meta Data Get tables
JDBC Meta Data Get tables       JDBC Meta Data is the collective information about the data structure and property of a column available in table. The meta data of any
join tables mysql
) Here we are getting data from the two tables in the database... .style1 { font-weight: bold; } join tables mysql... and the result will be displayed in the browser. To join the tables firstly it is important
JSP hide and show tables
JSP hide and show tables In this tutorial, you will learn how to hide and show html tables using javascript in jsp. Here is an example of simple jsp code which is having a table consists of database data and a Go button. Using
php import data from excel to mysql
php import data from excel to mysql  php import data from excel to mysql
mysql
mysql  want the code for mysql nested select query with single where condition.want to select data from more than one table
Different tables present in MySQL
Different tables present in MySQL  What are the different tables present in MySQL? Which type of table is generated when we are creating a table...; Hi friends, Total 5 types of tables we can create 1. MyISAM 2. Heap 3
MySQL Create Database
and modification of tables. The MySQL Table Editor can be accessed from the MySQL Query... be accessed from MySQL Administrator through the Catalogs screen. Once you have... from the drop-down menu.      MySQL Editor
Fetch the data from mysql and display it on php form
Fetch the data from mysql and display it on php form  when i press on login button, after succesful login the related data of that person should be display in other textbox
I need to join three tables and return data that may not be in all three tables
I need to join three tables and return data that may not be in all three tables  How do I join three tables and return information even if it is in only two of the tables   Hi Friend, Please visit the following link
MYSQL retrieve record from Data table
MYSQL retrieve record from Data table  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from the field
Exporting data from mysql into csv using jsp
Exporting data from mysql into csv using jsp  Hi friends.... I want to export the data from mysql to csv file using... i am having 30 columns in my database.. Eg- text1,text2,text3,....,upto text30... i want to export this data
displaying data based on criteria from 2 tables having same type of data - Java Beginners
displaying data based on criteria from 2 tables having same type of data  Dear Experts, First, thanks for replying my question regarding my...: NameContactSubjects We have created following database tables: 1
extract data from excel sheet to mysql
extract data from excel sheet to mysql  sir, i want to extract data from excel sheet and save the data in mysql5.0 database in the form of table
retrieve data from mysql database and store it in a variable ?
retrieve data from mysql database and store it in a variable ?  sir , I am working on a project , in which I have to apply operation on input data which is stored in mysql. so to apply some arithmetic operation on it we have
how can i hide and show tables
the code is included below i want to hide the tables initially and after i click go i want to display the tables with result.so any help is appreciated much <... which is having a table consists of database data and a Go button. Using
Exporting data from mysql to csv file
Exporting data from mysql to csv file  Hi friends.... I want to export the data from mysql to csv file... i am having 30 columns in my database.. Eg... example that retrieves the data from the database and save it into csv file
mysql tables - JDBC
mysql tables  hi, I have a table in MySql, having fields, emp... mangager for MySQL, statements, preparedstatements,resultset. Please can you..."); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/databasename
updation of data in mysql
updation of data in mysql  http://www.roseindia.net/answers/viewqa/PHP/20822-Edit-the-record-.html sir , i want the above code as retreive of data from mysql ,but based on subject code(varchar) instead of id and my table format
access data from mysql through struts
access data from mysql through struts  I am Pradeep Kundu. I am making a program in struts in which i want to access data from MySQL through struts. I am using Strut 1.3.8 , Netbean 6.7.1 and MySQL 5.5. In this program ,I want
Inserting Data into mysql - SQL
Inserting Data into mysql  My sincere apologize for this post. I... into the SQL category though under php. I need help with reading from a csv file (using php)and inserting the details in a mysql database. Lets take for instance
Query for gathering info from 3 tables with condition depended on 4th table
Query for gathering info from 3 tables with condition depended on 4th table  I have 4 tables, 1 User profile (PK usrid), 2 Friend list(pk ugid), 3... a query in which I will get a data of people, there updates, and comments on updates

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.