[Info-vax] Rdb question
Jan-Erik Söderholm
jan-erik.soderholm at telia.com
Sun Jul 24 15:19:44 EDT 2022
Den 2022-07-24 kl. 18:01, skrev IanD:
> On Saturday, July 23, 2022 at 1:46:41 AM UTC+10, Arne Vajhøj wrote:
>> On 7/22/2022 3:35 AM, Jan-Erik Söderholm wrote:
>>> Den 2022-07-22 kl. 01:29, skrev Arne Vajhøj:
>>>> I am not good at Rdb.
>>>>
>>>> CONNECT TO 'ATTACH FILENAME disk4:[rdb]test'
>>>>
>>>> should connect to that database.
>>>>
>>>> But it fails with alias already in use.
>>>
>>> Yes, you probably already have an active attach
>>> which uses the "default connection", and since you
>>> did not specify a new "alias", it tried to use the
>>> same default connection.
>> Yes. I just doesn't know where that connection comes from.
>>>> CONNECT TO 'ATTACH ALIAS test FILENAME disk4:[rdb]test'
>>>>
>>>> works fine, but I have to prefix all table names with "test." and
>>>> I do not like that.
>>>>
>>>> What is the correct syntax for:
>>>>
>>>> CONNECT TO 'ATTACH JUSTOVERWRITETHEDEFAULTALIAS FILENAME disk4:[rdb]test'
>>>
>>> If you want a new default connection you need to DISCONNECT the open one.
>> DISCONNECT did not help.
>>> From where are you doing that? Rdb interactive SQL?
>> Program using SQL Services.
>>> Do you need multiple connections? If not, just use
>>> a default connection and only use ATTACH.
>> That works!
>>
>> :-)
>>
>> Arne
>
>
> I don't have access to RDB anymore so sorry if what I remember is wrong...
>
> I think you used to be able to define a logical SQLINI that points to an initialization file wre you can execute SQL commands prior to being dropped into interactive SQL. See if one exists and is pre-defining your db handle
>
> DISCONNECT ALL; from memory is how you can disconnect from all prior attachments/aliases or perhaps DISCONNECT RDB$DBHANDLE ?
>
> Looks like you've solved your issue anyhow, so this post is late to the call
If you do not have an SQLINI file, or hasn't defined SQL$DATABASE, you
are not connected to any database when entering the SQL interactive CLI.
So you must do:
$ sql
SQL> ATTACH ....
SQL> SELECT ... FROM ...;
The easiest way is to simply define SQL$DATABASE in your LOGiN.COM, in
particluar if you usually access the same database.
SQLINI is usually used to "SET TRANSACTION READ ONLY;" since the default
transaction mode is READ WRITE, and that might give you to much locking
if you usually want to just read things.
When you need to actually update some thing, it is easy to do:
$ def/User sqlini " "
$ sql update ... SET xxx=1234;
$
The empty sqlini definition will only be active in that SQL session.
I ask my developers to try to *never* do:
$ SQL
SQL> select ...
SQL> commit (exit)
$
Since it is very easy to forget that "commit" and lock up things
for the production processes. So always do:
$ sql select ...
$
And you'll get an automatic commit when the select has finished.
You just need to have the SQL$DATABASE logical defined...
Jan-Erik.
More information about the Info-vax
mailing list