?
Solved

How to use update(SQL) statement in delphi?

Posted on 1999-07-05
11
Medium Priority
?
424 Views
Last Modified: 2011-09-20
I want to use a SQL statement like this:
'update fixasset set assetstatus='0' where assetstatus='F' '
I want to write it in delphi program. I don't want to use store procedure. I write it in TQuery but it not work. Can you tell the details of how to do so???
0
Comment
Question by:keynes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +3
11 Comments
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1386481
You need to use the ExecSQL method...

Perhaps you could post you code that does no work?

Cheers,

Raymond.

0
 
LVL 1

Expert Comment

by:yk030299
ID: 1386482
What is the query.CacheUpdates?
0
 
LVL 15

Expert Comment

by:simonet
ID: 1386483
When using that kind of statement in a TQuery component, you must call it by issuing:

Query1.ExecSQL;

It will not work if you call "Query1.Open" or "Query1.Active := true".

Are you getting any error messages?

Alex
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:keynes
ID: 1386484
I use execsql.
But it returned a error message
'Table is read-only.'
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1386485
hi keynes,

execsql is the way, after fired you can get with the property rowsaffected how much records are updated.

>'Table is read-only.'
what database do you use?

meikl
0
 
LVL 1

Expert Comment

by:yk030299
ID: 1386486
did update priv of Table fixasset grant ti user?
0
 
LVL 7

Accepted Solution

by:
RBertora earned 200 total points
ID: 1386487
I want to use a SQL statement like this:
'update fixasset set assetstatus='0' where assetstatus='F' '
I want to write it in delphi program. I don't want to use store procedure. I write it in TQuery but it not work. Can you tell the details of how to do so???

This will work in all cases but one:

uses DB, DBTables;

procedure TForm1.Button1Click(Sender: TObject);
var
  TempQuery : TQuery;
begin
  TempQuery := TQuery.Create(Form1);
  TempQuery.DatabaseName := 'YourBDEAliasName';
  TempQuery.Sql.Clear;
  TempQuery.Sql.Add('update fixasset set assetstatus= ''0'' where assetstatus=''F'' ');
  TempQuery.ExcecSql;
end;

It wont work if you have a clustered index on more than the assetstatus field... you should remove the clustered index if you want this statement to work, alternatively you should include the entire index in your where clause.

cheers,
Bert.





0
 

Author Comment

by:keynes
ID: 1386488
Thanks everybody.
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1386489
Could you tell us what you needed to do to fix it?

Seems to me RBertora's answer did not contribute to the information already supplied by other experts...

Cheers,

Raymond.
0
 
LVL 15

Expert Comment

by:simonet
ID: 1386490
Ditto.

keynes, why did you accept RBertora's answer since all he/she said had already been said by other experts?

Alex
0
 
LVL 15

Expert Comment

by:simonet
ID: 1386491
Keynes, did you read me question?
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question