Bisa dicoba cara sebagai berikut:
create or replace function get_nourut( p_cabang in varchar2 ) return number
as
l_theCursor integer default dbms_sql.open_cursor;
l_columnValue number default NULL;
l_status integer;
begin
dbms_sql.parse( l_theCursor, 'select nourut_'||p_cabang||'.nextval from
dual',dbms_sql.native );
dbms_sql.define_column( l_theCursor, 1, l_columnValue );
l_status := dbms_sql.execute(l_theCursor);
if ( dbms_sql.fetch_rows(l_theCursor) > 0 )
then
dbms_sql.column_value( l_theCursor, 1, l_columnValue );
end if;
dbms_sql.close_cursor( l_theCursor );
return l_columnValue;
end ;
/
create sequence nourut_100 start with 1 increment by 1;
create sequence nourut_200 start with 1 increment by 1;
create sequence nourut_300 start with 1 increment by 1;
select get_nourut('100') from dual;
GET_NOURUT('100')
-----------------
1
select get_nourut('200') from dual;
GET_NOURUT('200')
-----------------
1
select get_nourut('100') from dual;
GET_NOURUT('100')
-----------------
2
select get_nourut('300') from dual;
GET_NOURUT('300')
-----------------
1
Salam,
Indra Armansyah
[EMAIL PROTECTED]
----- Original Message -----
From: "wawan mulyawan" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, October 13, 2006 1:56 PM
Subject: [indo-oracle] Panggil sequence dengan variable
> Saya punya permasalahan mengenai sequence yang berbeda beda tapi ingin
> di panggil dalam satu prosedure..
> Spesifikasinya seperti ini.
>
> Saya punya sequence untuk nomor urut transaksi, tetapi sequence itu
> untuk masih masing cabang
> Sample adalah
> nourut_100 untuk cabang 100
> nourut_200 untuk cabang 200 dst dst
>
> bagai mana memanggil sequence tersebut dengan function database yang
> mem-passing kode kantornya..
>
> misalnya
>
> function get_nourut(kdkntr number)
> nourut number;
> begin
> select nourut_???.nextval into nourut from dual;
> return(nourut);
> end;
>
> terima kasih atas bantuannya.
>
> Ti
> Mulyawan
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
> --
> -----------I.N.D.O - O.R.A.C.L.E---------------
> Keluar: [EMAIL PROTECTED]
> Website: http://indo-oracle.blogspot.com
> Mirror: http://indooracle.wordpress.com
> -----------------------------------------------
>
> Bergabung dengan Indonesia Thin Client User Groups,
> Terminal Server, Citrix, New Moon Caneveral, di:
> http://indo-thin.blogspot.com
> Yahoo! Groups Links
>
>
>
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.408 / Virus Database: 268.13.3/473 - Release Date: 10/12/2006
>
>
--
-----------I.N.D.O - O.R.A.C.L.E---------------
Keluar: [EMAIL PROTECTED]
Website: http://indo-oracle.blogspot.com
Mirror: http://indooracle.wordpress.com
-----------------------------------------------
Bergabung dengan Indonesia Thin Client User Groups,
Terminal Server, Citrix, New Moon Caneveral, di:
http://indo-thin.blogspot.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/indo-oracle/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/indo-oracle/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/