SQL question very urgent 
Author Message
 SQL question very urgent

I want to do the following
var:string;             declare a variable named var
var:='("word1", "word2", "word3")';

And now use the var in an SQL statement.
query1.close;
query1.sql.clear;
query1.sql.add:=('select * from table1 where filedname IN var');

So I want to use de varaible var after the IN keyword in my SQL statement.
I have tried parambyname but is doesnt work.



Wed, 18 Jun 1902 08:00:00 GMT
 SQL question very urgent

a) To use a parameter, put : in front of the name, eg fieldname in :var

b) Since you are building up the SQL string, why not use the variable
directly:

query1.sql.add:=('select * from table1 where filedname IN ' + var);

c) What part is not working? There are two possible problems:
   The generated SQL is incorrect
   The SQL doesn't return the correct results (SQL is generated as expected,
but is incorrect )

Barbara


Quote:
>I want to do the following
>var:string; declare a variable named var
>var:='("word1", "word2", "word3")';

>And now use the var in an SQL statement.
>query1.close;
>query1.sql.clear;
>query1.sql.add:=('select * from table1 where filedname IN var');

>So I want to use de varaible var after the IN keyword in my SQL statement.
>I have tried parambyname but is doesnt work.



Wed, 18 Jun 1902 08:00:00 GMT
 SQL question very urgent

the SQL syntax it looks like you want is

SELECT *
FROM TABLE1
WHERE FIELDNAME IN ('word1','word2','word3')

if so then using the SQL property of your query will do the trick...

with Query1,SQL do
begin
   clear; //flush it out
   add('SELECT * FROM TABLE1 WHERE FIELDNAME IN '+var);
end;



Quote:
> I want to do the following
> var:string;                declare a variable named var
> var:='("word1", "word2", "word3")';

> And now use the var in an SQL statement.
> query1.close;
> query1.sql.clear;
> query1.sql.add:=('select * from table1 where filedname IN var');

> So I want to use de varaible var after the IN keyword in my SQL
statement.
> I have tried parambyname but is doesnt work.



Wed, 18 Jun 1902 08:00:00 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. -- URGENT --- Question for number in fields..-- URGENT ---

2. urgent SQL 7.0 replication questions

3. SQL and IDC Question Urgent please

4. Urgent Question about SQL job

5. urgent: SQL Question!

6. Urgent:Maximum SQL server performance question.

7. URGENT VB/SQL Question PLEASE HELP!!!

8. urgent question for sql-server

9. Urgent, ADO SQL question

10. Urgent, TQuery / SQL question

11. SQL Question Urgent!

12. Urgent: SQL*Loader Question


 
Powered by phpBB® Forum Software