Hi all,

In my forms application I use column for simple arithmetic calculation as in EXCEL. This is specially used in numeric columns. Ex. =10+202 entered in a column will replace this expression with 50. However, formspider does not permit entry of non-numeric characters like ,-,= etc in numeric columns. Therefore I cannot implement this functionality. How can I implement this functionality in formspider?

George.

asked 24 Mar '13, 23:44

George's gravatar image

George
1111229
accept rate: 0%

I write =10+20 star 2 but question removed the star without my permission.

George

(24 Mar '13, 23:49) George

Hi George,

As you mentioned, Formspider does not permit entry of calculation expressions into numeric columns. To implement this functionality, you should assign a varchar2 datatyped domain to your numeric datasource column where the calculation expression needs to be entered. To achieve this:

  • From the Formspider IDE, open the datasource definition edit dialog for the datasource definition containing this numeric column
  • Expand "Columns" node from the tree existing at the left side of the dialog, all columns are listed
  • Click on the numeric column where the calculation expression needs to be entered and select "DefaultVarchar2" option from the "Domain" combobox. This selection overrides the original datatype of the column.
  • Press "OK" to save your change.

As the next step you have to implement a calculation procedure which can be called from the valueChanged event of the calculation field. This procedure needs to perform the calculation and also restrict and ignore the characters that are entered in the field. A quick example can be as follows:

procedure calculate is
  v_formula_tx    varchar2(4000);
  v_result_nr     number;
  v_validChars_tx varchar2(255) := '+-.*,=()0123456789';
begin
  -- retrieve the calculation expression
  v_formula_tx := api_datasource.getColumnValueTX('dataourceName.columnName');
  -- check if the calculation expression contains invalid chars
  if trim(translate(v_formula_tx, v_validChars_tx, ' ')) is null then -- expression or numeric value
    if substr(v_formula_tx, 1,1) = '=' then -- expression
      begin
        execute immediate 'begin :1 :'||v_formula_tx ||'; end;' using out v_result_nr;
      exception 
        when others then -- invalid expression
          null;
      end;
    else
      begin
        v_result_nr := to_number(v_formula_tx);
      exception 
        when others then -- invalid numeric value or expression
          null;
      end;
    end if;
  end if;

  -- set the result
  api_datasource.setcolumnvalue('dataourceName.columnName', v_result_nr);
end;

Hope this helps,
Ibrahim

link

answered 25 Mar '13, 05:24

Ibrahim%20Sandalli's gravatar image

Ibrahim Sand... ♦♦
1.5k5
accept rate: 25%

Hi Ibrahim,

Thank you for the feedback. I will try this.

George.

(25 Mar '13, 10:18) George
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×2
×1

Asked: 24 Mar '13, 23:44

Seen: 726 times

Last updated: 25 Mar '13, 10:18

Related questions


© Copyright Gerger 2017