[[https://www.revelation.com/|Sign up on the Revelation Software website to have access to the most current content, and to be able to ask questions and get answers from the Revelation community]]
==== Change Account Name (OpenInsight Specific) ====
=== At 10 JAN 2001 07:33:11PM Barry Stevens wrote: ===
{{tag>"OpenInsight Specific"}}
I am still looking for a routine to change the account name in attached files to the current OI account - need to because of problems with adding new indexes.
I have a Arev routine VOLTRNS that does this, but there are some areas I am not sure abouting in converting it to OI.
I could post it here if someone wants a go at converting it.
many thanks
Barry
----
=== At 10 JAN 2001 08:50PM WinWin/Revelation Technical Support wrote: ===
Barry-
Email it to Info@Revelation.com
We'll convert it, post it here.
Thanks-
Mike Ruane
----
=== At 10 JAN 2001 09:19PM Barry Stevens wrote: ===
Choice! - Will do
----
=== At 11 JAN 2001 05:43PM WinWin/Revelation Support wrote: ===
Barry
Converted the program to OI. Left the Copyright unchanged
Please let me know if it works.
bob
*************************************************
Subroutine Rename_Volume(Volume, Media, Account)
!
* Matthew Crozier 1 September 1990
* Copyright (C) Vernon Systems Ltd
*
* This program will change the Media name and/or the Account for the files
* in a volume - and will modify the index definitions for any indexed files
* in that volume, thus indexes will not have to be rebuilt when redefining a
* volume's Media or Account.
* No one should be attached to the volume while this routine is run. All
* files in the volume will be renamed to the target account.
*
* Permission is given for commercial and non-commercial use of this program
* by legitimate Revmedia subscribers. No warranty express or implied, no
* responsibility accepted.
*
* 01-11-2001 RJC WinWin Solutions, Inc. Converted to OpenInsight
!
Declare Subroutine Reduce, Set_Status
Declare Function Msg, Get_Status
$INSERT Msg_Equates
If Assigned(Volume) Else Volume='
If Assigned(Account) Else Account='
If Assigned(Media) Else Media='
Convert @LOWER.CASE To @UPPER.CASE In Volume
Convert @LOWER.CASE To @UPPER.CASE In Account
Parent=@WINDOW
If Len(Volume) Else
Def="
Def=Rename Volume"
Def=Source Volume?'
Def=?'
Def=RC"
Volume=Msg(Parent, Def, '' , '' , '' )
End
If Volume # '' Then
Gosub Read.params
If Valid Then
Gosub Change.media
Read Index_Files From Revmedia, '%RECORDS%' Then
Gosub Change.%records%
End
If Valid Then Gosub Rename.media.records
If Valid Then Gosub Change_Index
If Valid Then Gosub Finish
End
End
Return ''
!
Read.params:
Valid=1
Call Alias_Table(Volume, 'SYSPROG' , 'REVMEDIA' , 'REVMEDIA$' )
If Get_Status() Then
x=Msg(@WINDOW, "Unable to alias the REVMEDIA table." , '' , '' , '' )
Set_Status (0)
Valid=0
Return
End
Open 'REVMEDIA$' To Revmedia Then
Readv Old.media From Revmedia, '%%REVMEDIA%%' , 2 THEN
If Len(Media) Else
Media=Old.media
Def="
Def=Rename Volume"
Def=New Media Name?'
Def=?'
Def=RC"
Def=Media
Media=Msg(Parent, Def, '' , '' , '' )
End
If Media=' Then Media=Old.media
End Else
Valid=0
End
End Else
x=Msg(Parent, 'REVMEDIA cannot be attached.|Program aborted.' , '' , '' , '' )
Valid=0
End
If Valid Then
If Len(Account) Else
Account=@APPID
Def="
Def=Rename Volume"
Def=New Account?'
Def=?'
Def=RC"
Def=Account
Account=Msg(Parent, Def, '' , '' , '' )
Is_Valid=( Len(Account) ] 0 )
End
End
Return
!
Change.media:
Writev Media To Revmedia, '%%REVMEDIA%%' , 2 else
x=Msg(Parent, 'Unable to Update Revmedia %%REVMEDIA%%' , '' , '' , '' )
Valid=0
End
Return
!
Change.%records%:
Fld.cnt=Count( Index_Files, @FM) + (Index_Files # '' )
For i=1 To Fld.cnt
File.spec=Index_Files
Old.account=Field( File.spec, '*' , 2)
If Account # Old.account Then
Index_Files=Fieldstore( File.spec, '*' , 2, 1, ACCOUNT)
End
Next i
Write Index_Files To Revmedia, '%RECORDS%' Else
x=Msg(Parent, 'Unable to Update Revmedia %RECORDS%' , '' , '' , '' )
Valid=0
End
Return
!
Rename.media.records:
Def="
Def=Rename Volume'
Def=Renaming media records."
Def=U"
If Len(Parent) Then Msgup=Msg(Parent, Def);* display the processing message
Select Revmedia
Done=0
Loop
Readnext R.id Then
Old.account=Field( R.id, '*' , 2)
If Account # Old.account And Old.account # '' Then
Read R.rec From Revmedia, R.id Then
Delete Revmedia, R.id Else
x=Msg(Parent, 'Unable to Delete Revmedia ' : Quote(R.id), '' , '' , '' )
Valid=0
End
R.id=Fieldstore( R.id, '*' , 2, 1, ACCOUNT)
Write R.rec To Revmedia, R.id Else
x=Msg(Parent, 'Unable to Update Revmedia %RECORDS%' , '' , '' , '' )
Valid=0
End
End
End
End Else Done=1
Until Done
While Valid
Repeat
If Len(Parent) Then x=Msg(Parent, Msgup);* take down the processing message
Return
!
Change_Index:
Def="
Def=Rename Volume'
Def=Changing Index information."
Def=U"
If Len(Parent) Then Msgup=Msg(Parent, Def);* display the processing message
Flag='
Reduce( 'WITH {@ID} ] "!"' , '' , 0, 'REVMEDIA$' , 1, FLAG)
If Flag Then
Select 'REVMEDIA$' By '' Using 1 Then
Done=0
Loop
Readnext Index_File Using 1 By AT Then
Index_File=Index_File1, '*'
Gosub Change_Index_File
End Else
Done=1
End
Until Done
While Valid
Repeat
End Else
x=Msg(Parent, 'Failure in SELECT.' , '' , '' , '' )
Valid=0
End
End Else
x=Msg(Parent, 'Failure in REDUCE.' , '' , '' , '' )
Valid=0
End
If Len(Parent) Then x=Msg(Parent, Msgup);* take down the processing message
Return
!
Change_Index_File:
Def="
Def=Rename Volume'
Def=Changing Index information|for file ' : Index_File
Def=U"
If Len(Parent) Then Msgup2=Msg(Parent, Def);* display the processing message
Data_File=Index_File2,65534
If TableExists(Data_File) Then
Call Detach_Table(Data_File)
End
If TableExists(Index_File) Then
Call Detach_Table(Index_File)
End
Call Attach_Table(Volume,Index_File,Account, '' )
If Get_Status()=0 Then
Index_Attached_Name=Index_File
End Else
Call Alias_Table(Volume,Account,Index_File, Index_File )
If Get_Status()=0 Then
Index_Attached_Name=INDEX_FILE$'
End Else
x=Msg(@WINDOW, 'Unable to alias the ' : Quote(Index_File ): ' table.' , '' , '' , '' )
Index_Attached_Name='
Valid=0
Return
End
End
Open Index_Attached_Name To If.fv Then
Read Index.defn From If.fv, Index_File Then
Header=Index.defn
File=Header1, '*'
Header=File: '*' : Account: '*' : Media
Index.defn=Header
Write Index.defn To If.fv, Index_File Else
x=Msg(Parent, 'Unable to Update Index definitions for ' :quote(Index_File), '' , '' , '' )
Valid=0
Return
End
End
Read Index.sym From If.fv, '!' Then
Writev '' To If.fv, '!' , 8 else
x=Msg(Parent, 'Unable to Update Index_SYM' , '' , '' , '' )
Valid=0
Return
End
End
Clearselect
Call Rlist( 'SELECT ' :index_Attached_Name ,5, '' , '' )
If @RECCOUNT Then
Eof=0
Loop
Readnext Indxkey Else Eof=1
Until Eof
Read Indexrec From If.fv,Indxkey Then
Swap Old.account: "*" :old.media With Account: "*" :media In Indexrec
Write Indexrec To If.fv,Indxkey Else
x=Msg(Parent, 'Unable to Update Revmedia %RECORDS%' , '' , '' , '' )
Valid=0
Return
End
End
Repeat
End
Call Detach_Table( Index_Attached_Name )
End Else
x=Msg(Parent, Index_File: ' cannot be attached!.' , '' , '' , '' )
Valid=0
End
If Len(Parent) Then x=Msg(Parent, Msgup2);* take down the processing message
Return
!
Finish:
Call Detach_Table( 'REVMEDIA$' )
Call Attach_Table(Volume,'',account,'')
Return
----
=== At 11 JAN 2001 09:09PM Barry Stevens wrote: ===
Great, It works fine. Thank you very very much.
**WARNING** - IT MUST BE RUN FROM THE SYSTEM MONITOR TO WORK PROPERLY
Barry
----
=== At 11 JAN 2001 09:52PM Barry Stevens wrote: ===
I have just logged out of the application and then back in, and when I look at the "list of indexed table" or try to update, its says there are no indexed tables.
Could you please test and verify, and fix.
Thanks
Barry
----
=== At 11 JAN 2001 10:14PM Barry Stevens wrote: ===
The database definition has to be saved, so replace the last paragraph with this:
!
Finish:
Call Detach_Table( 'REVMEDIA$' )
Call Attach_Table(Volume,'',account,'')
call Define_Database(account, 1, "", "")
Return
Barry
----
=== At 12 JAN 2001 05:06AM Oystein Reigem wrote: ===
Barry/Bob/Mike,
Thanks for that useful piece of code! In my work I've never needed to change the account name but often the volume label. I had a RenameVolume subroutine from earlier, but I never got it to save the database definition. Off to the Old Procedures Resting Home with that!
Barry - when you say the subroutine must be run from the System Monitor it's only because of the Msg calls, right? It seems to run OK from an OI form, but of course not from the System Editor.
(In my own version of your routine I've added a few Utility('CURSOR', 'H') calls to set an hourglass cursor. That's because saving the database definition takes some time, and when you run the subroutine from a form nothing tells you it's still processing. When running from the System Monitor you see from the "Getting Remove List" and "Get Add List" lines that something's going on and the hourglass isn't really necessary. - I have one Utility call around the beginning, and one after most of the Msg calls, since Msg resets the cursor to arrow.)
- Oystein -
----
=== At 14 JAN 2001 09:25PM Barry Stevens wrote: ===
]]Barry - when you say the subroutine must be run from the System Monitor it's only because of the Msg calls, right? It seems to run OK from an OI form, but of course not from the System Editor.<<
Correct
----
=== At 15 JAN 2001 05:04AM Barry Stevens wrote: ===
Reletaional indexes dont appear to be working....have to delete\add index.
Could you look into please
Barry
----
=== At 15 JAN 2001 05:33AM Barry Stevens wrote: ===
Cant delete \add index:
delete index then add - still have to remove spome index info from dict.
Add - doesnt rebuild
Adding records doesnt add
Please Help
----
=== At 15 JAN 2001 02:52PM WinWin/Revelation Support wrote: ===
Barry:
Will investigate. In translating I focused on syntax changes (trees) rather than core functionality (forest)
I probably need to make program detach each table, save database, then re-attach each table, save database again.
In the meantime:
1. re: Indexes not listing
If you run LIST_INDEX from the system monitor do you get error messages? In the past I have found that system monitor gives messages that the screen does not.
2. re: need to delete / add information.
delete / add using menu or
did you need to edit dict records or the ! file ?
3. re: Add does not rebuild
btree and relational or relational only?
Bob
----
=== At 16 JAN 2001 01:52AM Barry Stevens wrote: ===
The !IndexedField in !file is not being converted. The Old names appear to be the new names by the time it gets there.
Barry
----
=== At 16 JAN 2001 02:48AM Barry Stevens wrote: ===
Here is the section of code.
I have noted the spot where the error is.
!
Change_Index_File:
Def="
Def=Rename Volume'
Def=Changing Index information|for file ' : Index_File
Def=U"
If Len(Parent) Then Msgup2=Msg(Parent, Def);* display the processing message
Data_File=Index_File2,65534
If TableExists(Data_File) Then
Call Detach_Table(Data_File)
End
If TableExists(Index_File) Then
Call Detach_Table(Index_File)
End
Call Attach_Table(Volume,Index_File,Account, '' )
If Get_Status()=0 Then
Index_Attached_Name=Index_File
End Else
Call Alias_Table(Volume,Account,Index_File, Index_File )
If Get_Status()=0 Then
Index_Attached_Name=INDEX_FILE$'
End Else
x=Msg(@WINDOW, 'Unable to alias the ' : Quote(Index_File ): ' table.' , '' , '' , '' )
Index_Attached_Name='
Valid=0
Return
End
End
Open Index_Attached_Name To If.fv Then
Read Index.defn From If.fv, Index_File Then
Header=Index.defn
File=Header1, '*'
Header=File: '*' : Account: '*' : Media
Index.defn=Header
Write Index.defn To If.fv, Index_File Else
x=Msg(Parent, 'Unable to Update Index definitions for ' :quote(Index_File), '' , '' , '' )
Valid=0
Return
End
End
Read Index.sym From If.fv, '!' Then
Writev '' To If.fv, '!' , 8 else
x=Msg(Parent, 'Unable to Update Index_SYM' , '' , '' , '' )
Valid=0
Return
End
End
Clearselect
Call Rlist( 'SELECT ' :index_Attached_Name ,5, '' , '' )
If @RECCOUNT Then
Eof=0
Loop
Readnext Indxkey Else Eof=1
Until Eof
Read Indexrec From If.fv,Indxkey Then
**************************************************
*AT THIS POINT OLD.ACCOUNT is the same as ACCOUNT*<<<<---ERROR HERE BJS
**************************************************
Swap Old.account: "*" :old.media With Account: "*" :media In Indexrec
Write Indexrec To If.fv,Indxkey Else
x=Msg(Parent, 'Unable to Update Revmedia %RECORDS%' , '' , '' , '' )
Valid=0
Return
End
End
Repeat
End
Call Detach_Table( Index_Attached_Name )
End Else
x=Msg(Parent, Index_File: ' cannot be attached!.' , '' , '' , '' )
Valid=0
End
If Len(Parent) Then x=Msg(Parent, Msgup2);* take down the processing message
Return
----
=== At 16 JAN 2001 08:26AM Bob Carten wrote: ===
Thanks Barry.
[[https://www.revelation.com/revweb/oecgi4p.php/O4W_HANDOFF?DESTN=O4W_RUN_FORM&INQID=NONWORKS_READ&SUMMARY=1&KEY=05EC7E88B8AE9502852569D100030A14|View this thread on the forum...]]