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

Xbasic SQL INSERT and Null field issue

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

    Xbasic SQL INSERT and Null field issue

    I have an Xbasic function in a UX component that writes a record to a table using SQL INSERT. What I can't figure out is this...

    For example. The COST field is a decimal(15,2) field. If I leave the field blank, the script will not write anything. If I put a number in it, it works fine and writes the record. Same goes for anything with the numeric or decimal field type. (using numeric from this point on).

    Why is that?

    Here's the script.

    Code:
    function checkinv as c (e as p)
    	'debug(1)
    	dim cn as sql::Connection
    	dim result as l = .f.
    	dim args as sql::Arguments
    	dim rs as sql::ResultSet
    	dim sqlstm as c 
    	dim sku as n
    	dim location as n
    	dim timeadded as t
    	dim dateadded as d
    	dim store as c
    	dim isDelete as l
    	dim Inventory as l
    	location = "1001"
    	isBarcode = "1"
    	timeadded = now()
    	dateadded = date()
    	store = "102"
    	isDelete = "0"
    	Inventory = "1"
    	
    	result = cn.open("::Name::SQL")
    	if result then
    			sqlstm = "SELECT MAX(SKU) FROM Inventory_NEW WHERE isBarcode = :isBarcode"
    			args.Set("loc",location)
    			args.Set("isBarcode",isBarcode)
    			result = cn.execute(sqlstm,args)
    				if result then 
    				rs = cn.ResultSet
    				sku = rs.data(1)
    				sku = sku+1
    				e._set.skuresult.value = sku
    				
    			sqlTruncateStatement = "TRUNCATE table Inventory_TEMP"
    			cn.Execute(sqlTruncateStatement)
    			sqlInsertStatement = "INSERT into Inventory_TEMP (Quantity,SKU) values (:qty, :BarCodeValue)"
    			args.Set("BarCodeValue",sku)
    			for i = 1 to val(e.dataSubmitted.copies)
    				args.Set("qty",i)
    				cn.Execute(sqlInsertStatement,args)
    			next i
    			
    			args.set("NEWUSED",e.dataSubmitted.NEWUSED)
    			args.set("CATEGORY",e.dataSubmitted.CATEGORY)
    			args.set("ITEM",e.dataSubmitted.ITEM)
    			args.set("MODEL",e.dataSubmitted.VENDORMODEL)
    			args.set("SIZE",e.dataSubmitted.SIZE)
    			args.set("PRICE",e.dataSubmitted.PRICE)
    			args.set("ACTIVE",e.dataSubmitted.ACTIVE)
    			args.set("DATEADDED",dateadded)
    			args.set("TIMEADDED",timeadded)
    			args.set("QUANTITY",e.dataSubmitted.QUANTITY)
    			args.set("ISBARCODE",isBarcode)
    			args.set("SKURESULT",sku)
    			args.set("TAX1",e.dataSubmitted.TAX1)
    			args.set("ADDITIONALINFO",e.dataSubmitted.ADDITIONALINFO)
    			args.set("STOREGEN",store)
    			args.set("COPIES",e.dataSubmitted.COPIES)
    			args.set("TAXEXEMPT",e.dataSubmitted.TAXEXEMPT)
    			args.set("INVENTORY",e.dataSubmitted.INVENTORY)
    			args.set("SIZE_GROUP",e.dataSubmitted.SIZE_GROUP)
    			args.set("SUPPLIER",e.dataSubmitted.SUPPLIER)
    			args.set("MANUFACTURER",e.dataSubmitted.MANUFACTURER)
    			args.set("DESCRIPTION",e.dataSubmitted.DESCRIPTION)
    			args.set("LOCATION",e.dataSubmitted.LOCATION)
    			args.set("REORDERLEVEL",e.dataSubmitted.REORDERLEVEL)
    			args.set("FINANCEPRICE",e.dataSubmitted.FINANCEPRICE)
    			args.set("COST",e.dataSubmitted.COST)
    			args.set("PRICEMULTIPLE",e.dataSubmitted.PRICEMULTIPLE)
    			args.set("FINANCEMULTIPLE",e.dataSubmitted.FINANCEMULTIPLE)
    			args.set("PRODUCTID",e.dataSubmitted.PRODUCTID)
    			args.set("PRICESHEETHEADER",e.dataSubmitted.PRICESHEETHEADER)
    			args.set("PRICESHEETDESCRIPTION",e.dataSubmitted.PRICESHEETDESCRIPTION)
    			args.set("PRODUCTVARIABLE",e.dataSubmitted.PRODUCTVARIABLE)
    			
    			
    			dim sqlInsertInventory as c 
    			sqlInsertInventory = "INSERT INTO Inventory_New (new_used, category, item_name, Size, price, Active, DateAdded, TimeAdded, quantity, isBarcode, SKU, tax1, additionalinfo, StoreGen, Copies, TaxExempt, cost, VendorModel, Inventory, Size_Group, supplier, manufacturer, description, location, reorderlevel, FinancePrice,PriceMultiple, FinanceMultiple, ProductID, ProductVariable, PriceSheetHeader, PriceSheetDescription) VALUES (:NEWUSED, :CATEGORY, :ITEM, :SIZE, :PRICE, :ACTIVE, :DATEADDED, :TIMEADDED, :QUANTITY, :ISBARCODE, :SKURESULT, :TAX1, :ADDITIONALINFO, :STOREGEN, :COPIES, :TAXEXEMPT, :COST, :MODEL, :INVENTORY, :SIZE_GROUP, :SUPPLIER, :MANUFACTURER, :DESCRIPTION, :LOCATION, :REORDERLEVEL, :FINANCEPRICE, :PRICEMULTIPLE, :FINANCEMULTIPLE, :PRODUCTID, :PRODUCTVARIABLE, :PRICESHEETHEADER, :PRICESHEETDESCRIPTION )"
    			cn.Execute(sqlInsertInventory,args)
    			
    	end if
    	cn.close()
    end if
    end function

    AND... see the image attached. I get the squiggly red line under end function with this warning message. Script works just fine except for the numeric/decimal fields when blank.

    GRAPHICS-0016.png

    #2
    Re: Xbasic SQL INSERT and Null field issue

    Must likely the COST field is trying to be inserted as Character if blank.

    I would test
    if e.dataSubmitted.COST = "" then
    e.dataSubmitted.COST = null_value()
    end if

    AND... see the image attached. I get the squiggly red line under end function with this warning message. Script works just fine except for the numeric/decimal fields when blank.
    The squiggly red line is just indicating that you have not returned anything back to the client.

    You can use "return" key word or checkinv = "" or have it equal some js like checkinv = "alert('Invoice Checked');"
    Alex Collier

    "The spread of computers and the Internet will put jobs in two categories. People who tell computers what to do, and people who are told by computers what to do"

    AA Builds from 5221_5152 to Pre-releases >> Deploying to IIS in AWS

    Comment


      #3
      Re: Xbasic SQL INSERT and Null field issue

      Originally posted by dfricke10 View Post
      AND... see the image attached. I get the squiggly red line under end function with this warning message. Script works just fine except for the numeric/decimal fields when blank.
      This was a change made in Pre-release build 5675... http://aadocuments.s3.amazonaws.com/...easeNotes.Html
      Xbasic Editors - Functions

      Comment


        #4
        Re: Xbasic SQL INSERT and Null field issue

        Thanks, Alex. That led me in the right direction.

        As for the squiggly line, understand now. But, oddly the function still works? Is it causing some other problem by not having the return function?

        Comment


          #5
          Re: Xbasic SQL INSERT and Null field issue

          It's just a warning... a reminder... to return something from the function... otherwise no ill effects.

          Comment


            #6
            Re: Xbasic SQL INSERT and Null field issue

            Since we're on this topic of this script, I added an ImageUpload component to it. running in Desktop, using a Character image field. This script above writes the record. I've added the argument for the field and the script fails when an image has been selected. If I do not specify an image, it saves the "null_1x1.png.a5image" to the field. My assumption is, since it's an Xbasic script to begin with, I need to use the FileUpload User Defined and integrate it into my current function?

            Comment


              #7
              Re: Xbasic SQL INSERT and Null field issue

              How are you getting the image data? Is it base64 data? What are the table field properties? What is the error message?

              Comment

              Working...
              X