Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. reading multiline value from database, then using the value in query
Forum Updated to NodeBB v4.3 + New Features

reading multiline value from database, then using the value in query

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 450 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    user4592357
    wrote on 29 Oct 2019, 14:34 last edited by
    #1

    i'm reading (possibly) multiline (i.e. containing '\n') values from sqlite database and storing them in QString.
    later, i need to use this value in a query like this:

    SELECT SomeID FROM SomeTable WHERE SomeText LIKE :the_text;
    

    when i bind the value of stored string to :the_text, something goes wrong and it matches 0 results.
    this is only true when the text is multiline. for single line it works fine. any idea what i can do?

    J 1 Reply Last reply 30 Oct 2019, 09:03
    0
    • G Online
      G Online
      Gerhard
      wrote on 29 Oct 2019, 16:45 last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • G Online
        G Online
        Gerhard
        wrote on 29 Oct 2019, 16:47 last edited by
        #3

        Most RDBM requires a Wildcard in the searchvalue if there is a LIKE in the WHERE clause.
        if the_text containing the values delivered from previous select try :
        SELECT SomeID FROM SomeTable WHERE SomeText = :the_text;

        Sorry for my english:)

        U 1 Reply Last reply 30 Oct 2019, 08:48
        1
        • G Gerhard
          29 Oct 2019, 16:47

          Most RDBM requires a Wildcard in the searchvalue if there is a LIKE in the WHERE clause.
          if the_text containing the values delivered from previous select try :
          SELECT SomeID FROM SomeTable WHERE SomeText = :the_text;

          Sorry for my english:)

          U Offline
          U Offline
          user4592357
          wrote on 30 Oct 2019, 08:48 last edited by
          #4

          @Gerhard
          that returns 0 (doesn't match the text in db)

          1 Reply Last reply
          0
          • U user4592357
            29 Oct 2019, 14:34

            i'm reading (possibly) multiline (i.e. containing '\n') values from sqlite database and storing them in QString.
            later, i need to use this value in a query like this:

            SELECT SomeID FROM SomeTable WHERE SomeText LIKE :the_text;
            

            when i bind the value of stored string to :the_text, something goes wrong and it matches 0 results.
            this is only true when the text is multiline. for single line it works fine. any idea what i can do?

            J Offline
            J Offline
            JonB
            wrote on 30 Oct 2019, 09:03 last edited by JonB
            #5

            @user4592357
            Do you mean the text you are searching for (bound to the_text) contains newlines, or do you just mean the column in the database you are searching in (SomeText) contains newlines while the text you are searching for (the_text) does not contain newlines? Give us an example of what you are binding the_text to?

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 30 Oct 2019, 22:41 last edited by
              #6

              Hi,

              To add to @JonB, please give an example of text you are storing in your database and an example of search you are currently doing.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              1/6

              29 Oct 2019, 14:34

              • Login

              • Login or register to search.
              1 out of 6
              • First post
                1/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved