Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    OperationBinding / REMOVE? Sorry but I just donīt get it!

    Hi there,

    I have two tables: A and B. Table B holds children from A, connected 1:n.
    Now, I want to delete three entries in Table B giving the id in parent Table A using this SQL: delete from table_B where fk_id = table_A.pk;

    Now I created two DataSources: TableA and TableB.
    I want to place in the first DataSource xml file (table A) an operationBinding
    to erase the children in table B at the same time.
    And here is my question: how can I do it?

    Iīve reading the whole Api, but I just donīt get it!

    My try:
    ...
    <operationBindings>
    <operationBinding operationType="remove" operationId="deleteChildren">
    <criteria fieldName="id" value="$mainID"/>
    HERE THE SQL, somehow!!!
    </operationBinding>
    </operationBindings>
    ...

    Please can you give me an example, how can I delete,
    within the same operationBinding, values in different tables.
    Thanks a lot.

    #2
    Looks like just:

    <customSQL>delete from table_B where fk_id = $mainID;</customSQL>

    Comment


      #3
      Hi Isomorphic,

      now there is no way to set this criteria before calling my operation.
      Criterias just work when retrieving some data.
      How can I call my operationBinding, set the id to erase and call my SQL?

      Code:
      Criteria pkIdCriteria = new Criteria();
      String pkId = record.getAttribute("pkid");
      pkIdCriteria.addCriteria("pkId", pkId);
      DataSource ghDatasource = DataSource.getDataSource("MyDS");
      
      // I WANT TO ERASE THE DATA HERE, somehow
      ghDatasource.removeData(new Record(), new DSCallback() {
      	@Override
      	public void execute(DSResponse aResponse, Object aRawData,
      						DSRequest aRequest) {
      				}
      	});
      Thanks in advance.
      Last edited by GWTDummies; 16 Jun 2010, 23:00.

      Comment


        #4
        I got IT!!!

        For those with the same understanding problem, here is the solution:

        DSRequest dsRequest = new DSRequest();
        dsRequest.setOperationId("myOperationId");
        dsRequest.setAttribute("pkid", idFromJava);
        DataSource ghDatasource = DataSource.getDataSource("DSB2BBH");
        ghDatasource.removeData(ghRec, null, dsRequest);

        Comment

        Working...
        X