Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6750317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:47:36+00:00 2026-05-26T12:47:36+00:00

This is quite a strange problem, so first I will post the procedure: DELIMITER

  • 0

This is quite a strange problem, so first I will post the procedure:

DELIMITER $$

USE `blahblahblah`$$

DROP PROCEDURE IF EXISTS `duplicateTradeIn`$$

CREATE DEFINER=`blahblahblah` PROCEDURE `duplicateTradeIn`(duplicate_claim INT(12))
BEGIN

DECLARE valuation INT(12) DEFAULT 0;
DECLARE claim INT(12) DEFAULT 0;
DECLARE serialNumber VARCHAR(255);
DECLARE duplicates INT(12);
DECLARE i INT(12) DEFAULT 1;
DECLARE claimID INT(12);

SET @claimID = duplicate_claim;
SET @duplicates = (SELECT COUNT(*) FROM `duplicates`);
SET @i = 1;

WHILE @i <= @duplicates DO

    SET @serialNumber = (SELECT `serial` FROM `duplicates` WHERE id = @i);

    INSERT INTO valuations (`pID`,`boughtproduct`,`valuationType`,`valuationAmount`,`working`,`accessories`,`age`,`brand`,`qty`,`created`,`valuationStatus`)
    SELECT `pID`,`boughtproduct`,`valuationType`,`valuationAmount`,`working`,`accessories`,`age`,`brand`,`qty`,`created`,`valuationStatus`
    FROM valuations WHERE vID = (SELECT vID FROM claims WHERE cID = @claimID);

    SET @valuation = (SELECT LAST_INSERT_ID());

    INSERT INTO claims (`vID`, `pID`, `email`, `title`, `firstname`, `lastname`, `customerType`, `company`, `position`, `address1`,`address2`,`town`,`county`,`postCode`,`telephone`,`mobile`,`emailBusiness`,`emailConsumer`,`contactPost`,`contactTelephone`,`contactMobile`,`contactEmail`,`invoiceNum`,`invoiceDate`,`invoiceInc`,`reseller`,`dateOfOrder`,`heardAbout`,`salesPerson`,`method`,`cleanseCert`,`blanccoCert`,`created`,`modified`,`noInvEmailDated`,`lateRejEmailSent`,`invAddressEmailSent`,`revalueEmailSent`,`signed`,`dated`,`sessionID`,`received`,`receiptSent`,`processedDate`,`validatedDate`,`rejectedDate`,`rejectReason`,`notes`,`claimStatus`,`origin`,`invoiceexported`)
    SELECT @valuation, `pID`, `email`, `title`, `firstname`, `lastname`, `customerType`, `company`, `position`, `address1`,`address2`,`town`,`county`,`postCode`,`telephone`,`mobile`,`emailBusiness`,`emailConsumer`,`contactPost`,`contactTelephone`,`contactMobile`,`contactEmail`,`invoiceNum`,`invoiceDate`,`invoiceInc`,`reseller`,`dateOfOrder`,`heardAbout`,`salesPerson`,`method`,`cleanseCert`,`blanccoCert`,`created`,`modified`,`noInvEmailDated`,`lateRejEmailSent`,`invAddressEmailSent`,`revalueEmailSent`,`signed`,`dated`,`sessionID`,`received`,`receiptSent`,`processedDate`,`validatedDate`,`rejectedDate`,`rejectReason`,`notes`,`claimStatus`,`origin`,`invoiceexported`
    FROM claims WHERE cID = @claimID;

    SET @claim = (SELECT LAST_INSERT_ID());

    INSERT INTO documents (`claimid`,`serial`,`filename`,`filenameOrig`,`filenameTemp`,`filetype`,`filesize`)
    SELECT @claim,`serial`,`filename`,`filenameOrig`,`filenameTemp`,`filetype`,`filesize`
    FROM documents WHERE claimid = @claimID;

    INSERT INTO redemptions (`cID`,`pID`,`prID`,`bundleNo`,`serialNum`,`price`,`cashback`,`created`,`modified`,`claimStatus`)
    SELECT @claim,`pID`,`prID`,`bundleNo`,@serialNumber,`price`,`cashback`,`created`,`modified`,`claimStatus`
    FROM redemptions WHERE cID = @claimID;

    INSERT INTO tradeins (`vID`,`cID`,`valuationType`,`valuationAmount`,`working`,`accessories`,`age`,`created`,`brand`,`claimStatus`)
    SELECT @valuation,@claim,`valuationType`,`valuationAmount`,`working`,`accessories`,`age`,`created`,`brand`,`claimStatus`
    FROM tradeins WHERE cID = @claimID;

    SET @i = (@i + 1);

END WHILE;
END$$

DELIMITER ;

EDIT: Sorry!

The problem is when it tries to insert into documents (So refer to the documents table insert). If I rename the column (claimid) in the WHERE clause and INSERT to cID (by altering the table and query) it works, but otherwise it refuses to insert the new rows when it is named claimid not cID. If you have any ideas or insight into this it would be much appreciated.

To try and clarify:

Documents table with field and query as cID not claimid works.
Documents table with field and query as claimid does not insert rows.

All of the other queries seem to work fine and it only occurred to me to try cID in the documents table as that was the only difference.

Again sorry for the vagueness before and I hope the question is now clearer.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:47:36+00:00Added an answer on May 26, 2026 at 12:47 pm

    Just to clear this up. It is as I stated and maybe a bug in mySQL? If there is a table with a field where the ID name differs. In this example cID and claimid then it will not recognise the second declared field claimid and not perform the query.

    In order for this to work I had to revise the documents table from claimID to cID.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a quite strange problem. I have set a setting variable in Application
First off, thanks to whomever is reading this. I have a very strange problem
This might be quite a strange question since usually people bind only complex types
I am intentionally leaving this quite vague at first. I'm looking for discussion and
I have this quite popular problem, but have failed to find a solution that
I am facing quite a strange problem at the moment, I have wordpress and
I've got this strange problem using py-amqp and the Flopsy module. I have written
I'm trying to write quite strange query and i'm having problem with if statement,
I'm having a quite strange problem with the fwd_iterator that I'm implementing: if I
I'm new to Drupal and am experiencing this strange problem with my testing Drupal

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.