1 package body iby_accttype_pkg as
2 /*$Header: ibyactpb.pls 115.8 2002/11/15 23:50:06 jleybovi ship $*/
3
4 /*
5 ** Function: createAcctType.
6 ** Purpose: creates the acct type information, if it is not already
7 ** there in the database.
8 ** and passes back the corresponding accttypeid id.
9 */
10 procedure createAcctType( i_accttype in iby_accttype.accttype%type,
11 i_instrtype in iby_accttype.instrtype%type,
12 io_accttypeid in out nocopy iby_accttype.accttypeid%type)
13 is
14 l_accttypeid iby_accttype.accttypeid%type;
15 cursor c_accttypeid is
16 select iby_accttype_s.nextval
17 from dual;
18 cursor c_get_accttypeid(ci_accttype in iby_accttype.accttype%type,
19 ci_instrtype in iby_accttype.instrtype%type)
20 is
21 SELECT accttypeid
22 FROM iby_accttype
23 WHERE accttype = ci_accttype
24 AND instrtype = ci_instrtype;
25 begin
26 /*
27 ** close the cursor if it is already open.
28 */
29 if ( c_get_accttypeid%isopen ) then
30 close c_get_accttypeid;
31 end if;
32 /*
33 ** open the cursor and check if the corresponding name exists in the
34 ** database.
35 */
36 open c_get_accttypeid(i_accttype, i_instrtype);
37 fetch c_get_accttypeid into l_accttypeid;
38
39
40 if ( c_get_accttypeid%notfound ) then
41 /*
42 ** if the finame is not there in the database then create the entry
43 ** in the database.
44 */
45 if ( c_accttypeid%isopen ) then
46 close c_accttypeid;
47 end if;
48 open c_accttypeid;
49 fetch c_accttypeid into l_accttypeid;
50 /*
51 ** insert name in the database.
52 */
53 INSERT INTO iby_accttype ( accttypeid, accttype, instrtype,
54 last_update_date, last_updated_by,
55 creation_date, created_by,
56 last_update_login, object_version_number)
57 VALUES ( l_accttypeid, i_accttype, i_instrtype,
58 sysdate, fnd_global.user_id,
59 sysdate, fnd_global.user_id,
60 fnd_global.login_id, 1);
61
62 close c_accttypeid;
63 end if;
64
65 io_accttypeid := l_accttypeid;
66 close c_get_accttypeid;
67 --commit;
68 end createaccttype;
69 end iby_accttype_pkg;