Home > database >  Pb on how to delete records related to an already delete records, thank you!!!!!
Pb on how to delete records related to an already delete records, thank you!!!!!

Time:09-19

Through the data window, I delete a record, such as id=12, the record in the delete buffer, now I want to delete some records associated with id=12, such as id=121, id=122, id=1211, id=1221 and related some records, id the first half of the oracle database table and deleted id the same record, how should do??

CodePudding user response:

Write embedded SQL code to delete, use wildcard % to do it,
For example:
The delete from table
Where id like '12%'

CodePudding user response:

reference 1st floor Dersak response:
write embedded SQL code to delete, use wildcard % to do it,
For example:
The delete from table
Where id like '12%'


No, because not necessarily remove 12%, may be 13%, 112%, and so on, has been deleted the id of the inside, there is a variable is not fixed

CodePudding user response:

It is not simple, so, see code:
String ls_id
//here you give id assignment
Ls_id="12"
Ls_id +="12" + "%"
Delete from tables where id like: ls_id using the sqlca.

CodePudding user response:

refer to the second floor xue_danfeng response:
Quote: refer to 1st floor Dersak response:

Write embedded SQL code to delete, use wildcard % to do it,
For example:
The delete from table
Where id like '12%'


Not ah, because not necessarily remove 12%, may be 13%, 112%, and so on, has been deleted the id of the inside, there is a variable not fixed

Have a look at the third floor even variables can add wildcards

CodePudding user response:

The
reference 3 floor Dersak response:
that is not easy, so, see code:
String ls_id
//here you give id assignment
Ls_id="12"
Ls_id +="12" + "%"
Delete from tables where id like: ls_id using the sqlca.

If his ID field is not string type?

CodePudding user response:

If your ID field character type

 
String ls_id
Ls_id='12'
Ls_id=ls_id + '%'
The delete table where id like: ls_id;


If the ID field is not a character type, use conversion
 
String ls_id
Ls_id='12'
Ls_id=ls_id + '%'
The delete table where to_char (id) like: ls_id;


Haven't been able to reach your requirements, you can use PB dynamic SQL statement
 
STRING lsSQL, ls_id
Ls_id='12'
LsSQL="DELETE table where id like '" + ls_id +' % '"
The EXECUTE IMMEDIATE: lsSQL;

CodePudding user response:

  • Related