![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
hi, i have a problem in executing a command. i want to grant administrator rights to another user, but i have to select it in a table. this is my code: declare @appo varchar (20) select @appo=Login from Speedy.RemoteAccount where ... exec ('grant dba to'||@appo) but i have an error. do you know which is the correct syntax? thanks in advance best regards Mauro |
#2
| |||
| |||
|
|
Try adding a space: exec ('grant dba to '||@appo) On 25 Oct 2007 09:48:43 -0700, mauro compagnoni wrote: hi, i have a problem in executing a command. i want to grant administrator rights to another user, but i have to select >it in a table. this is my code: declare @appo varchar (20) select @appo=Login from Speedy.RemoteAccount where ... exec ('grant dba to'||@appo) but i have an error. do you know which is the correct syntax? thanks in advance best regards Mauro -- Breck Carter [Team iAnywhere] RisingRoad SQL Anywhere and MobiLink Professional Services www.risingroad.com The book: http://www.risingroad.com/SQL_Anywhe...ers_Guide.html breck.carter (AT) risingroad (DOT) com |
#3
| |||
| |||
|
|
thanks for the answer, but i have a 'syntax error near @appo', so in the creation of the string, not in its execution best regards Mauro Try adding a space: exec ('grant dba to '||@appo) On 25 Oct 2007 09:48:43 -0700, mauro compagnoni wrote: hi, i have a problem in executing a command. i want to grant administrator rights to another user, but i have to select >it in a table. this is my code: declare @appo varchar (20) select @appo=Login from Speedy.RemoteAccount where ... exec ('grant dba to'||@appo) but i have an error. do you know which is the correct syntax? thanks in advance best regards Mauro -- Breck Carter [Team iAnywhere] RisingRoad SQL Anywhere and MobiLink Professional Services www.risingroad.com The book: http://www.risingroad.com/SQL_Anywhe...ers_Guide.html breck.carter (AT) risingroad (DOT) com |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
thanks for the answer, but i have a 'syntax error near @appo', so in the creation of the string, not in its execution best regards Mauro Try adding a space: exec ('grant dba to '||@appo) On 25 Oct 2007 09:48:43 -0700, mauro compagnoni wrote: hi, i have a problem in executing a command. i want to grant administrator rights to another user, but i have to select >it in a table. this is my code: declare @appo varchar (20) select @appo=Login from Speedy.RemoteAccount where ... exec ('grant dba to'||@appo) but i have an error. do you know which is the correct syntax? thanks in advance best regards Mauro -- Breck Carter [Team iAnywhere] RisingRoad SQL Anywhere and MobiLink Professional Services www.risingroad.com The book: http://www.risingroad.com/SQL_Anywhe...ers_Guide.html breck.carter (AT) risingroad (DOT) com |
#6
| |||
| |||
|
|
Oops, sorry... the keyword is "execute", not exec... plus you still need the space ![]() Here are the Transact SQL and Watcom SQL versions... both these samples work OK with SQL Anywhere Personal Server Version 10.0.1.3559 GRANT CONNECT TO XXX IDENTIFIED BY SQL; BEGIN declare @appo varchar (20) select @appo='XXX' execute ('grant dba to '||@appo) END GRANT CONNECT TO XXX IDENTIFIED BY SQL; BEGIN declare @appo varchar (20); SET @appo='XXX'; execute immediate 'grant dba to ' || @appo; END; Breck |
#7
| |||
| |||
|
thanks again..i've set the space ![]() but the error is still there! 'syntax error near @appo' in the first case and 'procedure immediate not found' in the second... is it possible that this is due to a previous version of Sybase? infact i have ASA 6.0.4...not the last one...does they have a different syntax? (anyway, in the manuals the syntax is this...) best regards Mauro Oops, sorry... the keyword is "execute", not exec... plus you still need the space ![]() Here are the Transact SQL and Watcom SQL versions... both these samples work OK with SQL Anywhere Personal Server Version 10.0.1.3559 GRANT CONNECT TO XXX IDENTIFIED BY SQL; BEGIN declare @appo varchar (20) select @appo='XXX' execute ('grant dba to '||@appo) END GRANT CONNECT TO XXX IDENTIFIED BY SQL; BEGIN declare @appo varchar (20); SET @appo='XXX'; execute immediate 'grant dba to ' || @appo; END; Breck |
#8
| |||
| |||
|
|
Mauro, I think in older SQL Anywhere versions, EXECUTE IMMEDIATE was only available in Watcom SQL, not in Transact SQL. I do not remember exactly, but I think Sybase Central always had a possibility to convert stored procedure code from one of these SQL dialects to the other. HTH Frank On Fri, 26 Oct 2007 08:24:18 +0200, mauro <compagnoni wrote: thanks again..i've set the space ![]() but the error is still there! 'syntax error near @appo' in the first case and 'procedure immediate not found' in the second... is it possible that this is due to a previous version of Sybase? infact i have ASA 6.0.4...not the last one...does they have a different syntax? (anyway, in the manuals the syntax is this...) best regards Mauro Oops, sorry... the keyword is "execute", not exec... plus >> you still need the space ![]() Here are the Transact SQL and Watcom SQL versions... both >> these samples work OK with SQL Anywhere Personal Server >> Version 10.0.1.3559 GRANT CONNECT TO XXX IDENTIFIED BY SQL; BEGIN declare @appo varchar (20) select @appo='XXX' execute ('grant dba to '||@appo) END GRANT CONNECT TO XXX IDENTIFIED BY SQL; BEGIN declare @appo varchar (20); SET @appo='XXX'; execute immediate 'grant dba to ' || @appo; END; Breck |
#9
| |||
| |||
|
|
hi Frank, thanks for the info, but also if i tried in the correct syntax i have the problem. in fact if i launch: execute ( 'grant dba to Remote_01418') everything works fine, but if i launch: select @appo = 'grant dba to Remote_01418' execute (@appo) i have a "syntax error near @appo". unlucky i have to use the string in a 'while' execution, so i need to create a string variable. best regards Mauro Mauro, I think in older SQL Anywhere versions, EXECUTE IMMEDIATE was only available in Watcom SQL, not in Transact SQL. I do not remember exactly, but I think Sybase Central always had a possibility to convert stored procedure code from one of these SQL dialects to the other. HTH Frank On Fri, 26 Oct 2007 08:24:18 +0200, mauro <compagnoni wrote: thanks again..i've set the space ![]() but the error is still there! 'syntax error near @appo' in the first case and 'procedure immediate not found' in the second... is it possible that this is due to a previous version of Sybase? infact i have ASA 6.0.4...not the last one...does they have a different syntax? (anyway, in the manuals the syntax is this...) best regards Mauro Oops, sorry... the keyword is "execute", not exec... plus >> you still need the space ![]() Here are the Transact SQL and Watcom SQL versions... both >> these samples work OK with SQL Anywhere Personal Server >> Version 10.0.1.3559 GRANT CONNECT TO XXX IDENTIFIED BY SQL; BEGIN declare @appo varchar (20) select @appo='XXX' execute ('grant dba to '||@appo) END GRANT CONNECT TO XXX IDENTIFIED BY SQL; BEGIN declare @appo varchar (20); SET @appo='XXX'; execute immediate 'grant dba to ' || @appo; END; Breck |
![]() |
| Thread Tools | |
| Display Modes | |
| |