isql script problem on DB with segments

Hi,

I try to run the next script  CreateForm:

//----- Begin of script -------
if exists (select 1 from sysobjects where name ="Forms" )
drop table Forms
go

create table Forms (
   Priority  int,
   Name      char(50),
   LinkTo    char(80)
) on form_seg
go

create unique index FormName on Forms ( Name )
go
//---------End of script --------

I run it by the next way:

isql -U"username" -P"passw" < CreateForm

After running the script I don't see
new table, i.e. this script doesn't
create the table

If I run it line by line in the isql
it's OK and I see the new table.

What is it?
Is it the problem of segments and permissions my DBA created for me or
isql problem, or whatever?

Thank in advance,
klivlend.
klivlendAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

klivlendAuthor Commented:
Edited text of question.
0
dinyar_gCommented:
What is your platform?
Try this,
isql -Uusername -Ppassword -iCreateForm

this should work on all platforms.
Thanks
Dinyar
0
klivlendAuthor Commented:
Unfortunately,  it doesn't help.

 My platform is Intel/Linux 2.0.36
 My isql is isql/10.0.4/P/Linux

 I increase points to 250.
 
 klivlend
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

ajith_29Commented:
kivelend the answer to the question is
in the above sql u have not defined the database where the table has to be made so whenever u give isql it goes to defualt database of the user specified.For example if u logined as sa it will go default to master database.
So u have to put in the begining of the script pointing to which database the table has to be made.
In the Begining of the script u should have

1>Use database_name
2>go
3>//----- Begin of script -------
4>if exists (select 1 from sysobjects where name ="Forms" )
5>  drop table Forms
6>  go
7>...
................



// of End script------------------------
This will make the table required for the database and ur problem will be solved.

P.S Next time make it point to reject the answer which u have not got an answer for so i had to put is as a comment
0
klivlendAuthor Commented:
I did
use form_seg
go

(database_name = segment name here)
Unfortunately, it doesn't help, too.

I did
isql -v
result:
isql is isql/10.0.4/P/Linux
May be it's version non-compatibility?
May be it's permission problem,
but why it's work line by line?

Help, please.

I increase the points to 350.
klivlend.
0
ajith_29Commented:
I forgot many things to tell when using isql .
Lets start from basics of isql when isql runs it sees for the sql.ini  file for the server name.So we should have the server name defined if the path is not specified u have to give the server name and then when important point when isql is to take the output to see if the isql worked properly.So the option for getting the output must also be given.Here the option of -o can also be used to get output or error returned by the isql command

so your isql should be like this
isql -Uuser_name -Sserver_name -Ppassword -iinput_file -oerror

if does not work please do give me details of the error file.We can solve the problem for u
0
klivlendAuthor Commented:
I get the file
$SYBASE/interfaces and found there
word SYBASE, I think it's the server name.

isql -Uuser -SSYBASE -Ppassw -iinput -oout

The same result  and file "out" is empty,
i.e.  no errors.

Help, help!
klivlend.
0
ajith_29Commented:
how do u login using isql can u please tell me the command.
Then can u run isql with the input file only havinglike this

use master
go
select name from sysobjects
go

then give the
isql -Uuser -Ssybase -Ppassw -input -oout
the out file should give u some value atleast

Can u atleast tell what text u typed when u went through the isql  command promopt when it worked line by line script.

U have problem with sybase rights set such a way that it cannot create file for u or read the file u have created.
Are u in the group of sybase to acess and read files for sybase.
Please do see for that

Login using sybase as user and try to create a file and see the rights of the file which was created that must be the problem.
If u cannot see the file created using sybase login then sybase login cannot read the files of urs.

I think ur problem is with the rights u have and sybase when it was insatlled and which group it has.

Please do tell me what u how found if solved please do tell me this is first time such a peculiar problem i am seeing.
Please do mail to my id ajith_29@yahoo.com if a sloution is found.
0
klivlendAuthor Commented:
I'l try to answer for ajith_29:

1) I login as:

isql -U"myusername" -SSYBASE -P"passw"
it doesn't matter if I login with
-SSYBASE or witout it.

2) If I try line by line the file
create table Form2(
  Priority int,
  Name char(50)
)
go

then all OK and
select * from Form2
get me result
Priority Name
.....

(0 rows affected)

3) If I try this file
(create table Form1 ...) as input for
isql and after that check it by
select * from Form1
I get "Form1 not found ..."

4) if I run script

use master
go
select name from sysobjects
go

as input for isql
I get about 53 lines in "output":
sp_configure
sp_dboption
.....
etc.

5) If you say I haven't read permissions, how can I check it?

klivlend.
0
wolfgang_93Commented:
I think the problem is something obvious.

Two possibilities:
-  Did you make sure to include the word "go" to terminate each command
   in your script file? Many times I have executed a script in Sybase and
   wondered why I didn't get any feedback only to find that I had not
   included the "go" line.
-  On Linux, I wonder if there is an implicit suffix assumed.
   E.g. if you specify isql ... <abc
   and if it looks for a file named abc.sql and you happen to have such
   a file and it is empty, then you would also get the same results you
   describe.
0
klivlendAuthor Commented:
Sorry, nothing obvious.
"go"  after every command
and suffux sql isn't needed in Linux.

Again,  
1) Do you know something about version incompatibility:
   isql 10.0.4 for Sybase 11  ?
