MySQL Forums :: Stored Procedures :: Problem with stored procedures on phpmyadmin


Advanced Search

Problem with stored procedures on phpmyadmin
Posted by: Andrew James ()
Date: August 11, 2016 03:20PM

Hi,

I'm having some problem with stored procedure in phpmyadmin since I got an error that says:

"- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as
begin
if not exists(select files.Files,Users.FirstName,Users.LastName,Users' at line 2"


Here's my stored procedure:

CREATE procedure GetallFiles()
as
begin
if not exists(select files.Files,Users.FirstName,Users.LastName,Users.EmailAddress from files,Users
where files.UserID = Users.UserID)
raiserror('cannot find files records',16,1)
end
begin

select files.Files,Users.firstname,Users.lastname,Users.EmailAddress from files,Users
where files.UserID = Users.UserID
end
return

Here's my table



-- Table structure for table `files`
--

CREATE TABLE `files` (
`FileID` int(11) NOT NULL,
`UserID` int(11) NOT NULL,
`Files` varchar(500) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `roles`
--

CREATE TABLE `roles` (
`RoleID` varchar(1) NOT NULL,
`Rolename` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `roles`
--

INSERT INTO `roles` (`RoleID`, `Rolename`) VALUES
('A', 'Admin'),
('U', 'UserName');

-- --------------------------------------------------------

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
`UserID` int(11) NOT NULL,
`FirstName` varchar(30) NOT NULL,
`LastName` varchar(30) NOT NULL,
`Password` varchar(30) NOT NULL,
`EmailAddress` varchar(30) NOT NULL,
`Salt` varchar(40) NOT NULL,
`RoleID` varchar(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `users`
--

INSERT INTO `users` (`UserID`, `FirstName`, `LastName`, `Password`, `EmailAddress`, `Salt`, `RoleID`) VALUES
(1, 'eric', 'James', 'andrew', 'james@gmail.com', '2', 'A'),
(2, 'mario', 'James', 'michael', 'michael@gmail.com', '2', 'U');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `files`
--
ALTER TABLE `files`
ADD PRIMARY KEY (`FileID`,`UserID`),
ADD KEY `UserID` (`UserID`);

--
-- Indexes for table `roles`
--
ALTER TABLE `roles`
ADD PRIMARY KEY (`RoleID`);

--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`UserID`),
ADD KEY `RoleID` (`RoleID`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `files`
--
ALTER TABLE `files`
MODIFY `FileID` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `UserID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- Constraints for dumped tables
--

--
-- Constraints for table `files`
--
ALTER TABLE `files`
ADD CONSTRAINT `files_ibfk_1` FOREIGN KEY (`UserID`) REFERENCES `users` (`UserID`);

--
-- Constraints for table `users`
--
ALTER TABLE `users`
ADD CONSTRAINT `users_ibfk_1` FOREIGN KEY (`RoleID`) REFERENCES `roles` (`RoleID`);

Options: ReplyQuote


Subject Views Written By Posted
Problem with stored procedures on phpmyadmin 2679 Andrew James 08/11/2016 03:20PM
Re: Problem with stored procedures on phpmyadmin 334 Peter Brawley 08/11/2016 06:41PM
Re: Problem with stored procedures on phpmyadmin 292 Andrew James 08/12/2016 12:07PM
Re: Problem with stored procedures on phpmyadmin 303 Peter Brawley 08/12/2016 12:31PM
Re: Problem with stored procedures on phpmyadmin 302 Andrew James 08/16/2016 02:37PM
Re: Problem with stored procedures on phpmyadmin 273 Peter Brawley 08/16/2016 02:52PM
Re: Problem with stored procedures on phpmyadmin 305 Andrew James 08/17/2016 11:23AM
Re: Problem with stored procedures on phpmyadmin 288 Peter Brawley 08/17/2016 12:17PM
Re: Problem with stored procedures on phpmyadmin 292 Andrew James 08/17/2016 02:35PM
Re: Problem with stored procedures on phpmyadmin 289 Peter Brawley 08/17/2016 04:19PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.