SQL Insert Struct

  • Michael
        vor 4 Jahren #21784

        Hello Everyone,

        I try to create a simple SQL insert statement “INSERT INTO BOOK (name) VALUES (:name:)”. The table “Book” has two attributes: “id” and “name”. The struct BookShelf_Book also has two attributes: “id” and “name”. The call has one input of type BookShelf_Book.

        When I test the connector call, I get the dialog were I can enter the struct attribute values. I only set name to “test”.

        As soon as I press the test button, I get an error. It seems that in the statement “INSERT INTO BOOK (name) VALUES (:name:)” the name value is not set with the content of the BookShelf_Book struct, attribute name. But every try like parameter.name also fails.

        Question: How can I address attributes within a struct as parameter of a SQL Query?

        Log:

        {
        “error”:”Couldn’t execute Query: [SQLITE_CONSTRAINT] Abort due to constraint violation (NOT NULL constraint failed: Book.name)”,
        “parameters”:{
        “parameter”:{
        “dataType”:”BookShelf_Book”,
        “value”:{
        “Name”:”test”,
        “ID”:0
        }
        },
        “mode”:{
        “dataType”:”String”,
        “const”:”execute”
        },
        “request”:{
        “dataType”:”String”,
        “const”:”INSERT INTO BOOK (name) VALUES (:name:)”
        }
        },

        Regards

        Michael

        Armin Winkler
            Has successfully completed the online course Introduction
            Has successfully completed the online course Intermediate (200)
            Has successfully completed the online course Advanced (300)
            Has successfully completed the online course Basics (100)
          vor 4 Jahren #21846
          Up
          0
          Down
          ::

          Hello Michael,

           

          can you please show me the configuration of you input parameters? If you want to address fields from within a struct, you have to make sure that you name your input parameter “params”, you can of course alias it if you want / need to. After you’ve done so the field from within the struct should be recognized properly since your statement seems to use the correct notation for parameters, i.e. :parameterName:, already. Please also make sure to use the mode “execute” as well since you have at least one input parameter defined. If you need any further help while creating SQL connector calls you may also refer to our documentation.

           

          Regards,

          Armin

           

          Update: I had a closer look at your error log and it seems you named the fields in your struct all with capital letters in the beginning of the words. However the naming of the fields in your struct need to match the column names of the table exactly. So I think you get the error since it expects to read the field “name” from the struct while in fact there’s only the field “Name” existing in the struct, please be aware of case-sensitivity here. Hope this helps

          Michael
              vor 4 Jahren #21915
              Up
              0
              Down
              ::

              Hello Armin,

              the upper letter was the problem and it gets cached some how. I created a complete new schema, new connector and a new struct already last time. I had in mind that it could be case sensitive ..

              Any way, after closing browser and clearing everything, it works.

              Thx

              Regards,

              Michael

            Ansicht von 3 Beiträgen – 1 bis 3 (von insgesamt 3)

            You must be logged in to reply to this topic.