Announcement

Collapse
No announcement yet.

[SOLVED] MySQL sc_exec_sql mysterious

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • [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:

    Code:
    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?
    What could it be?

    many thanks!

  • #2
    sorry, the code is:

    Code:
    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

    Comment


    • #3
      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)'

      Comment


      • #4
        en SQL Builder work's fine too

        Comment


        • #5
          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

          Comment


          • #6
            [SOLVED] MySQL sc_exec_sql mysterious

            many thank's Nick!

            CORRECT:
            Code:
            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:
            Code:
            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

            Comment

            Working...
            X