Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Declaring Sybase local variables

Posted on 2000-03-31
11
Medium Priority
?
3,009 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 

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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

While opting for any web-to-print solution, you need to discuss with your team and some of your end users and know their opinions about your decisions. In this article we list down some questions you need to ask yourself.
Whoever said that “a picture is worth one thousand words” observed a fact that can dramatically affect your marketing success. Most people tend to learn visually, so many publishers commonly acknowledge the effectiveness of visual learning by using…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

719 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