Declaring Sybase local variables

Hi, I am new to Sybase. I tried to declare local variables in an isql session on Hp-ux.
> declare @count int
> go
I get a syntax on count. This is an example straight from the book. I think the problem could be with the emulator's interpretation of metacharacters?

Could somebody help me overcome the problem?
I tried three different emulators Outsideview, QVT and Secure CRT,

-Thanks
Krishna
kthotaAsked:
Who is Participating?
 
amitpagarwalCommented:
u got that error as count is a reserved word in sybase.

try some other variable name
0
 
Alex_nlCommented:
I'm not sure but could it be that 'count' is a reserved word so you cannot use it? What if you tried another variable name like icount or something?

Alex
0
 
NickMorganCommented:
What is the exact error message?
Count is a reserved word but I don't think that should be a problem.

Try
select @@servername
go

which should return your sybase server name.

Cheers,Nick
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
ahoorCommented:
Khota,
should not be a problem... so you get the error from the declare or
afterwards when you try to use it...

this is a copy created on Sun

1> declare @count int
2> go
1> select @count = 1
2> go
Msg 137, Level 15, State 1:
Server 'SYBASE25', Line 1:
Must declare variable '@count'.
1>

The declare goes well but you can't use it because it's not in a batch.
In that case, you use begin/end.

1> begin
2> declare @count int
3> select @count = 1
4> select @count
5> end
6> go
(1 row affected)

 -----------
           1
(1 row affected)
1>
0
 
kthotaAuthor Commented:
Hi Guys,
       None of the above suggestions seem to work. I am pasting what I did for you perusal. I think the issue is not with the syntax one way or the other. This should be an emulation issue. But I don't know a whole lot about emulators to change the configuration. Actually I tried using atleast three different emulators, namely Outside view, Qvtnet, Secure-crt and even a plain run telnet from windows 98.This last one was emulating VT-100/ANSI.
1> declare @vchar varchar(20)
2> go
Msg 102, Level 15, State 1:
Line 1:
Incorrect syntax near '20'.
1> declare @vchar varchar(20)
2> go
Msg 102, Level 15, State 1:
Line 1:
Incorrect syntax near '20'.
1>

Hope somebody can shed light on the quirks of emulators
-Krishna              
0
 
ajith_29Commented:
hi kthota,
Do not use go after the declare statement when u have finished giving the commands to be done by the server then give the go.The go is used to show that your through with your commands and its time for the sql to be executed in simple terms.
If you have a go after the declare then the variable is not found by the sql because its gone in another session.
The simple answers is after you finished typing the commands then use go statement.
0
 
kthotaAuthor Commented:
Hi Ajith, I don't think there is anything wrong with executing a go after declaring local variable.After the declaration I could say select @vchar1 to display the null contents of the variable and then say go. That would still not help.
1>
2> declare @vchar1 varchar(20)
3> select @vchar1
4> go
Msg 102, Level 15, State 1:
Line 2:
Incorrect syntax near '20'.
1>                        
Do you see anything wrong in what I typed above. If so how would I ever get to use the variables without the go. The above would be a simple test batch

Again I think this a problem with the emulator that I am using. Somehow things are not fine between isql and my emulator. I do not have any problems using the emulator for performing other unix tasks
-Krishna
0
 
andresCommented:
try bellow:

declare @vchar1 varchar;
select @vchar1;
go
0
 
kthotaAuthor Commented:
Hi,
   I could get what ever I typed from a script. But the same does  not work interactively. Even with the script I had to do a CTRL V before typing @. I wonder what could be done to make this work interactively
0
 
jesumibCommented:
Hi kthota,

Maybe something in your isql in unix is wrong.

I think you can use other software to get interactivity to Sybase, not to change the emulators.

Example, I like to use RapidSQL from Embarcadero http://www.embarcadero.com/ 

There is a evaluation to download, you
only need open client in your PC to define your server in sql.ini, i.e.

[HP9000]
query=NLWNSCK,132.1.1.3,4050


0
 
ahoorCommented:
Amit etc please read previous responses before posting an answer *sigh*
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.