Forum Discussion

TejasvitaDhuri's avatar
TejasvitaDhuri
Qrew Trainee
6 years ago

Update the table record using API_DoQuery

Hi,
I have two table Parent and child table, I importing data into child table and i want to relate that imported data to the parent last record id how can i achieve this functionality.

In SQL : 
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;

3 Replies

  • When you say last record id - can you elaborate? Are you doing an import of a parent record, then a second import of your children and then need to associate the children against that most recent parent record? 

    If yes - my first thought, if you're using doQuery to get the most recent parent, would be to query your parent table to sort your doQuery in descending order of record id (meaning that you are returning the newest record id's first) and then set an option parameter for number of records to be 1 - so you only return the most recent record. You can parse that for the record ID and and associate it before you import the children

    Chayce Duncan | Technical Lead
    (720) 739-1406 | chayceduncan@quandarycg.com
    Quandary Knowledge Base
    • TejasvitaDhuri's avatar
      TejasvitaDhuri
      Qrew Trainee
      Thank you Chayce Duncan for your reply but what I want to implement:
       Lets say I have 2 table 1st Parent 2nd Child and I had generated one record in parent table now i'm going to import a data into child table from csv file from my local system. After imported data in to child table now I want to relate that imported data to parent one. how I can I achieve this is there any way.

      In SQL we can do this by using Query : UPDATE table_name
      SET column1 = value1, column2 = value2, ...
    • ChayceDuncan2's avatar
      ChayceDuncan2
      Qrew Cadet
      If your intent is to chain the actions together - meaning you create the parent, then within the same process also upload the second file without any kind of manual intervention - you will need 1 of 2 things to happen

      1) Depending on how you are creating the parent record - the Quick Base API returns its XML response after an AddRecord - and you can parse that to get the RID of the parent record and then append that to your second import

      2) Query Quick Base to find the parent record that was just created, and parse the query results to get the RID value you're looking for and append that to your second import

      If you're using SQL - I'm not really familiar of how to use it with Quick Base, but I would imagine you could do something along the lines of:

      Step 1: Update parent_table to create your parent record

      After this completes - 

      Step 2: SELECT parent_table and get your recently created parent

      After this is returned or however you would do the above

      Step 3: UPDATE child_table , using one of your column = value entries set to the response in Step 2

      My advanced SQL is pretty non-existent, but I could give a better client side (JS) example if that would help the understanding. 

      Chayce Duncan | Technical Lead
      (720) 739-1406 | chayceduncan@quandarycg.com
      Quandary Knowledge Base