How To Delete Rows From Temp Table With EntityDelete In CFSCRIPT

PeterKA

If I have an array of entities loaded from a temp relation using ORMExecuteQuery(), how can I use EntityDelete() to delete all entities.

I have tried EntityDelete( tempArr ) but it does not work. However, I am able to iterate through the array and add each entity with additional info into a new final relation.

Here is my cfscript code:

tempArr = ORMExecuteQuery( "FROM TEMP WHERE CartID=#FORM.CartID#" );
transaction {
    for( i=1; i LTE ArrayLen(tempArr); i=i+1 ) {
        reg = EntityNew( "register" );
        reg.setFirstName( tempArr[i].getFirstName() );
        ........
        EntitySave( reg );
        ORMFlush();
    }
    EntityDelete( tempArr );//<<== THIS IS NOT DELETING THE ENTITIES
}

Error:

- Object passed is not a valid entity.
PeterKA

Use EntityDelete( tempArr[i] ); at the end of the for-loop.

tempArr = ORMExecuteQuery( "FROM TEMP WHERE CartID=#FORM.CartID#" );
transaction {
    for( i=1; i LTE ArrayLen(tempArr); i=i+1 ) {
        reg = EntityNew( "register" );
        reg.setFirstName( tempArr[i].getFirstName() );
        ........
        EntitySave( reg );
        ORMFlush();
        EntityDelete( tempArr[i] );//<<== THIS WORKS!!
    }
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I delete rows in the main table that match the ID in my temp table?

From Dev

Returning values from a temp table if another temp table returns no rows

From Dev

Returning values from a temp table if another temp table returns no rows

From Dev

How to delete some similar rows from a table?

From Dev

Delete rows from table

From Dev

How to show temp data and delete in html table?

From Dev

How to delete from table then delete what deleted rows referenced? (postgresql)

From Dev

How to Use Delete Triggers to Delete Rows From Same Table?

From Dev

How to delete rows from a table based on a join with another table?

From Dev

How to delete rows from one table matching another table?

From Dev

insert record from temp table to new table and also delete from temp table

From Dev

How to insert into a table from temp table?

From Dev

MySQL - Query a temp table to retrieve 2 rows from table

From Dev

Updating table from temp table with many rows in postgres

From Dev

Delete X rows from table

From Dev

Postgresql: How to delete rows from table constrained by date?

From Dev

How to delete unknown number of rows from sql table

From Dev

How to quickly delete a column from a table containing 600 million rows?

From Dev

How to delete many rows from frequently accessed table

From Dev

How to delete all rows from table which has no FK relation

From Dev

How to delete rows from table when clicking button

From Dev

Postgresql: How to delete rows from table constrained by date?

From Dev

how to delete fixed number of rows from a table with null values in PostgreSQL

From Dev

How do I delete multiple rows from a table on Backand?

From Dev

How can I delete multply rows from a table with another condition?

From Dev

How to efficiently delete expired rows from a large MySQL table

From Dev

How to create a temp table from a dynamic list

From Dev

How to insert data into temp table from a string

From Dev

After how many rows is temp table column size determined?

Related Related

  1. 1

    How can I delete rows in the main table that match the ID in my temp table?

  2. 2

    Returning values from a temp table if another temp table returns no rows

  3. 3

    Returning values from a temp table if another temp table returns no rows

  4. 4

    How to delete some similar rows from a table?

  5. 5

    Delete rows from table

  6. 6

    How to show temp data and delete in html table?

  7. 7

    How to delete from table then delete what deleted rows referenced? (postgresql)

  8. 8

    How to Use Delete Triggers to Delete Rows From Same Table?

  9. 9

    How to delete rows from a table based on a join with another table?

  10. 10

    How to delete rows from one table matching another table?

  11. 11

    insert record from temp table to new table and also delete from temp table

  12. 12

    How to insert into a table from temp table?

  13. 13

    MySQL - Query a temp table to retrieve 2 rows from table

  14. 14

    Updating table from temp table with many rows in postgres

  15. 15

    Delete X rows from table

  16. 16

    Postgresql: How to delete rows from table constrained by date?

  17. 17

    How to delete unknown number of rows from sql table

  18. 18

    How to quickly delete a column from a table containing 600 million rows?

  19. 19

    How to delete many rows from frequently accessed table

  20. 20

    How to delete all rows from table which has no FK relation

  21. 21

    How to delete rows from table when clicking button

  22. 22

    Postgresql: How to delete rows from table constrained by date?

  23. 23

    how to delete fixed number of rows from a table with null values in PostgreSQL

  24. 24

    How do I delete multiple rows from a table on Backand?

  25. 25

    How can I delete multply rows from a table with another condition?

  26. 26

    How to efficiently delete expired rows from a large MySQL table

  27. 27

    How to create a temp table from a dynamic list

  28. 28

    How to insert data into temp table from a string

  29. 29

    After how many rows is temp table column size determined?

HotTag

Archive