Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. Problem mit Asynchronität

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    Problem mit Asynchronität

    This topic has been deleted. Only users with topic management privileges can see it.
    • Thisoft
      Thisoft last edited by

      Habe mich an diesem sendTo synchron verwenden Post orientiert und damit aber noch ein Problem 😞

      Prinzipiell funktioniert ja dieses Promising auch bei mir 😉 aber warum nur einmal in meinem Konstrukt??

      async function HoleDaten(){
      var sqlstr = "SELECT * FROM xxx WHERE Feld = 1"
      try {
        const result = await sendToAsync('sql.0', 'query', sqlstr)
       console.log(result)
        // mit result weiterarbeiten
      } catch (e) {
        // Fehler behandeln
      }
      sqlstr = "SELECT * FROM xxx WHERE Feld = 999"
      try {
        const result = await sendToAsync('sql.0', 'query', sqlstr)
       console.log(result)
        // mit result weiterarbeiten
      } catch (e) {
        // Fehler behandeln
      }
      

      Die erste Logausgabe ist ein leeres result - die zweite ist dann korrekt.

      Was mach ich denn falsch bzw. was muss ich denn anders machen? Sorry, ich hab diese Asynchronität bzw. die Verrenkungen um die Abarbeitung der Befehle eben wieder "auf die Reihe" zu bekommen leider noch nicht verinnerlicht und tue mich auch schwer das nachzuvollziehen 😞

      F 1 Reply Last reply Reply Quote 0
      • F
        fastfoot @Thisoft last edited by

        @thisoft hast du mal die Abfragen getauscht? hier funktioniert das genau so

        Thisoft 1 Reply Last reply Reply Quote 0
        • Thisoft
          Thisoft @fastfoot last edited by

          @fastfoot Oh nein - Du hast ja so Recht! Danke für's Brett vom Kopf schlagen 😉 Ich hatte ganz einfach einen Tippfehler in der WHERE-Klausel die im Original ein ganzes Stück komplexer ist als hier das Beispiel..😰

          Great SUN 1 Reply Last reply Reply Quote 0
          • Great SUN
            Great SUN @Thisoft last edited by

            @thisoft Auch komplexe SQLs kannst uns schicken, es findet sich sicher jemand, der das lesen kann und fixen. Ich hab zum Beispiel eine DB mit der Konfiguration gebaut, wann wer online darf und die Geräte noch Gruppen zugeordnet und so:

            select substr('00' || timeRule.timeRule_starthour, -2, 2) || ':' ||substr(timeRule.timeRule_startminute || '00', 1, 2) as startTime, substr('00' || timeRule.timeRule_endHour, -2, 2) || ':' || substr(timeRule.timeRule_endminute || '00', 1, 2) as endTime, timeRule_machineDeactivated as activeBlock, lanStation_timeRule.lanStation_timeRule_inactiveDate as ruleInactiveDate, lanStation_timeRule.lanStation_timeRule_inactiveUntilDateTime as ruleInactiveUntil, lanStation.lanStation_name as name, lanStation.lanStation_MAC as MAC, lanStation.lanStation_deactivated as blocked FROM lanStation LEFT OUTER JOIN lanStation_timeRule ON lanStation.lanStation_id = lanStation_timeRule.lanStation_id LEFT JOIN timeRule ON lanStation_timeRule.timeRule_id = timeRule.timeRule_id AND timeRule_weekDayList LIKE '%Mon%' WHERE (lanStation_timeRule.timeRule_id IS NULL AND blocked=1) OR (lanStation_timeRule.timeRule_id IS NOT NULL AND startTime IS NOT NULL);
            

            Ist ne Abfrage an eine SQLite3... Oder ist Dein SQL etwa noch komplexer? 😉

            Thisoft 1 Reply Last reply Reply Quote 0
            • Thisoft
              Thisoft @Great SUN last edited by

              @great-sun Danke für Dein Angebot 🙂 Aber das Problem lag nicht in der Komplexität an sich sondern einfach darin dass ich durch einen Tippfehler in der WHERE-Klausel eine Bedingung gebaut hatte die eben keine Datensätze zurückgeben konnte. Und ich glaube, DAS hättest du auch nicht rausgefunden - oder weißt du was in meiner Datenbank steht? 🙂 🙂

              1 Reply Last reply Reply Quote 0
              • Great SUN
                Great SUN last edited by

                @thisoft Ach iwo... Es war ja auch nur nett gemeint und etwas witzig gedacht 😉
                Manchmal ist es ein ! das zuviel oder zu wenig ist 😄
                Das hatte ich heute auch schon lach

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post

                Support us

                ioBroker
                Community Adapters
                Donate

                816
                Online

                31.8k
                Users

                80.0k
                Topics

                1.3m
                Posts

                3
                6
                379
                Loading More Posts
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes
                Reply
                • Reply as topic
                Log in to reply
                Community
                Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                The ioBroker Community 2014-2023
                logo