Hi formspider team,

with api_datasource.createrow i can create new rows before the current row (with in_nextsiblingrow_id) or after the last row (use only parameter datasource).

Is there somekind of workaround to create a row AFTER the current row. That experienced Oracle Forms users that would be more logical :)

Kind regards, Jan Willem Vermeer

asked 09 Jun, 10:04

Jan%20Willem%20Vermeer's gravatar image

Jan Willem V...
1231331
accept rate: 0%


Hi Jan Willem,

As a work-around, you can use

api_datasource.nextrow('DS')
api_datasource.createrow('DS', in_nextsiblingrow_id=>api_datasource.getcurrentrowid('DS'))

Kind Regards Serdar

link

answered 03 Jul, 05:29

Serdar's gravatar image

Serdar ♦♦
100k4
accept rate: 14%

Hi Serdar,

it's a little bit complicated because "force current row" has been activated because the DS might be empty. And when the user clicks in the empty row, a new row has to be created.

My PLSQL for this is:

-- Create record
CASE api_datasource.getRowStatus('DS_NAME')
WHEN api_datasource.row_status_temp THEN
-- This is a blank record
  l_row_id := api_datasource.getCurrentRowid('DS_NAME');
WHEN api_datasource.row_status_new THEN
-- Check of the user has started the new record by just entering values. If so, the key will not be null anymore and we need to create the next row.
   IF api_datasource.getColumnValueNR('DS_NAME.PK_VALUE') IS NULL --
   THEN                                                                    --
     l_row_id := api_datasource.getCurrentRowid('DS_NAME');
   ELSE
-- This a new record
     l_row_id := api_datasource.createRow( 'DS_NAME' );
   END IF;
ELSE
-- Create record after current record
  l_row_id := api_datasource.createRow( 'DS_NAME', api_datasource.getCurrentRowid('DS_NAME') );
END CASE;

So i can not just add nextrow to this, because that only works when there is a next row... I need to add tests for that too. And that might lead to exceptions... If you have a smart idea for this, please let me know.

Kind regards, Jan Willem

link

answered 03 Jul, 06:57

Jan%20Willem%20Vermeer's gravatar image

Jan Willem V...
1231331
accept rate: 0%

Hi,

i have created a generic procedure that creates a new row after the current row or as first row in a datasource. Can you check if there is something missing?

Kind regards, Jan Willem

  PROCEDURE doNewRow(
      p_datasource_name IN VARCHAR2 ,
      p_row_id          IN OUT NUMBER )
  IS
  BEGIN
    CASE api_datasource.getRowStatus(p_datasource_name)
    WHEN api_datasource.row_status_temp THEN
      -- This is a blank row
      p_row_id := api_datasource.getCurrentRowid(p_datasource_name);
    WHEN api_datasource.row_status_new THEN
      -- Check of the user has started the new record by just entering values. 
      -- If so, the key will not be null anymore and we need to create the next row.
      -- in this example the key always has the name PMS_UID :)
      IF api_datasource.getColumnValueNR(p_datasource_name||'.PMS_UID') IS NULL --
        THEN                                                                    --
        p_row_id := api_datasource.getCurrentRowid(p_datasource_name);
      ELSE
        -- This a new record
        p_row_id := api_datasource.createRow( p_datasource_name );
      END IF;
    ELSE
      -- Create record after current record
      IF api_datasource.getRowNumber(p_datasource_name) < api_datasource.getRowCount(p_datasource_name) THEN
        api_datasource.nextRow(p_datasource_name);
        p_row_id := api_datasource.createrow(p_datasource_name, in_nextsiblingrow_id=>api_datasource.getcurrentrowid(p_datasource_name));
        api_datasource.previousRow(p_datasource_name);
      ELSE
        p_row_id := api_datasource.createrow(p_datasource_name);
        api_datasource.nextRow(p_datasource_name);
      END IF;
    END CASE;
  END doNewRow;
link

answered 03 Jul, 12:22

Jan%20Willem%20Vermeer's gravatar image

Jan Willem V...
1231331
accept rate: 0%

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:

×1

Asked: 09 Jun, 10:04

Seen: 143 times

Last updated: 03 Jul, 12:22

Related questions


© Copyright Gerger 2017