Jump to content

Recommended Posts

Mysql server version: 5

 

In database abc_spare1, I'm trying to copy particular columns of data, from phpbb2_posts_text1 into phpbb3_posts3.

 

Specifically, I'm trying to copy the data, from phpbb2_posts_text1's bbcode_uid, post_subject, and post_text columns and insert it into phpbb3_posts3's bbcode_uid, post_subject, and post_text columns.

 

Following is the code I employed:

 

Code: Select all

    delimiter //

    use abc_spare1;

    CREATE PROCEDURE Getdata1()

    BEGIN

    DECLARE COUNTER1 INT DEFAULT 0;

    DECLARE bbcode_uid VARCHAR(10);

    DECLARE post_subject VARCHAR(60);

    DECLARE post_text TEXT;

    DECLARE CUR CURSOR FOR SELECT * FROM phpbb2_posts_text1;

    DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET COUNTER1=1;

    DECLARE CONTINUE HANDLER FOR SQLSTATE '23000' SET COUNTER1=1;

    OPEN CUR;

    LOOP1: LOOP

    IF COUNTER1=1 THEN

    LEAVE LOOP1;

    END IF;

    IF NOT COUNTER1=1 THEN

    FETCH CUR INTO bbcode_uid,post_subject,post_text;

    INSERT INTO phpbb3_posts3 VALUES(bbcode_uid,post_subject,post_text);

    END IF;

    END LOOP;

    CLOSE CUR;

    END;

    //

 

 

 

The code appears to run without errors, but I don't see any data showing up in the phpbb3_posts3 columns.

 

I would appreciate if you could tell me how to fix this.

 

- r

Link to comment
https://forums.phpfreaks.com/topic/208930-no-results/
Share on other sites

Looking at my problem, from a different angle, I'm trying to horizontally merge two tables (phpbb2_posts & phpbb2_posts_text) which share a common column (post_id).

 

They exist in the same database and the merger should result in the creation of a new table.

 

I tried adding popbb2_posts' column headings to phpbb2_posts_text and then inserting the data, but, that did not work. So, I tried doing the same with phpbb2_posts_text, but that didn't work, either.

 

I tried going the procedure route, above, but that didn't work.

 

I know it can be done, but I haven't been able to figure it out, yet.

 

phpbb2_posts consists of the following 13 columns:

 

post_id

topic_id

forum_id

poster_id

post_time

poster_ip

post_username

enable_bbcode

enable_html

enable_smilies

enable_sig

post_edit_time

post_edit_count

 

 

phpbb2_posts_text consists of the following 4 columns:

 

post_id

bbcode_uid

post_subject

post_text

 

Does anyone know to horizontally merge these two tables?

 

- r

Link to comment
https://forums.phpfreaks.com/topic/208930-no-results/#findComment-1092072
Share on other sites

I tried the following code to insert the contents of 3 columns, from phpbb2_posts_text, into 3 columns of phpbb3_posts3.

 

Both tables are located in the same database.

 

Further, phpbb3_posts3's post_id column already exists and sequentially increases, from 2 to 218727.

 

 

 

 

UPDATE phpbb2_posts_text A, phpbb3_posts3 B

SET B.bbcode_uid=A.bbcode_uid,B.post_subject=A.post_subject,B.post_text=A.post_text

WHERE B.post_id<=218727

 

 

 

 

Unfortunately, the above code resulted in the following error message:

 

SQL Error (1): Can't create/write to file '/tmp/#sql_4bd9_0.myi' (Errcode:13)

 

I have a feeling that the error is not code-related, but I would appreciate learning your opinion on how to remedy it.

 

Please reply.

 

- r

Link to comment
https://forums.phpfreaks.com/topic/208930-no-results/#findComment-1092410
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.