Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7441875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:05:12+00:00 2026-05-29T11:05:12+00:00

I am building a DataSnap server in Delphi XE2, and I’m having trouble figuring

  • 0

I am building a DataSnap server in Delphi XE2, and I’m having trouble figuring out the best way to insert the JSON Object that the client sends me into a Database.

Here’s the format of the object I’m receiving:

{"PK":0,"FIELD1":"EXAMPLE","FIELD2":5, "DATE":""}

The solution I found was the following code

with qryDBMethods do
  begin
    SQL.Text := 'SELECT * FROM Table';
    Open;
    Append;
    FieldByName('PK')    .AsInteger := StrToInt(newId.ToString)
    FieldByName('FIELD1').AsString  := Object.Get('FIELD1').JsonValue.Value;
    FieldByName('FIELD2').AsInteger := StrToInt(Object.Get('FIELD2').JsonValue.Value); 
    FieldByName('DATE')  .AsDateTime:= Now;    
    Post;

After that, I would have my query component made into a JSON Object and returned to my client, but problem is, this is going to be a big application with dense tables and so doing a “SELECT * ” every time I want to insert something isn’t ideal. What is the best way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T11:05:13+00:00Added an answer on May 29, 2026 at 11:05 am

    Try using a INSERT sentence instead.

    with qryDBMethods do
      begin
        SQL.Text := 'INSERT INTO Table (PK, FIELD1, FIELD2) VALUES (:PK, :FIELD1, :FIELD2)';
        ParamByName('PK')    .Value:= StrToInt(newId.ToString)
        ParamByName('FIELD1').Value := Object.Get('FIELD1').JsonValue.Value;
        ParamByName('FIELD2').Value:= StrToInt(Object.Get('FIELD2').JsonValue.Value);    
        ExecSQL();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Building on what has been written in SO question Best Singleton Implementation In Java
Building a site super quick and having it work on all my Mac browsers,
Building a string for post request in the following way, var itemsToAdd = sl.SelProds.ToList();
Building on this question , is there a simple solution for having a multi-key
Building on this this post , I needed a clean way to extract nodes
I have a DataSnap server that creates a TSQLQuery, TDataSetProvider and a TClientDataSet that
Building my first web app using Yii and wondering if it is best to
Building a simple asp.net web app just to test things out (will obviously refactor
Building on from a previous query regarding Class::Struct vs Object::Accessor, I'd like to find
Building on How Do You Express Binary Literals in Python , I was thinking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.