Click here to Skip to main content
15,887,596 members
Home / Discussions / Database
   

Database

 
GeneralRe: MySQL syntax error.. Please help... Pin
Jassim Rahma2-Sep-13 23:13
Jassim Rahma2-Sep-13 23:13 
GeneralRe: MySQL syntax error.. Please help... Pin
GuyThiebaut2-Sep-13 23:16
professionalGuyThiebaut2-Sep-13 23:16 
GeneralRe: MySQL syntax error.. Please help... Pin
Jassim Rahma2-Sep-13 23:19
Jassim Rahma2-Sep-13 23:19 
GeneralRe: MySQL syntax error.. Please help... Pin
GuyThiebaut2-Sep-13 23:32
professionalGuyThiebaut2-Sep-13 23:32 
GeneralRe: MySQL syntax error.. Please help... Pin
Jassim Rahma2-Sep-13 23:56
Jassim Rahma2-Sep-13 23:56 
GeneralRe: MySQL syntax error.. Please help... Pin
Jassim Rahma3-Sep-13 0:22
Jassim Rahma3-Sep-13 0:22 
GeneralRe: MySQL syntax error.. Please help... Pin
Jassim Rahma3-Sep-13 1:43
Jassim Rahma3-Sep-13 1:43 
QuestionPL/Mysql - can't run procedure with sql security invoker Pin
noislude1-Sep-13 15:59
noislude1-Sep-13 15:59 
Good evening from Brazil. I granted select and update to the user but I still can't run the procedure below. What are the other privileges I need to grant to him?

delimiter // 
drop procedure if exists sp_optimistic_locking // 
create procedure sp_optimistic_locking 
(
  p_from_account int, 
  p_to_account int, 
  p_transfer_amount numeric(10,2),
  p_status int, 
  p_message varchar(100)
)
sql security invoker
modifies sql data 
begin 
  declare l_account_balance1 numeric(10,2);
  declare l_account_balance2 numeric(10,2);
  declare l_account_timestamp1 timestamp; 
  declare l_account_timestamp2 timestamp; 
  
  select balance, account_timestamp into l_account_balance1, l_account_timestamp1
  from account_balance where account_id = p_from_account;  
  
  if l_account_balance1 >= p_transfer_amount then 

  start transaction; 

  -- call long_running_validation(p_from_account);

  select balance, account_timestamp into l_account_balance2, l_account_timestamp2 
  from account_balance where account_id = p_from_account for update; 
    
    if (l_account_balance1 <> l_account_balance2 or 
        l_account_timestamp1 <> l_account_timestamp2) then
       rollback; 
       set p_status = -1; 
       set p_message = concat('Transaction canceled due to previous update of account ', p_from_account);
    else 
       update account_balance set balance = balance - p_transfer_amount where 
       account_id = p_from_account; 
 
       update account_balance set balance = balance + p_transfer_amount where 
       account_id = p_to_account; 

       commit;
       set p_status  = 0; 
       set p_message = 'transaction ok'; 
    end if;
    else  
     set p_status = -1; 
     set p_message = 'Transaction canceled due to account balance less than desired withdrawal'; 
  end if; 
     select 'Transaction code', p_status; 
     select 'Transaction message', p_message;
end; 
//

QuestionPL/MySQL - can't load file Pin
noislude1-Sep-13 4:22
noislude1-Sep-13 4:22 
QuestionCan't create table - SQL 2008 R2 Pin
ThetaClear1-Sep-13 3:15
ThetaClear1-Sep-13 3:15 
AnswerRe: Can't create table - SQL 2008 R2 Pin
PIEBALDconsult1-Sep-13 3:35
mvePIEBALDconsult1-Sep-13 3:35 
GeneralRe: Can't create table - SQL 2008 R2 Pin
ThetaClear1-Sep-13 3:40
ThetaClear1-Sep-13 3:40 
GeneralRe: Can't create table - SQL 2008 R2 Pin
PIEBALDconsult1-Sep-13 3:53
mvePIEBALDconsult1-Sep-13 3:53 
GeneralRe: Can't create table - SQL 2008 R2 Pin
ThetaClear1-Sep-13 3:57
ThetaClear1-Sep-13 3:57 
GeneralRe: Can't create table - SQL 2008 R2 Pin
PIEBALDconsult1-Sep-13 4:06
mvePIEBALDconsult1-Sep-13 4:06 
GeneralRe: Can't create table - SQL 2008 R2 Pin
ThetaClear1-Sep-13 6:30
ThetaClear1-Sep-13 6:30 
GeneralRe: Can't create table - SQL 2008 R2 Pin
PIEBALDconsult1-Sep-13 6:37
mvePIEBALDconsult1-Sep-13 6:37 
GeneralRe: Can't create table - SQL 2008 R2 Pin
ThetaClear1-Sep-13 8:19
ThetaClear1-Sep-13 8:19 
GeneralRe: Can't create table - SQL 2008 R2 Pin
PIEBALDconsult1-Sep-13 8:25
mvePIEBALDconsult1-Sep-13 8:25 
GeneralRe: Can't create table - SQL 2008 R2 Pin
ThetaClear1-Sep-13 8:47
ThetaClear1-Sep-13 8:47 
GeneralRe: Can't create table - SQL 2008 R2 Pin
PIEBALDconsult2-Sep-13 17:47
mvePIEBALDconsult2-Sep-13 17:47 
Question[SOLVED] PL/MySQL - Duplicated last row Pin
noislude29-Aug-13 3:58
noislude29-Aug-13 3:58 
QuestionHelp Me Pin
Kailashkumar Raghvani28-Aug-13 21:57
Kailashkumar Raghvani28-Aug-13 21:57 
AnswerRe: Help Me Pin
Ingo28-Aug-13 22:30
Ingo28-Aug-13 22:30 
AnswerRe: Help Me Pin
Simon_Whale29-Aug-13 0:13
Simon_Whale29-Aug-13 0:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.