dbTalk Databases Forums  

Re: execute a command string

sybase.public.sqlanywhere.general sybase.public.sqlanywhere.general


Discuss Re: execute a command string in the sybase.public.sqlanywhere.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Breck Carter [Team iAnywhere]
 
Posts: n/a

Default Re: execute a command string - 10-25-2007 , 12:17 PM






Try adding a space: exec ('grant dba to '||@appo)

On 25 Oct 2007 09:48:43 -0700, mauro compagnoni wrote:

Quote:
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


Reply With Quote
  #2  
Old   
mauro compagnoni
 
Posts: n/a

Default Re: execute a command string - 10-25-2007 , 02:09 PM






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

Quote:
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

Reply With Quote
  #3  
Old   
anil k goel
 
Posts: n/a

Default Re: execute a command string - 10-25-2007 , 02:34 PM



select Login into @appo from Speedy.RemoteAccount where ...

-anil
--
Query Processing, SQL Anywhere R&D


<mauro compagnoni> wrote

Quote:
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



Reply With Quote
  #4  
Old   
anil k goel
 
Posts: n/a

Default Re: execute a command string - 10-25-2007 , 02:43 PM



Sorry, please ignore my last response.

-anil
--
Query Processing, SQL Anywhere R&D



Reply With Quote
  #5  
Old   
Breck Carter [Team iAnywhere]
 
Posts: n/a

Default Re: execute a command string - 10-25-2007 , 02:46 PM



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

On 25 Oct 2007 12:09:38 -0700, mauro compagnoni wrote:

Quote:
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
--
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


Reply With Quote
  #6  
Old   
mauro compagnoni
 
Posts: n/a

Default Re: execute a command string - 10-26-2007 , 01:24 AM



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

Quote:
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


Reply With Quote
  #7  
Old   
Frank Ploessel
 
Posts: n/a

Default Re: execute a command string - 10-26-2007 , 02:41 AM



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:

Quote:
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



Reply With Quote
  #8  
Old   
mauro compagnoni
 
Posts: n/a

Default Re: execute a command string - 10-26-2007 , 03:05 AM



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

Quote:
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



Reply With Quote
  #9  
Old   
Breck Carter [Team iAnywhere]
 
Posts: n/a

Default Re: execute a command string - 10-26-2007 , 07:36 AM



Please show us the ENTIRE script you are executing, and tell us how it
is executed.

The following two code samples work OK in Sybase Adaptive Server
Anywhere Database Engine Version 6.0.4.3594. I was not able to get
"execute ( string )" to work properly in pure Transact SQL syntax. The
following examples look a bit *like* Transact SQL but all the
semicolons mean it's really Watcom SQL. I am not sure Transact SQL had
"execute immediate" functionality nine years ago, which is when ASA 6
was released (1998).

Breck

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;

On 26 Oct 2007 01:05:53 -0700, mauro compagnoni wrote:

Quote:
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


--
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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.