I'm trying to connect to a database and run a script using dbisql. I've checked the docs and tried many combinations but I guess I'm missing something.

For example:

dbisql -nogui -c "uid=dba;pwd=sql"

results in:

((not connected)

whereas if I write:

dbisql -c "uid=dba;pwd=sql"

an Interactive SQL window opens as connected.

What I'd really like to is call dbisql -nogui -c "uid=dba;pwd=sql" myscript.sql but I'm stuck on the first step.

Notes:

  • I have both SA9 and SA12 installed on this machine.
  • I'm working on SA12 Bin32 directory.
  • -nogui -c "uid=dba;pwd=sql" line works with SA9 dbisql command.
  • v12.0.1.3769

Update:

According to the docs, the following command should work against the default database although Links property is missing:

dbisql -c "UID=DBA;PWD=sql" -onerror exit mycom.sql

However, I get the message "You are not connected to a database". On the other hand, I can connect to the same database smoothly via Interactive SQL window (choosing 'connect to a running database on this computer'). dbping -d -c "UID=DBA;PWD=sql" succeeds with the same connection string stating it connected to the database. The target database is started with -x none switch.

Is there anything else I'm missing?

Screenshots:

Dbsrv12: alt text

Dbping & Dbisql: alt text

Dbisql window (works ok): alt text

asked 24 Sep '12, 03:45

henginy's gravatar image

henginy
406151827
accept rate: 0%

edited 24 Sep '12, 08:23

Thank you, you're correct in both cases. Most of the time I used the Server property but forgot about Links. Also no need for nogui parameters. I suppose I accidentally used SA9 exes in some tests. Anyway, please post your comment as answer so I can accept it.

(24 Sep '12, 06:57) henginy

Hm, it might not be over yet, updating the question.

(24 Sep '12, 07:57) henginy

-c Should be a complete connections string. Probably you should add links=shmem to.

In my batch files i don't use the -nogui paramater. And I'm not getting a normal window when I run the batchfile

permanent link

answered 24 Sep '12, 05:53

Thomas%20Duemesnil's gravatar image

Thomas Dueme...
2.7k293965
accept rate: 17%

Changed Thomas's comment to answer so henginy may accept it.

(24 Sep '12, 08:08) Reimer Pods

Thank you for the answer. First time I tried, it worked with links attribute added. But later, I don't have a single idea how, it didn't work. I keep getting 'You are not connected to a database' message even if I add links (and also server attribute). Please see the update.

(24 Sep '12, 08:11) henginy
Replies hidden

I would certainly add the path to the DBSIQL call in order to prevent to call the wrong version. The environment variables are handy here, such as

"%SQLANY12%\bin32\dbisql" -c "..."

Are you having a SQLCONNECT environment variable that might "secretly" add stuff to your connection string?


FWIW I still usually use the dbisqlc tool for batch stuff...

(24 Sep '12, 08:25) Volker Barth

@Volker Barth: Yes, I'm also setting another variable to shorten the script: SET sa12bin=%SQLANY12%\bin32. Checked the environment variables, but no SQLConnect variable (didn't know about them before, thanks).

I like dbisqlc too, but am afraid to use it in case it is discontinued..(don't know if there's really such a risk, but..)

(24 Sep '12, 08:34) henginy
Replies hidden

Have you tried if using dbisqlc raises the same problem?

(24 Sep '12, 09:51) Volker Barth

I've tried it now and it works OK, no problem connecting to database. Only a few trivial warnings about spatial data options. It does the job and I might stick to it all right, but I wonder why dbisql cannot connect.

(24 Sep '12, 09:55) henginy
Replies hidden

I'd try to use the LOG connection parameter within the connection string to get more debug output on the connection attempts...

(24 Sep '12, 10:00) Volker Barth

Good pointer. The command dbisql -c "UID=dba;PWD=sql;LINKS=SharedMemory;Log=C:\salog" opens an isql window, connected, and the log says Connected to database successfully. When I add file name at the end (dbisql -c "UID=dba;PWD=sql;LINKS=SharedMemory;Log=C:\salog" test.sql), it says 'You are not connected to a database' and no log file is created. (Test.sql exists, and I'm running the command in %SQLANY12%\Bin32 directory.)

(24 Sep '12, 10:17) henginy
Replies hidden

Btw, test.sql contains only SELECT * FROM SYSVIEW and GO lines.

(24 Sep '12, 10:22) henginy

Does the server console contain any info that a connect attempt is tried (dbeng12 -z ...)?

(24 Sep '12, 11:08) Volker Barth

Sorry, reformatted the output - (done now):

Command: C:\Program Files\SQL Anywhere 12\Bin32>dbisql -c "uid=dba;pwd=sql;LINKS=SharedMemory;Log=C:\salog.txt"

Server console: Connection ID 1: "dba" connected to database "asusys" from SQL Anywhere 12.0.1 (3769) client over SharedMemory Connection ID 1: AppInfo is IP=x.x.x.x;HOST=xxx;OSUSER=xxx;OS='Windows XP Build 2600 Service Pack 3';EXE='C:\Program Files\SQL Anywhere 12\Bin32\dbisql.exe';PID=0xdb0;THREAD=0xed8;VERSION=12.0.1.3769;API=iAnywhereJDBC;TIMEZONEADJUS Connection ID 1: Server character set conversion is enabled, but not required using character set "windows-1254"

Command: C:\Program Files\SQL Anywhere 12\Bin32>dbisql -c "uid=dba;pwd=sql;LINKS=SharedMemory;Log=C:\salog.txt" test.sql

You are not connected to a database.

Server console: => No new lines appended to console.

(24 Sep '12, 11:22) henginy

Other info: Workgroup Edition, Turkish OS.

(24 Sep '12, 11:28) henginy

Still strange. May this be an encoding problem (I-dot etc.)? - If so, I'm no expert anyway:(

(24 Sep '12, 11:49) Volker Barth

If you want to test if the behaviour is caused by an encoding problem, you can switch the encoding of your command prompt using the chcp command. Example:

chcp 850

chcp 1252

(24 Sep '12, 11:54) Dan Cummins

Thank you Volker, you've been very helpful and shown good ways to debug.

(25 Sep '12, 03:23) henginy

Unfortunately no progress with codepages 850 and 1252 either.

(25 Sep '12, 03:23) henginy

How can I open a technical case for this issue?

(25 Sep '12, 03:24) henginy

AFAIK, you can use "Case Express" to report a bug or open a case:

http://case-express.sybase.com/cx/

(Your current support plan may play a role here, apparently...)

(25 Sep '12, 06:07) Volker Barth

Thanks. I'll check our plan.

(25 Sep '12, 06:41) henginy
More comments hidden
showing 5 of 19 show all flat view

This is a long shot, but from your screen snap it looks as though you may have endashes (long dashes) on the command line instead of ASCII dashes. I can see how you could get the non-ASCII dash if you cut-and-paste the command line from the docs on Windows. You might want to try typing it in with regular dashes and see if you still have a problem?

permanent link

answered 24 Sep '12, 09:32

Dan%20Cummins's gravatar image

Dan Cummins
511614
accept rate: 41%

edited 24 Sep '12, 09:34

I actually typed in the commands every time, no copy-paste. The dashes on the screen must the same as this: '-' (next to Backspace on my keyboard:). Thank you.

(24 Sep '12, 09:42) henginy

You will see this behaviour when running dbisql.exe from a Windows command prompt. For .bat file you should run with dbisql.com which is created for that purpose.

Reference: http://dcx.sybase.com/index.html#1201/en/dbadmin/dbisql-interactive-dbutilities.html

HTH


. . . "For Windows, there are two executables:"

"1.Batch scripts should call dbisql or dbisql.com, not dbisql.exe. The dbisql.com executable is linked as a console application. "

"2.The dbisql.exe executable is linked as a windowed application and does not block the command shell from which it was started. If dbisql.exe is run from a batch file, you won't see any output sent to the standard output or standard error files. "


permanent link

answered 02 Jan '13, 14:59

Nick%20Elson%20SAP%20SQL%20Anywhere's gravatar image

Nick Elson S...
7.3k35107
accept rate: 32%

edited 02 Jan '13, 15:04

Mark%20Culp's gravatar image

Mark Culp
24.9k10139297

Well, AFAIK, if you don't specify a file extension, .com will have higher precedence than .exe (and the doc seem to cope with that), so Henginy - who does not use an extension - should already use dbisql.com, right?

(02 Jan '13, 15:48) Volker Barth
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×438
×105
×5

question asked: 24 Sep '12, 03:45

question was seen: 29,305 times

last updated: 16 Dec '16, 01:58