2) May be it is something with
segment I get from DB administrator
and my segment hasn't some permission?
How I can check it?  What question I
need to ask my DBA ? Anyway the same
script is executed fix line by line
( I wrote above ).

 Any other ideas?
 Please, help.

 klivlend.
0
jkotekCommented:
Here is something from myself:

1) The ISQL 10.0.4 is a correct version for ASE 11.0.x - the '10.0.4' is actually a version of OpenClient - Sybase database client and the 11.0 db server comes with a 10.0.4 OpenClient (and ASE 11.0.3.3 is an OpenServer ver. 10.0.4)

2a) please run 'select name from syssegments' in your user database 'form_seg'. This gives us a list of segments in from_seg database.

2b) can you run this from isql (not using scriptfile):
create table Forms (
                         Priority  int,
                         Name      char(50),
                         LinkTo    char(80)
                      ) on form_seg
                      go
If you get some error message, post it here.

2c) you can also 'load' a script file into isql by using a 'r: file' at isql's '>' prompt.

2d) you have to have a 'create table' permission granted to create table (according to your response from December 05 1999 this isn't the case).
0
dinyar_gCommented:
could you post your entire script that you are trying to run
0
wolfgang_93Commented:
I am curious by the statement "After running the script I don't see new table, i.e. this script doesn't create the table".

Does this mean that after you issued the commands line
by line in isql, you issued the command:

   sp_help <table>

to confirm the existance of the table? Did you then try
feeding the script to isql and after go into isql in interactive
mode again and issue the sp_help <table> command?

0
jkotekCommented:
Another usefull stored procedure: sp_helpsegment <segment_name> - displays info on segment in current db.
0
klivlendAuthor Commented:
Hello, evrebody tries to help.
1) It became to clear,  that form_seg
is datbase, no segment. It's the bug
of my DBA.
2) I can't use the script for segment:
create table Form (...)
on form_seg
go
 
 but I can use script dor DB

use form_seg
go
create table Forms (... )
go

The last script works correctly
in the mode line by line and I check
it simply by
select * from Forms
go

3) Unfortunately this script still doesn't work in the command mode:
isql -Uuser -Ppassw < myScript > outF

where

myScript:

use form_seg
go
create table Forms (... )
go
select * from Forms
go

and outF is empty after all this.

klivlend.



0
klivlendAuthor Commented:
All answers still doesn't hope
and are rejected.

klivlend.
0
jkotekCommented:
3) the '<' (imput stream/pipe) operator is NOT SUPPORTED by isql

try the '-i[scriptfile]' parameter instead (like dinyar_g's answer from 1/12)
or 'r: [scriptfile]' from the isql's '>' prompt (described in point 2c in my comment from 7/12)

For the output file use the switch '-o'

But if you still want to use the imput and output streams/pipes, there is a way to do it. Most of the Unix OS use virtual RAM-based filesystems to emulate imput and output streams/pipes - 'fdfs' or File Descriptor File System. This is how it is done on Solaris:

isql ... -i/dev/fd/0 -o/dev/fd/1 < infile > outfile

the /dev/fd/0 is a standard input stream and /dev/fd/1 is standard output stream

2) the create table on seg_form obviously cannot work
there are two things that might come handy:
select name from syssegments gives you list of all segments in database
and sp_helpsegment [segmentname] more info on specific segment
0
klivlendAuthor Commented:
Hi,
1) I wrote 14/12 that form_seg is
database ( not segment )
2) Using -i ( instead of < )  and -o
(instead of > )  --> the same result.
empty output.  I say about the script
use form_seg
go
create table Forms (... )
go
select * from Forms
go

It works ok line by line.
klivlend.
0
jkotekCommented:
Ooops my mistake.

That script definatelly should work. Isn't there something in the server's error log?
0
ahoorCommented:
Ok, another test for you...
If you want to know if anything goes wrong, add some
logging in the script.
Here's an example:

use form_seg
go

if exists (select 1
              from sysobjects
              where name ="Forms"
              and    type = 'U')     -- why did you not add this?
begin
    print ' dropping table forms'
    drop table Forms
end
go

create table Forms
( Priority  int,
  Name      char(50),
  LinkTo    char(80)
 ) on form_seg
go

if exists (select 1
              from sysobjects
              where name ="Forms"
              and    type = 'U')
begin
    print ' created table forms'
end
else
begin
    print ' Error in creating table forms'
end
go

create unique index FormName on Forms ( Name )
go

The fact that the outputfile is still empty is strange, if
you say the table was not created the file should at least
contain an error message saying something like
"Cannot create index because table forms does not exist".

The outputfile should contain the 2 sentences as in the
print statements... at least.

This may help you locating the error... not solve it yet.
Arjan
0
amitpagarwalCommented:
A possibility exists that a view with the same name as "Forms" exists in the database.

try using the following script


//----- Begin of script -------
if exists
(select * from sysobjects where type = 'U' and id = object_id('Forms'))
begin
drop table Forms
end
go

create table Forms (
   Priority  int,
   Name      char(50),
   LinkTo    char(80)
) on form_seg
go

create unique index FormName on Forms ( Name )
go

//---------End of script --------

Run the script as

isql -U"username" -P"passw" -S"srv" -D"Database" -i "scriptfile"

Hope it works

thanks
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
albertspCommented:
You should check if there are no leading blank for
your go.

I have experienced that scrips not work when there is space
before the 'go'
TABS are allowed!

Succes, Albert
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Sybase Database

From novice to tech pro — start learning today.