Results 1 to 4 of 4

Thread: INSERT INTO... SELECT breaks USE ... AGAIN function

  1. #1
    Junior Member
    Join Date
    Jul 2015
    Posts
    25

    INSERT INTO... SELECT breaks USE ... AGAIN function

    Hi guys,

    I've found what I believe is a bug in the INSERT INTO command. If you USE table1 and then USE table2 which is a structural copy of it, calling

    Code:
    INSERT INTO table1 SELECT * FROM table2
    Will stop you from being able to call USE table1 AGAIN.

    You can reproduce this in the Lianja/VFP console using the Southwind datbase with the following:

    Code:
    OPEN DATABASE southwind
    USE productsbyname
    COPY STRUCTURE TO productsbyname_copy
    INSERT INTO productsbyname_copy values(111,"zyx",22,33)
    CLOSE ALL
    CLOSE DATABASE
    OPEN DATABASE southwind
    USE productsbyname
    USE productsbyname_copy
    INSERT INTO productsbyname SELECT * FROM productsbyname_copy
    USE productsbyname AGAIN
    The first half is only to create an exact copy. That works fine. If you already have a structural copy of a table sitting somewhere else, you can use that instead and see that it's the second half of the above code that causes problems.

    The error output is:
    Code:
    Fri Feb 5 10:56:30 2016
    **** Lianja error ****
    USE productsbyname AGAIN
                            ^
    File 'productsbyname.dbf' does not exist
    Finally, here's what's in debug.txt when you SET DEBUG ON and then attempt the above:

    Code:
    *
    * Lianja embedded database engine
    * Version 1.3.0
    * Compiled on Jan 27 2016 10:38:20
    *
    Error reported from file rct_use.c line 1091 n=15
    cmdline=USE productsbyname AGAIN
    
    g_current=0
    database=C:\Lianja\data\southwind\
    u->name=<null>
    u->alias=<null>
    Stacktrace:
    
    *** ERROR *** called from rct_use.c at line 1091 n=15 g_cmdpos=25 g_cmdlen=25 lex=1, g_uci=-1
    on error: 
    error number: 15
    error message: File 'productsbyname.dbf' does not exist
    cmdbuf: USE productsbyname AGAIN
    
    current=0
    database=C:\Lianja\data\southwind\
    * u->name=<null>
    * u->alias=<null>
    Stacktrace:
    Is this actually a bug or am I just doing something wrong?

  2. #2
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,368
    Blog Entries
    22
    Hi Joanna,

    Why do you want to open the same table again in the same cursor?

    You need to USE table name IN 0 to open tables up in their own cursor. What you are doing is using one cursor.

    The AGAIN should be being ignored if its the same cursor so submit a ticket so that it can be fixed.

    The forums are not the place to report bugs. Please use the ticketing system to do that.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  3. #3
    Junior Member
    Join Date
    Jul 2015
    Posts
    25
    Thanks Barry,

    I posted on here because I wasn't sure if I was doing something wrong or not. I was.

    I had USE..AGAIN and SELECT commands mixed up so I was using USE..AGAIN when I wanted to make a table the active table when you're supposed to use SELECT. If I replace USE AGAIN with SELECT in the below code it works fine.

  4. #4
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,196
    Hi Joanna,

    in the development environment, SET EXCLUSIVE is on by default. Your error is caused by SET EXCL being on, as a table cannot be opened AGAIN when it is on.

    To test this, open Lianja, and execute the follow commands from the VFP console:

    Code:
    set excl off
    open data southwind
    use employees
    use employees again alias myemps in 0
    list stat
    hth,

    Hank

Bookmarks

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
  •  
Journey into the Cloud
Join us