Hi,

See thread http://osqa.theformspider.com/questions/5339/how-can-i-detect-the-data-type-of-a-column for a generic procedure to simulate the Oracle Forms "Duplicate Field" (F3) function.

Kind regards, Jan Willem Vermeer

asked 03 Oct, 13:00

Jan%20Willem%20Vermeer's gravatar image

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


Hi there, I use the following code to copy/paste entire records:

create or replace package FS_CPREC_PKG is

  -- Author  : Cezar Nechifor
  -- Created : 05/08/2016 09:54:30
  -- Purpose : Copy-Paste a record in Formspider

  -- Public variable declarations
   ttRow    api_datasource.tt_row;  --datasource row. keep copied row
   vDataSrc varchar2(255);          --datasource name of copied row

  -- Public function and procedure declarations
  procedure CopyRec(vDatasource varchar2);
  procedure PasteRec(vDatasource varchar2);

end FS_CPREC_PKG;

create or replace package body FS_CPREC_PKG is
--
/**
  %author Cezar Nechifor 2016-08-05
  %usage Copy current record of vDatasource
*/
procedure CopyRec(vDatasource varchar2) is
begin
  ttRow    := api_datasource.getRow(vDatasource);
  vDataSrc := vDatasource;
end;
--
/**
  %author Cezar Nechifor 2016-08-05
  %usage Paste values from ttRow into current record of vDatasource
  %nt Keep in mind to take care of primary key generation of new record ...
  %nt I do this in my actSave procedure
  %nt if(api_datasource.getrowstatus(kvDataSource) = 'New') then
  %nt    execute immediate 'select '||kvSeq||'.nextval from dual' into nId;
  %nt    api_datasource.setcolumnvalue(kvDataSource||'.'||kvKeyColumn, nId);
  %nt .....
*/
procedure PasteRec(vDatasource varchar2) is
  ttCols api_datasource.tt_columns;
begin
  if(vDatasource <> vDataSrc) then  --paste from different datasource is not allowed
    raise_application_error(-20000, 'Actual Paste datasource='||vDataSrc);
  end if;
  ttCols := api_datasource.getColumnNames(vDataSource);
  for i in ttCols.First..ttCols.Last loop
    if(ttCols(i).datatype_cd = 'VARCHAR2') then
      api_datasource.setColumnValue(vDatasource||'.'||ttCols(i).name_tx, ttRow(ttCols(i).name_tx).value_tx);
    elsif(ttCols(i).datatype_cd = 'NUMBER') then
      api_datasource.setColumnValue(vDatasource||'.'||ttCols(i).name_tx, ttRow(ttCols(i).name_tx).value_nr);
    elsif(ttCols(i).datatype_cd = 'DATE') then
      api_datasource.setColumnValue(vDatasource||'.'||ttCols(i).name_tx, ttRow(ttCols(i).name_tx).value_dt);
    end if;
  end loop;
end;
--
begin
  -- Initialization
  null;
end FS_CPREC_PKG;
link

answered 04 Oct, 07:19

brg's gravatar image

brg
2115
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:

×5
×4

Asked: 03 Oct, 13:00

Seen: 130 times

Last updated: 04 Oct, 07:19


© Copyright Gerger 2017