Home » Developer & Programmer » Forms » How column name of a database column can be changed at runtime (Form 10g)
How column name of a database column can be changed at runtime [message #544240] Mon, 20 February 2012 20:08 Go to next message
kumarsanjeeva
Messages: 16
Registered: April 2010
Location: Delhi
Junior Member

My form has to go into two different environment in which the one column name of a table is different. datatype is same.

I would like to change the database column name of the item in the form for that block at run time.

Please let me know if it is possible or is there any alternate way to do this.
Re: How column name of a database column can be changed at runtime [message #544264 is a reply to message #544240] Tue, 21 February 2012 00:09 Go to previous messageGo to next message
Littlefoot
Messages: 19699
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Quote:
change the database column name of the item in the form for that block at run time.

I don't think that you can do that. If there was, it would be handled by SET_ITEM_PROPERTY. But, unless I'm wrong, there's no "DATABASE_ITEM" or similar property.

The simplest way would be to rename a column:
SQL> desc test
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 DEPTNO                                             NUMBER(2)
 DNAME                                              VARCHAR2(14)
 LOC                                                VARCHAR2(13)

SQL> alter table test rename column loc to location;

Table altered.

SQL> desc test
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 DEPTNO                                             NUMBER(2)
 DNAME                                              VARCHAR2(14)
 LOCATION                                           VARCHAR2(13)

SQL>

That might be tricky if a table (and its column) is referenced elsewhere (in other forms, reports, stored procedures, etc.).

If that's not possible, perhaps you could create a view and unify column names, and then create a form on a view:
SQL> create or replace view view_form as
  2  select 'ENV_1' environment, deptno, dname, loc
  3    from dept
  4  union
  5  select 'ENV_2' environment, deptno, dname, location
  6    from test;

View created.

SQL> select * from view_form
  2  where environment = 'ENV_2';

ENVIR     DEPTNO DNAME          LOC
----- ---------- -------------- -------------
ENV_2         10 ACCOUNTING     NEW YORK
ENV_2         20 RESEARCH       DALLAS
ENV_2         30 SALES          CHICAGO
ENV_2         40 OPERATIONS     BOSTON

SQL>


Someone else might have a better idea, though.
Re: How column name of a database column can be changed at runtime [message #544299 is a reply to message #544264] Tue, 21 February 2012 03:00 Go to previous message
cookiemonster
Messages: 11076
Registered: September 2008
Location: Rainy Manchester
Senior Member
As far as I'm concerned the only sensible solution is to rename the column in the DB so both are the same. It makes no sense to run the same forms application against 2 DB's with different structures.
Previous Topic: Problem Running forms 11g
Next Topic: Compiling multiple FMB
Goto Forum:
  


Current Time: Sat Oct 25 22:53:39 CDT 2014

Total time taken to generate the page: 0.08127 seconds