0

How can i pass string in values rather than passing each value. Receiving error

Error Code: 1136. Column count doesn't match value count at row 1

  INSERT INTO `ProfileResumeActivityLog`
    (`Email`,`ProfileID`,`ExternalUserDID`, `EventType`, `ResumeDID`, `EventText`, `CreatedOn`)
    VALUES('checkpp@test.com,73443358,XR2Z1WT6WR5PPR6Z99L4,r
 esume_backload,R3W6WN6LFY95PKL27SR,resume_create, NOW()' );

I want to pass this as string because my stored procedure takes dynamic number of values for batch insert

CREATE DEFINER=`root`@`localhost` PROCEDURE `SaveBatchMultipleProfileResumeActivityLog`(
    _resumeBatch            TEXT

)
BEGIN

    INSERT INTO `ProfileResumeActivityLog`
    (`Email`,`ProfileID`,`ExternalUserDID`, `EventType`, `ResumeDID`, `EventText`, `CreatedOn`)
    VALUES(_resumeBatch);
    
END

calling

CALL CBAX.SaveBatchMultipleProfileResumeActivityLog   ('checkpp@test.com,73443358,XR2Z1WT6WR5PPR6Z99L4,resume_backload,R3W6WN6LFY95PKL27SR,resume_create, NOW()',

'checkpp@test1.com,73443358,XR2Z1WT6WR5PPR6Z99L41,resume_backload,R3W6WN6LFY95PKL27SR1,resume_create, NOW()' )
art
  • 226
  • 3
  • 11
  • 30
  • 1
    You have to add individual string not as a whole. `'checkpp@test.com', 73443358, 'XR2Z1WT6WR5PPR6Z99L4'` and so on. – GodWin1100 Aug 05 '22 at 11:07
  • i want to use in case multiple values also come @GodWin – art Aug 05 '22 at 11:08
  • check call to stored proc @Madmax i edited question – art Aug 05 '22 at 11:12
  • When sending one string, you can split it into different values as is explained here: [MySQL substring extraction using delimiter](https://stackoverflow.com/questions/34992575/mysql-substring-extraction-using-delimiter) – Luuk Aug 05 '22 at 11:16
  • @Luuk could you please answer how we will do here – art Aug 05 '22 at 11:17
  • You need a function to do the splitting, there are multiple links in the link I gave you. Try some of them, it's not hard, and you will gain some experience doing so. At the end you will have a correct working function to solve your problem. (Succes with testing/debugging!) – Luuk Aug 05 '22 at 11:22

1 Answers1

0

when you put string inside a insert statement you have to put them inside a "" thats why you get that error.

INSERT INTO `ProfileResumeActivityLog`(`Email`,`ProfileID`,`ExternalUserDID`, `EventType`, `ResumeDID`, `EventText`, `CreatedOn`)
VALUES('checkpp@test.com',73443358,'XR2Z1WT6WR5PPR6Z99L4','resume_backload','R3W6WN6LFY95PKL27SR','resume_create', NOW() );
Mad max
  • 99
  • 2
  • 10