Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

help on xbasic sql insert statement that handles names with a quote - I'm drawing a blank - on it, I must be losing it.

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

    help on xbasic sql insert statement that handles names with a quote - I'm drawing a blank - on it, I must be losing it.

    names like O'Connor -

    assistance appreciated.

    Pete

    Insanity: doing the same thing over and over again and expecting different results.
    Albert Einstein, (attributed)
    US (German-born) physicist (1879 - 1955)

    #2
    Hi Pete,

    in normal use I would have said use the "" (Backslash) character but I thought I would use the SQL insert genie (right click in the xbasic editor) to see how Alpha would write the code and it used arguments and came up with the following

    Code:
    dim cn as sql::connection
    dim flag as l
    flag = cn_open(cn,"::Name::Jobs")
    if flag = .f. then
    'there was an error
    dim errorText as c
    errorText = cn.callresult.text
    end
    end if
    'turn on portable SQL
    cn.PortableSQLEnabled = .t.
    dim SQL as c
    sql = "INSERT INTO clients(LAST_NAME,COMP_NO) VALUES (:LASTNAME,:COMPNO)"
    dim args as sql::arguments
    args.add("LASTNAME","o'conner")
    args.add("COMPNO",convert_type("1","N"))
    'execute the SQL
    flag = cn.execute(sql,args)
    if flag = .f. then
    'there was an error
    dim errorText as c
    errorText = cn.callresult.text
    cn.close()
    end
    end if
    dim rowsInserted as n
    'get the number of rows that were inserted
    rowsInserted = cn.CallResult.rowsaffected
    cn.close()

    Comment


      #3
      https://w3schools.sinsixx.com/js/js_...acters.asp.htm

      Comment


        #4
        I usually use another single quote. O'Connor --> O''Connor

        Comment


          #5
          Chris' option works in mysql and sql server(sql express).
          My preferred option is to change the character to a pipe, then change the pipe back to the original character when retrieving the data.
          Gregg
          https://paiza.io is a great site to test and share sql code

          Comment


            #6
            I guess that works too, madtowng. Just to be clear, Alpha is automatically escaping the characters when it runs queries in lists and grids and data-bound UXs, etc. And I'm pretty confident it handles them when they're passed to a query via arguments in XBasic. But if you're writing a query in SSMS or MySQL Workbench, or you're writing a query directly in XBasic, you'll need to handle them yourself.

            Comment


              #7
              Seems strange to see what Alpha does.
              [code]<SQLArguments>
              <SQLArgument>
              <Name>lastname</Name>
              <Data Type="C">O&apos;Brien</Data>
              <IsNull Type="L">0</IsNull>
              <Usage>Input</Usage>
              </SQLArgument>
              </SQLArguments>
              [/code
              Gregg
              https://paiza.io is a great site to test and share sql code

              Comment


                #8
                Thanks everyone - I'll look at all the options and report back( once Santa has done his Job tomorrow (Australia)) - I though I would be alone on this problem, I'm glad I got these responses, was doubting myself - and thinking the whole thing is weird that there isn't an obvious xbasic function to accommodate what is a very common occurrence..

                Happy Holidays to you all.
                Insanity: doing the same thing over and over again and expecting different results.
                Albert Einstein, (attributed)
                US (German-born) physicist (1879 - 1955)

                Comment


                  #9
                  One final thought, (although I have not tested it yet):
                  Can you do a stringtran and replace the apostrophe with CHR(39) as in:
                  STRTRAN(LAST_NAME,"'","+CHR(39)+")
                  Again, I have not tested it, but it may/should work.

                  Merry Christmas,
                  Jay
                  Jay Talbott
                  Lexington, KY

                  Comment


                    #10
                    Originally posted by peteconway View Post
                    Thanks everyone - I'll look at all the options and report back( once Santa has done his Job tomorrow (Australia)) - I though I would be alone on this problem, I'm glad I got these responses, was doubting myself - and thinking the whole thing is weird that there isn't an obvious xbasic function to accommodate what is a very common occurrence..

                    Happy Holidays to you all.
                    Isn't it already tomorrow in Australia?
                    Santa2021_10pc.jpg
                    Last edited by Al Buchholz; 12-24-2021, 11:23 AM.
                    Al Buchholz
                    Bookwood Systems, LTD
                    Weekly QReportBuilder Webinars Thursday 1 pm CST

                    Occam's Razor - KISS
                    Normalize till it hurts - De-normalize till it works.
                    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
                    When we triage a problem it is much easier to read sample systems than to read a mind.
                    "Make it as simple as possible, but not simpler."
                    Albert Einstein

                    http://www.iadn.com/images/media/iadn_member.png

                    Comment


                      #11
                      Originally posted by Al Buchholz View Post

                      Isn't it already tomorrow in Australia?
                      Santa2021_10pc.jpg
                      Would it not be "today" in Oz no matter what? "tomorrow" will always be "tomorrow"? :-)

                      Pedantic Englishman!!!
                      Glen Schild



                      My Blog

                      Comment


                        #12
                        Cheers - guys, Jay I think that will work..
                        Pete.. speak tomorrow
                        Insanity: doing the same thing over and over again and expecting different results.
                        Albert Einstein, (attributed)
                        US (German-born) physicist (1879 - 1955)

                        Comment


                          #13
                          Hey Pete,

                          Assuming you use arguments in your sql, this is one time where Alpha does things right.
                          if your code is " select lastname from clients where lastname = :lastName " and you
                          configured the args to include args.Set("lastName","O'bri"), alpha does it's trickery as shown in post 7
                          to make the insert work as expected.
                          Gregg
                          https://paiza.io is a great site to test and share sql code

                          Comment


                            #14
                            The answer was hard to find but easy to implement, you just replace the single ' to '' double.
                            Thanks everyone, I have been totally drained from solving issues (bug work arounds) in the last few months and was burnt out, had a months break now - all good.

                            dim firstName as C = ALLTRIM(e.dataSubmitted.FirstName) Sally
                            dim lastName as c = STRTRAN(e.dataSubmitted.LastName,"'","''") O'Toole
                            sql = "INSERT INTO [Authoriser] (LastName,FirstName) "

                            sql = sql + "VALUES ('"+ lastName + "','" + firstName)

                            Sally O'Toole
                            Insanity: doing the same thing over and over again and expecting different results.
                            Albert Einstein, (attributed)
                            US (German-born) physicist (1879 - 1955)

                            Comment

                            Working...
                            X