1
votes

I'm new to stored procedure and I don't know much. I'm testing with an example. Could you help me? Here is my stored procedure

DELIMITER $$

DROP PROCEDURE IF EXISTS dictionarytable$$

CREATE PROCEDURE dictionarytable(id VARCHAR(20),name VARCHAR(20),work VARCHAR(20),place VARCHAR(20),mobileno VARCHAR(20),bike VARCHAR(20),car VARCHAR(20),homeno VARCHAR(20),dictionaytype VARCHAR(20),meaning VARCHAR(20),sentence VARCHAR(20),antonym VARCHAR(20),synonym VARCHAR(20))

BEGIN

select id,name,work,place,mobileno,bike,car,homeno,dictionaytype,meaning,sentence,antonym,synonym from dictionary INTO dictionarytable; END $$

DELIMITER ; I wanted id,name,13 columns from dictionary(table) to be called in stored procedure dictionarytable the query in the Begin is wrong could you specify a query to display all 13 columns

1

1 Answers

1
votes

You cannot pass field values INTO the procedure, you can pass them INTO user variables, declared variables or OUT paramaters. Note, that only one record can be passed when INTO clause is used. For example:

SET @var1 = NULL;
SELECT column1 INTO @var1 FROM table;

If you want to copy more then one record, then you can use INSERT INTO...SELECT statement to copy data-set to second table. For example:

INSERT INTO table2 SELECT column1 FROM table;

Also, if you want to use variables or parameters as identifiers (field names in your case), then you should use prepared statements.