1 (edited by jeffmtl@hotmail.com 2021-10-21 19:30:41)

Topic: Extracting the ID number using sql and converting to a string

Hi Everybody

I am trying to extract the ID number (For example : of a client) by using SQL, convert that Number into a string.

I then will use that Number(id) to "INSERT INTO database (Client, Update, price) values ('id','On Hold', 'Price pending');

So my question has 2 parts.


1) Extracting the id using sql using Delphi scripting:   
     
Example ( I can do this which extracts the info but not the ID) 
fmGroupPresence.GroupProgressClientName.Text:= SQLExecute('SELECT txClientName FROM dtClientName WHERE id='+fmClientSearh.TableGrid1.sqlValue);


2) How to insert a string into an sql using sql. I will be using the SQL BUTTON , which all is done in mysql..


Example (as a test ive forced info into the table by doing this, but would need the client number to be scripted.)

insert into dtFollowing(id_dtClientName,ProgressEdited,txtTitle,txNote)  values ('23','Yes','Test','Testnote');         

Sorry Im not more clear as I don't have the lingo used to explain what i need to do.


Thanks for your help.



Jeff

Re: Extracting the ID number using sql and converting to a string

1. SELECT id FROM ....



You already have an id. You get it from the fmClientSearh.TableGrid1.sqlValue table.

2. You are better off using the SQL query in the script, not in SQL BUTTON.

insert into dtFollowing(id_dtClientName,ProgressEdited,txtTitle,txNote)  values ('+fmClientSearh.TableGrid1.sqlValue+' ,'Yes','Test','Testnote');

Re: Extracting the ID number using sql and converting to a string

Thanks Sparrow

I was over thinking this and I got into a mind jam.

     tmpID :=SQLExecute('SELECT id FROM dtClientName WHERE id=' +fmClientSearh.TableGrid1.sqlvalue);

I'll be working on the second part later on today.

much appreciated

Jeff

4 (edited by sparrow 2021-10-22 11:29:04)

Re: Extracting the ID number using sql and converting to a string

jeffmtl@hotmail.com wrote:

     tmpID :=SQLExecute('SELECT id FROM dtClientName WHERE id=' +fmClientSearh.TableGrid1.sqlvalue);


Jeff

SELECT id ... WHERE id=' +fmClientSearh.TableGrid1.sqlvalue


Get id from table where id = 1 ???   
Will return 1. It is possible but stupid.


Use  tmpID := fmClientSearh.TableGrid1.dbItemID