Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Declaring Sybase local variables

Posted on 2000-03-31
11
Medium Priority
?
3,091 Views
Last Modified: 2008-03-17
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
0
Comment
Question by:kthota
11 Comments
 

Expert Comment

by:Alex_nl
ID: 2675758
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
 

Expert Comment

by:NickMorgan
ID: 2679184
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
 
LVL 3

Expert Comment

by:ahoor
ID: 2679278
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
Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

 

Author Comment

by:kthota
ID: 2680658
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
 
LVL 2

Expert Comment

by:ajith_29
ID: 2690330
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
 

Author Comment

by:kthota
ID: 2694040
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
 
LVL 1

Expert Comment

by:andres
ID: 2724072
try bellow:

declare @vchar1 varchar;
select @vchar1;
go
0
 

Author Comment

by:kthota
ID: 2724149
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
 

Expert Comment

by:jesumib
ID: 2797294
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
 
LVL 5

Accepted Solution

by:
amitpagarwal earned 10 total points
ID: 2919636
u got that error as count is a reserved word in sybase.

try some other variable name
0
 
LVL 3

Expert Comment

by:ahoor
ID: 2920386
Amit etc please read previous responses before posting an answer *sigh*
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
In this article, the configuration steps in Zabbix to monitor devices via SNMP will be discussed with some real examples on Cisco Router/Switch, Catalyst Switch, NAS Synology device.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question