[SOLVED] MySQL sc_exec_sql mysterious

Hi Forum!

I need to make the following query

update listas_buenafe_cab set total=(select count(*) from listas_buenafe_det where listas_buenafe_det.id_lista=listas_buenafe_cab.id_lista)

when run in the phpmyadmin, works perfectly, but when try:

sc_exec_sql(dataset, 'update listas_buenafe_cab set total=(select count(*) from listas_buenafe_det where listas_buenafe_det.id_lista=listas_buenafe_cab.id_lista)');

have the following error message:

Error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'dataset, ‘update listas_buenafe_cab set total=(select count() from listas_buena’ at line 1
dataset, 'update listas_buenafe_cab set total=(select count(
) from listas_buenafe_det where listas_buenafe_det.id_lista=listas_buenafe_cab.id_lista)’

How can it be possible? :confused:
What could it be?

many thanks!

sorry, the code is:

sc_exec_sql('update listas_buenafe_cab set total=(select count(*) from listas_buenafe_det where listas_buenafe_det.id_lista=listas_buenafe_cab.id_lista)');

dataset not going

the error is the same:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’’ at line 1
update listas_buenafe_cab set total=(select count(*) from listas_buenafe_det where listas_buenafe_det.id_lista=listas_buenafe_cab.id_lista)’

en SQL Builder work’s fine too :confused:

You might want to try double quotes instead of single quotes. You could view the generated source and see how it is being quoted to check. Some of the sc_ macros are macros and not function calls. So they get escaped/quoted different than you would expect.

Nick

[SOLVED] MySQL sc_exec_sql mysterious

many thank’s Nick!

CORRECT:

sc_exec_sql"update listas_buenafe_cab set total=(select count(*) from listas_buenafe_det where listas_buenafe_det.id_lista=listas_buenafe_cab.id_lista)");

INCORRECT:

sc_exec_sql('update listas_buenafe_cab set total=(select count(*) from listas_buenafe_det where listas_buenafe_det.id_lista=listas_buenafe_cab.id_lista)');

Ufff!!!

the documentation showld warn