Suneido

Integrated Application Platform

  • Home
  • Learning
    • Suneido Manual
    • Beginners
      • Inside Suneido
      • The Suneido Programming Language
      • The Suneido Database
      • Installing Suneido
      • Building Suneido
      • IDE Go To Tour
      • Upgrading To A New Release
    • Advanced
      • Canvas Control
      • DrawControl Part 1
      • DrawControl Part 2
      • DrawControl Part 3
      • SAX Like XML Processing
      • A Plug-In Architecture
      • A Simple Wizard Framework
      • An HTML Include Facility
      • An RSS 2 Feed Creator
      • MIME Generation
      • A New Add-on Facility
      • Workspace Improvement Hack
    • Mockito for Suneido
    • The Suneido Task Scheduler
    • Contributing To Suneido
    • Contributor Assignment of Copyright
    • Language Translation
    • Future Directions
    • Interview With Andrew Mckinlay
  • Forum
    • Announcements
    • Internals & Enhancements
    • Cookbook
    • General
  • FAQ
  • Screenshots
  • Downloads
  • Links

Updating records in a database

Integrated Application Platform › Forums › General › Updating records in a database

  • This topic has 5 replies, 2 voices, and was last updated 10 years, 4 months ago by Anonymous.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • September 26, 2012 at 2:34 pm #738
    Anonymous
    Inactive

    Hello. I have a new project going on. I need to update the prices on my customer database. I am trying to use QueryApply but am having trouble. Im sure its a simple problem but Im stuck. Here is the code:

    function()
    {
    QueryApply(‘inv_customer’)
    { |x|
    x.cb_price = .ncb_price
    x.Update()
    }
    }

    Controller
    {
    Title: ‘Wagram Paper Stock Customer Price Adjustment’
    Xmin: 800
    Ymin: 500

    Controls:
    (Vert
    (Skip)
    (Horz (Skip 300)
    (Static, “Customer Price Addjustment” font: (name: Arial size: 30)))
    (Skip)
    (Skip)
    (Horz (Skip 150)
    (ncb_price)
    (Skip 10)
    (Static, ‘Official Board Market’))
    (Horz (Skip 150)
    (now_price)
    (Skip 10)
    (Static, ‘Official Board Market’))
    (Horz (Skip 150)
    (ntube_price))
    (Horz (Skip 150)
    (nnews_price))
    (Horz (Skip 150)
    (nmixed_paper_price))
    (Horz (Skip 150)
    (nplastic_bot_price))
    (Horz (Skip 150)
    (nplastic_film_price))
    (Horz (Skip 150)
    (naluminum_price))
    (Horz (Skip 150)
    (nrecyclables_price))
    (Horz (Skip 150)
    (nsteel_price))
    (Skip)
    (Skip)
    (Horz (Skip 300) (Button, “OK”) (Button, “Cancel”))

    )
    On_OK()
    {
    Alert(‘You are about to update all customer prices’ Title: ‘ALERT’)
    Inv_price_update()
    }
    }

    I need to update all the prices that are entered but started with just the ncb_price to figure it out.
    Thanks for your help
    Benny

    September 26, 2012 at 2:53 pm #943
    j_ferguson
    Moderator

    Hi,

    Are you trying to update your database records based on the prices that are entered on the screen? To do that you’ll need to get the data from the screen and pass it to your function that does the QueryApply. Try using a RecordControl at the top level of your Controller controls. Then in your On_Ok method you should be able to reference the RecordControl’s data (which should include all the price amounts entered on the screen) by using .Data.Get()

    Once you have the screen data you can pass it to your Inv_price_update function. Assuming your parameter is called data, the line to set the cb_price field would then be:

    x.cb_price = data.ncb_price

    I hope I am understanding what you are trying to do.

    Jeff Ferguson

    September 26, 2012 at 3:00 pm #944
    j_ferguson
    Moderator

    I also forgot to mention that you will need to pass true in the update argument to QueryApply. By default it uses a readonly transaction:

    QueryApply(‘inv_customer’, update:)
    …

    Jeff Ferguson

    September 26, 2012 at 6:16 pm #945
    Anonymous
    Inactive

    Thanks for your reply, but Im still not doing something right. I get the following error: ‘uninitialized member: #Class56_data’ when the function is called. I am reposting the new code

    //Inv_price_update
    function(data)
    {
    QueryApply(‘inv_customer’, update:)
    { |x|
    x.cb_price = data.ncb_price
    x.Update()
    }
    }

    //Account Entry
    Controller
    {
    Title: ‘Wagram Paper Stock Customer Price Adjustment’
    Xmin: 800
    Ymin: 500

    Controls:
    (Record
    (Vert
    (Skip)
    (Horz (Skip 300)
    (Static, “Customer Price Addjustment” font: (name: Arial size: 30)))
    (Skip)
    (Skip)
    (Horz (Skip 150)
    (ncb_price)
    (Skip 10)
    (Static, ‘Official Board Market’))
    (Horz (Skip 150)
    (now_price)
    (Skip 10)
    (Static, ‘Official Board Market’))
    (Horz (Skip 150)
    (ntube_price))
    (Horz (Skip 150)
    (nnews_price))
    (Horz (Skip 150)
    (nmixed_paper_price))
    (Horz (Skip 150)
    (nplastic_bot_price))
    (Horz (Skip 150)
    (nplastic_film_price))
    (Horz (Skip 150)
    (naluminum_price))
    (Horz (Skip 150)
    (nrecyclables_price))
    (Horz (Skip 150)
    (nsteel_price))
    (Skip)
    (Skip)
    (Horz (Skip 300) (Button, “OK”) (Button, “Cancel”))
    )
    )
    On_OK()
    {
    .Data.Get()
    Alert(‘You are about to update all customer prices’ Title: ‘ALERT’)
    Inv_price_update(.data)
    }
    }

    Thanks again

    September 26, 2012 at 9:51 pm #946
    j_ferguson
    Moderator

    You need to save the data in a local variable and pass that to your function something like this:

    On_OK()
    {
    data = .Data.Get()
    Alert(‘You are about to update all customer prices’ Title: ‘ALERT’)
    Inv_price_update(data)
    }

    Jeff Ferguson

    September 27, 2012 at 6:39 pm #947
    Anonymous
    Inactive

    Thanks for your assistance again. It is great how quickly you provide support here. It makes learning your program so much better.

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Log In

Search Forums

Log In
Welcome to the new Suneido Web Site and Forum.
Register
Lost Password
users of the previous PHPBB Forum should be able to log in with their previous username and password.

Recent Topics

  • Alpha copy of gSuneido to play with
  • how to start jsuneido ?
  • Problem Starting Suneido…
  • Dialog not showing buttons
  • New link for Suneidojo

Contact Us | Legal Statement | Privacy Statement | SiteMap

Copyright © 2023 Axon® Development Corporation. All Rights Reserved. - Open Source Integrated Database and Programming Language