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 7060191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:19:22+00:00 2026-05-28T04:19:22+00:00

Suppose I generate the PK for my SQL Server DB table with the help

  • 0

Suppose I generate the PK for my SQL Server DB table with the help of newid() function. In Java I can do something like this:

...
String query = "DECLARE @newGuid uniqueidentifier "+
"SET @newGuid = newid() "+
"INSERT INTO myTable(id, stringval) "+
"VALUES (@newGuid, "Hello") "+
"SELECT uid FROM @newGuid";
PreparedStatement ps = conn.prepareStatement(query);
ResultSet rs = ps.executeQuery();
String uid = rs.getString("uid");

But when I try to make that with Delphi+ADO I get stuck cause ADO can either get data from DB (Open method of AdoQuery) or put data to DB (ExecSQL method). So I can’t insert new value to the table and get the parameter value afterwards.

  • 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-28T04:19:23+00:00Added an answer on May 28, 2026 at 4:19 am

    You could solve this problem atleast in two ways.

    1. You can put both of your SQL queries into one string (just like you have in your example) and call TADOQuery.Open or TADOQuery.Active := True. it doesn’t matter that you have INSERT statement there as long as query returns something.

    2. You can define parameter’s direction as pdOutput in ADOQuery.Parameters collection and read value of that parameter after executing the query.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to generate a series of alphabets, using SQL Server. Suppose I
Using SQL Server 2005 I want to generate the table values between the two
Consider the following function: void f(const char* str); Suppose I want to generate a
Suppose your git history looks like this: 1 2 3 4 5 1–5 are
Here's the query that is being executed on SQL Server 2008: SELECT "dbo"."tblMainData"."recID" FROM
Imagine I have C1 , C2 and C3 classes. Suppose we can have string
Suppose my URL is http://something.com/products.php?brand=samsung&condition=new For the above query I am using isset() and
SQL Server 10, .NET, C# This is similar to this question but not exactly
I want to use SQL SERVER 2005 commands to generate tab-delimited file. I want
Suppose I have a SQL table of Awards, with fields for Date and Amount.

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.