SQL Syntax - Embedded SQL Statements

SQL Syntax - Embedded SQL Statements

Post by Ron St.Pierr » Fri, 05 May 2000 04:00:00



I am trying to embed one SQL statement inside another as:
           UPDATE client:
             SET country = (SELECT ID FROM countries WHERE
countries.NAME = c_country) ;
             WHERE client.client_id = sequence_table.client_id
but I receive an error message "Function name is missing)."

There is an MSDN example as follows:
           SELECT company FROM customer a WHERE ;
              EXISTS (SELECT * FROM orders b WHERE a.postalcode =
b.postalcode)
so SQL statments can be embedded in other SQL statements.

I've tried variations on the syntax without success. Can anyone help me
with this?

Thanks
Ron St.Pierre

PS In case it helps, what I am trying to do is use the COUNTRIES table
as a lookup table. The user selects the country, and the associated
Integer value from the COUNTRIES table will be inserted into my CLIENT
table.

 
 
 

SQL Syntax - Embedded SQL Statements

Post by Anders Altber » Fri, 05 May 2000 04:00:00


Ron
You're ahead of the game. That's hopefully an SQL standard that VFP will
implement some day.
You can do
UPDATE Clients SET country = 'x' ;
WHERE EXISTS (Select * FROM sequence_table ST WHERE
Clients.client_id=ST.client_id)
but you can replace 'x' with a subquery. You can mix in some xbase code:
 USE Countries IN 0
 UPDATE clients SET country = LOOKUP(Countries.id, c_country,'Countries') ;
 WHERE EXISTS ...
You could use an update statement like yours in SQL Pass-through against
Oracle or SQLServer
-Anders


Quote:> I am trying to embed one SQL statement inside another as:
>            UPDATE client:
>              SET country = (SELECT ID FROM countries WHERE
> countries.NAME = c_country) ;
>              WHERE client.client_id = sequence_table.client_id
> but I receive an error message "Function name is missing)."

> There is an MSDN example as follows:
>            SELECT company FROM customer a WHERE ;
>               EXISTS (SELECT * FROM orders b WHERE a.postalcode =
> b.postalcode)
> so SQL statments can be embedded in other SQL statements.

> I've tried variations on the syntax without success. Can anyone help me
> with this?

> Thanks
> Ron St.Pierre

> PS In case it helps, what I am trying to do is use the COUNTRIES table
> as a lookup table. The user selects the country, and the associated
> Integer value from the COUNTRIES table will be inserted into my CLIENT
> table.


 
 
 

1. embedded SQL:Problem during compilation in embedded sql(MSSQL) with VC++

Yo! Microsoft.

I got a problem with my embedded sql program.
My system is Microsoft NT4.0 (with S.P 4) so I compile my VC++ program with
nsqlprep compiler. but there comes this error message "c1010 : unexpected
end of file while looking for precompiled header  directive".

I think I may misuse some option or setting. please let me know how to
handle this bug. and if you can, would you mind sending me ESQL/C-related
examples?

Sorry for my poor English, and I'll be waiting for your answer.
thank for reading this message....

2. JDBC ODBC CONNECT ERROR

3. SQL vs JET - SQL Statement Syntax

4. Seeking Oracle DBA, Developer Job

5. Embedded SQL/C Preprocessor - strange syntax errors

6. Server access thru webmin

7. ASP syntax for embedded SQL call

8. Is Informix Universal Server 9.12 really an Object-relational DBMS ?

9. About Embedded SQL Syntax??

10. Old Article: Access SQL syntax versus Transact SQL syntax

11. HELP: Embedded characters in SQL statement

12. Embedded SQL statement