Alpha Video Training
Results 1 to 9 of 9

Thread: Delete/re-create a shadow from the shadow

  1. #1
    "Certified" Alphaholic
    Real Name
    Raymond Lyons
    Join Date
    Apr 2000
    Location
    Carlsbad, CA
    Posts
    2,143

    Default Delete/re-create a shadow from the shadow

    Too many times clients have run into problems with shadow databases that only seem to be fully cured by deleting the shadow and re-creating it rather then simply refreshing it in the usual ways. For one thing, refreshing does not get rid any tables in the shadow that have been deleted in the master.

    Asking novice users to delete a shadow folder is asking for trouble, and without deleting it not all problems will be resolved, in my experience. Giving users access to the control panel to "create" a shadow is also not something I am fond of. Besides, creating and overwriting an existing shadow does not always get rid of whatever might be causing a problem with a shadow.

    So, I have finally succeeded in creating some scripts that from the shadow will close itself, open the master, delete all the files in the the shadow folder and then re-create the shadow from scratch. This may sound easy, but if you have ever tried it you most likely found all kinds of peculiar tweaks were needed to make it work reliably and without problems (e.g., the 2 second delay in one the scripts is essential).

    In addition to the two scripts that follow, I am going to attach a test database, which also has a script for making a shadow from a master (just using create_shadow2("database_name") won't work).

    Ray Lyons


    'Date Created: 26-Oct-2005 05:49:21 PM
    'Last Updated: 19-Jan-2006 08:14:57 PM
    'Created By : Ray Lyons
    'Updated By : Ray Lyons
    '******** Del_Re-Create Shadow script **********************************
    'Addin variables to communicate with the master DB to be opened here
    DIM aiv AS P
    DIM aiv.DelShadow AS P
    aiv = addin.variables()
    dim aiv.DelShadow.Create_shadow as L
    dim aiv.DelShadow.shadow_path as c

    'check to see if in master or shadow.
    dim Master_name as c
    Master_name=a5.Get_Master_Name() 'Here just using to get shadow folder
    'name and to check whether we are in
    'the master (="") or the shadow.
    If Master_name = ""
    ui_msg_box("STOP","You are NOT in a Shadow database."+crlf(2)+"You can only run this operation from a Shadow.",UI_STOP_SYMBOL+UI_OK)
    END
    End if

    'Routine to get shadow path to be deleted once shadow is closed & master opened.
    dim shadow_folder_name as c
    shadow_folder_name = file.filename_parse(Master_name,"n")
    aiv.DelShadow.shadow_path = a5.Get_Path() 'path for the shadowed DB--use in autoexec when coming back
    response = ui_msg_box("Shadow Path","Shadow DB Path = "+aiv.DelShadow.shadow_path+crlf(2)+"Shadow Database Name = "+Shadow_folder_name+crlf(2)+"Are you sure you want to delete and re-create Shadow Database?",UI_QUESTION_SYMBOL+UI_YES_NO)
    If response = UI_NO_SELECTED
    aiv.DelShadow.Create_shadow = .F. 'set fales so when master opens nothing is triggered.
    end
    else
    'current is a shadow, so close shadow, open Master and create a
    'shadow there using the aiv.DelShadow.Create_shadow as the trigger.
    aiv.DelShadow.Create_shadow = .T. 'set true so when master opens code will triger
    dim Master_name as c
    Master_name=a5.Get_Master_Name()
    Trimmed_path = alltrim(Master_Name)
    :a5.load(Trimmed_path)
    end if
    END
    '************************ END **************


    'Date Created: 18-Jan-2006 02:30:01 PM
    'Last Updated: 19-Jan-2006 08:36:07 PM
    'Created By : Ray Lyons
    'Updated By : Ray Lyons
    '*******************************Autoexec script ************************
    DIM aiv AS P
    DIM aiv.DelShadow AS P
    aiv = addin.variables()
    dim aiv.DelShadow.Create_shadow as L 'Used to trigger or not.
    dim aiv.DelShadow.shadow_path as c 'Used for deleting and re-creating the shadow.

    dim Master_Path as c
    Master_path=a5.Get_Master_Path()'If this ="", it is NOT shadowed
    If aiv.DelShadow.Create_shadow = .t. .AND. Master_path = "" 'currently in the Master, so delete & create shadow
    aiv.DelShadow.Create_shadow = .F. 'so shadow won't trigger this
    dim success_flag as L 'indicates whether anything was removed--not using now but may
    Success_Flag = DIR_REMOVE_RECURSE(aiv.DelShadow.shadow_path,.t.) '.t. suppresses warning
    DIM GLOBAL pDlg1 as {waitdialog}
    pDlg1.Create(1,"Message")
    pDlg1.Set_Title("Please Wait")
    pDlg1.Set_Message("Operation still processing.")
    pDlg1.Set_Bottom_Message("Only a few seconds left.")
    dim DBname as c
    DBname = file.filename_parse(a5.get_name(),"N")
    xbasic_wait_for_idle(2) 'Seems to need at least a 2 sec delay or A5 really gets screwed up
    pDlg1.Close()
    'next line is for v6 and above. Check docs for v5 version of it
    create_shadow2(aiv.DelShadow.shadow_path+"\\"+DBname,.t.)
    End if
    END
    '*************************** END *********************************

  2. #2
    "Certified" Alphaholic
    Real Name
    Raymond Lyons
    Join Date
    Apr 2000
    Location
    Carlsbad, CA
    Posts
    2,143

    Default

    OK, I give up: How does one get indents in pasted code to diplay?

    Ray

  3. #3
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,310

    Default

    Use html [code] tags.

    http://msgboard.alphasoftware.com/alphaforum/faq.php?faq=vb_read_and_post#faq_vb_special_codes

  4. #4
    "Certified" Alphaholic
    Real Name
    Raymond Lyons
    Join Date
    Apr 2000
    Location
    Carlsbad, CA
    Posts
    2,143

    Default

    You know, when one goes to the trouble of posting something like this that should be of help to others and no one even so much as responds with a simple “Thanks,” it raises a number of questions, one of which is, “Why bother going to the trouble?” Another might be, “Am I the Lone Ranger on this (i.e., no one else has ever had a need for this)?” The latter can’t possibly be true, can it?

    Also, I see there is a better answer to my question about displaying indents in posted code:

    http://msgboard.alphasoftware.com/al...ad.php?t=57348

    Ray

  5. #5
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,310

    Default

    Ray,

    I know how you feel. Sometimes folks respond to my efforts to help by saying they aren't as good as they could have been.

    Can't speak for others concerning the non-response you received to your post. For me, this seemed like something that belongs over in the code archive. I plan to study it but haven't had the time so far.

    -- tom
    Last edited by Tom Cone Jr; 01-23-2006 at 07:37 AM.

  6. #6
    "Certified" Alphaholic
    Real Name
    Peter Wayne
    Join Date
    Apr 2000
    Posts
    1,728

    Default

    Ray,
    I just saw your contribution today, and thank you, I think it is very valuable. I would think it should be included in the newsletter for wider distribution. Why don't you send it to Bill or Jim?
    - Peter

  7. #7
    "Certified" Alphaholic
    Real Name
    Raymond Lyons
    Join Date
    Apr 2000
    Location
    Carlsbad, CA
    Posts
    2,143

    Default

    Hi Peter, and thanks, as always, for the kind words. Although I am still not sure there is any need for wider distribution, I may offer it to Bill or Jim after I am more sure that it is reliable. I just today implemented it on some client networks, and although it works fine here in my office, what works fine here does not always work fine out in the real world. This may be especially tricky because there clearly are some timing issues that can cause serious problems. My delay in the code may need to be more than 2 seconds in other environments. We'll see what happens.

    Ray

  8. #8
    Member melmitts707's Avatar
    Real Name
    Melvin Mitts
    Join Date
    Jan 2006
    Location
    Harrisonville, MO
    Posts
    15

    Default

    I just arrived here (Using A5 v7 less than a week) and am just starting to learn so I don't completely understand what you are doing yet but keep it up... I will catch up and I appreciate people who take the time to post such examples.

    Thanks

    Mel

  9. #9
    "Certified" Alphaholic
    Real Name
    Ed Barley
    Join Date
    Mar 2002
    Location
    Southern California
    Posts
    1,056

    Default

    Hi Ray,

    In the past, I have had the problem, where the shadow had to be deleted and recreated due to different problems, at different times.
    I saw your post over the weekend, and could not respond till today.
    Appreciate your programming expertise. This is definitely very useful.
    As soon as I get a chance I will use it at this end.

    Many Thanks Ed

Similar Threads

  1. Shadow
    By Bill@TrackerSystems.com in forum Alpha Five Version 6
    Replies: 3
    Last Post: 02-16-2005, 09:17 AM
  2. shadow
    By Lanny Tonning in forum Alpha Five Version 6
    Replies: 3
    Last Post: 02-06-2005, 09:46 AM
  3. Shadow only
    By Richard Neal in forum Alpha Five Version 4
    Replies: 5
    Last Post: 05-08-2001, 11:14 PM
  4. Shadow only
    By Richard Neal in forum Alpha Five Version 4
    Replies: 1
    Last Post: 05-08-2001, 11:08 PM
  5. create index for shadow (read only / CD) database
    By Saverio Biunno in forum Alpha Five Version 4
    Replies: 2
    Last Post: 04-21-2000, 03:19 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •