Databases

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • store result

    6 answers - 442 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    hi,
    is there is any way so that i can store the result
    of
    a select query and execute a delete query on the
    same
    table with out using any other buffer?
    T h a n k s & R e g a r d s ,
    Manoj M | Webyog | Bangalore | Voice: 91 9886171984, 91 80 51216434(off)
    "A winner is not one who never fails, but one who never quits!"
    Send instant messages to your online friends http://in.messenger.yahoo.com
  • No.1 | | 452 bytes | |

    1/19/06, manoj marathayil <manojmarathayil (AT) yahoo (DOT) co.inwrote:

    hi,
    is there is any way so that i can store the result
    of
    a select query and execute a delete query on the
    same
    table with out using any other buffer?

    How about:

    select id
    into temp_table
    from source_table
    where somecondition = true;

    delete from source_table
    where id in ( select id from temp_table );
  • No.2 | | 1250 bytes | |

    Jay Sprenkle wrote:

    >
    >>is there is any way so that i can store the result
    >>of a select query and execute a delete query on the
    >>same table with out using any other buffer?

    >
    >>

    >
    >How about:
    >
    >select id

    into temp_table
    from source_table
    >where somecondition = true;
    >
    >delete from source_table
    >where id in ( select id from temp_table );
    >


    Jay,

    I don't believe there is an option to "select into" in SQLite. So your
    first statement should probably be a "create as". Also, you should
    delete the temp table after the delete. Your solution should read like this:

    create temp temp_table as
    select id from source_table where some_condition = true;
    delete from source_table
    where id in (select id from temp_table);
    drop temp_table;

    But I have to wonder why you suggest creating the temp table at all when
    this does the same thing:

    delete from source_table
    where id in
    (select id from source_table where some_condition = true);

    Dennis Cote
  • No.3 | | 343 bytes | |

    Dennis Cote wrote:
    But I have to wonder why you suggest creating the temp table at all
    when this does the same thing:

    delete from source_table
    where id in
    (select id from source_table where some_condition = true);

    even

    delete from source_table
    where some_condition = true;

    Igor Tandetnik
  • No.4 | | 1043 bytes | |

    I don't believe there is an option to "select into" in SQLite. So your
    first statement should probably be a "create as". Also, you should
    delete the temp table after the delete. Your solution should read like this:

    ! Too many database syntax records in my head at the same time!

    create temp temp_table as
    select id from source_table where some_condition = true;
    delete from source_table
    where id in (select id from temp_table);
    drop temp_table;

    But I have to wonder why you suggest creating the temp table at all when
    this does the same thing:

    He said he wanted to do some processing before deleting the records.

    I do something similar when printing letters from a live system. I
    take a snapshot
    into a temp table, export the data to the printing process, and then
    if that suceeds
    I mark the records as printed using the temp table. If I didn't use a
    snapshot records
    added while the process runs will be marked as printed when they really are not.
  • No.5 | | 492 bytes | |

    Igor Tandetnik wrote:

    Dennis Cote wrote:
    >
    >But I have to wonder why you suggest creating the temp table at all
    >when this does the same thing:
    >>

    >delete from source_table
    >where id in
    >(select id from source_table where some_condition = true);
    >
    >

    even

    delete from source_table
    where some_condition = true;

    Igor Tandetnik
    --
    Good point.
  • No.6 | | 1134 bytes | |

    1/19/06, manoj marathayil <manojmarathayil (AT) yahoo (DOT) co.inwrote:
    ok this i can do, but the problem is i need to select a set of records and i want to manipulate with each record then only i need to delete that record

    That's why I had it separated. Select the set into a temporary table.
    Process the records
    listed in the temporary table. Then delete them when you're finished
    using the temporary
    table to define what to delete:

    delete from source_table
    where id in ( select id from temp_table );

    Jay Sprenkle <jsprenkle (AT) gmail (DOT) comwrote: 1/19/06, manoj marathayil wrote:

    hi,
    is there is any way so that i can store the result
    of
    a select query and execute a delete query on the
    same
    table with out using any other buffer?

    How about:

    select id
    into temp_table
    from source_table
    where somecondition = true;

    delete from source_table
    where id in ( select id from temp_table );
    >
    >
    >

    Send instant messages to your online friends http://in.messenger.yahoo.com

Re: store result


max 4000 letters.
Your nickname that display:
In order to stop the spam: 6 + 5 =
QUESTION ON "Databases"

EMSDN.COM