Probability Distribution Functions in Oracle PL/SQL
Hello,
I have the need to calculate some standard probability distribution functions as part of my PL/SQL code. Does Oracle DB offer any packages that will enable such calculations to be performed?
In parituclar, i am looking for cumulative distribution functions for Normal distribution and T-distribution
Thanks,
Kartik
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/functions29a.htm#82888
Similar Messages
-
How can i migrate Power Builder 8.0 Function into oracle PL/SQL
Hi Oracle Experts...
How can i migrate Power Builder 8.0 Function into oracle PL/SQL.. I had migrate some of the coding from PB to PL/SQL. But i don't know how can i convert PB structure(here structure is a data type) into oracle PL/SQL.
Instead of structure what is the equivalent in oracle plsql
Below i pasted my POWER BUILDER FUNCTION:
Long ll_perd,ll_lnperd,ll_mon,ll_effmon,ll_instno,ll_odno
Decimal{5} ldl_actual,ldl_diff,ldl_inst
Datetime ldt_first,ldt_exp,ldt_oddt, ldt_lastprod
String ls_instmode,ls_inst
str_batch lstr_od //Structure to store odamt and oddate
Select pay_c_final,lon_d_expiry, lon_d_lastprod
Into :ls_inst,:ldt_exp, :ldt_lastprod
From loan_mast
Where branch_c_code = :gs_branch and
act_c_type = :as_actype and
act_c_no = :as_acno;
If Sqlca.Sqlcode = -1 Then
f_message('FT-0189',Sqlca.Sqlerrtext)
lstr_od.batchslno = -1
Return lstr_od
End If
If adt_prodt > ldt_exp Then
Select Ceil(months_between(:adt_prodt,:ldt_exp)) Into :lstr_od.batchslno From dual;
lstr_od.cheqdt = ldt_exp
lstr_od.batchslno = DaysAfter(Date(ldt_lastprod), Date(adt_prodt))
Else
If ls_inst = 'N' Then
If adt_prodt > ldt_exp Then
Select Ceil(months_between(:adt_prodt,:ldt_exp)) Into :lstr_od.batchslno From dual;
lstr_od.cheqdt = ldt_exp
Else
lstr_od.batchslno = 1
End If
ElseIf ls_inst = 'Y' Then
Select first_d_due,lon_c_instperd,lon_n_perd
Into :ldt_first,:ls_instmode,:ll_lnperd
From loan_mast
Where branch_c_code = :gs_branch and
act_c_type = :as_actype and
act_c_no = :as_acno;
If Sqlca.Sqlcode = -1 Then
f_message('FT-0189',Sqlca.Sqlerrtext)
lstr_od.batchslno = -1
Return lstr_od // Return Structure
End If
Select Ceil(months_between(:adt_prodt,:ldt_first)) Into :ll_mon from dual;
If ll_mon > 0 Then
Select Nvl(ln_n_balance,0),Nvl(ln_n_instlamt,0),Nvl(ln_n_instlno,0)
Into :ldl_actual,:ldl_inst,:ll_instno
From loan_inst_sch
Where act_c_type = :as_actype and
act_c_no = :as_acno and
ln_d_effdate = (Select Max(ln_d_effdate)
From loan_inst_sch
Where act_c_type = :as_actype and
act_c_no = :as_acno and
ln_d_effdate < :adt_prodt);
If Sqlca.Sqlcode = -1 Then
f_message('FT-0224', Sqlca.Sqlerrtext)
lstr_od.batchslno = -1
Return lstr_od
ElseIf Sqlca.Sqlcode = 100 Then
lstr_od.batchslno = 1
* Return lstr_od*
End If
If adl_bal > ldl_actual Then
If ldl_inst > 0 Then
lstr_od.batchslno = (adl_bal - ldl_actual) / ldl_inst
End If
Else
lstr_od.batchslno = 1
End If
If lstr_od.batchslno = 0 Then lstr_od.batchslno = 1
//For full OD
If ll_mon > ll_lnperd Then
lstr_od.batchslno = (ll_mon - ll_lnperd) + lstr_od.batchslno
End If
If ls_instmode = 'Q' Then
lstr_od.batchslno = lstr_od.batchslno * 3
ElseIf ls_instmode = 'H' Then
lstr_od.batchslno = lstr_od.batchslno * 6
ElseIf ls_instmode = 'Y' Then
lstr_od.batchslno = lstr_od.batchslno * 12
End If
Select :adt_prodt - :lstr_od.batchslno Into :lstr_od.cheqdt From dual;
If ls_instmode = 'M' Then
ll_odno = ll_instno - lstr_od.batchslno // To get OD Date
Select ln_d_effdate
Into :lstr_od.cheqdt
From loan_inst_sch
Where act_c_type = :as_actype and
act_c_no = :as_acno and
ln_n_instlno = :ll_odno;
If Sqlca.Sqlcode = -1 Then
f_message('FT-0224', + Sqlca.Sqlerrtext)
lstr_od.batchslno = -1
Return lstr_od
End If
End If
Else
lstr_od.batchslno = 1
End If
End If
End if
Return lstr_od
Thanks in adance
Arun M MWhat are you going to return the structure to? What I would normally use here if the code was going to be used by other PL/SQL would be a PL/SQL object type.
However, if PowerBuilder is still in the equation (you're moving the logic to PL/SQL but keeping PowerBuilder for the GUI ), then you'll have to return something else, because PowerBuilder doesn't understand PL/SQL object types. Perhaps passing a REF CURSOR as a OUT argument and populating it from the procedure. PowerBuilder could then retrieve the result of the procedure using a stored procedure based DataWindow. -
Spilt function in oracle pl/sql 8i
Hi,
iam actually looking for a split function , where in i get a string as
india australia pakistan, now i want to store them in three variables, in pl/sql
can any one help me out???
cheere...If I understand your questions.....
SQL> set serveroutput on
SQL> declare
2 var varchar2(100) := 'india australia pakistan';
3 var1 varchar2(50);
4 var2 varchar2(50);
5 var3 varchar2(50);
6 s1 number;
7 s2 number;
8 begin
9 s1 := instr(var,' ');
10 s2 := instr(var,' ',s1+1);
11 var1 := substr(var,1,s1-1);
12 var2 := substr(var,s1+1,s2-s1);
13 var3 := substr(var,s2+1);
14 dbms_output.put_line(var1||chr(10)||var2||chr(10)||var3);
15* end;
16 /
india
australia
pakistan
PL/SQL procedure successfully completed.
SQL>Tab substitution :
SQL> var v1 varchar2(100);
SQL> exec :v1 := 'india australia pakistan';
PL/SQL procedure successfully completed.
SQL> print v1
V1
india australia pakistan
SQL> exec :v1 := replace(:v1,chr(9),' ');
PL/SQL procedure successfully completed.
SQL> print v1
V1
india australia pakistan
SQL> In the first example, if you have tabs in the string, instead of spaces, change these lines :
9 s1 := instr(var,' ');
10 s2 := instr(var,' ',s1+1);with these ones :
9 s1 := instr(var,chr(9));
10 s2 := instr(var,chr(9),s1+1); -
Use T-SQL functions in ORACLE too, so you can write one script version that works in SYBASE, SQLSERVER and ORACLE when need to use the following functions:
ceiling, charindex, dateadd, datediff, datename, datepart, day, db_id, db_name, getdate, host_id, host_name, left, len, month, replicate, right, space, str, str_replace, stuff, substring, suser_id, suser_name, user_id, user_name and year.
The file [comp_tsql_ORA_schema.txt|http://forums.databasejournal.com/attachment.php?attachmentid=564&d=1258547015] creates the tablespace and schema to put the objects, and the file [comp_tsql_ORA.txt|http://forums.databasejournal.com/attachment.php?attachmentid=569&d=1259256898] creates the functions into the new schema. They will be avaliable for any schema of the oracle instance.
Hope this help!
Any suggestion please contact.
aklein2003
Edited by: user1958693 on 26/11/2009 10:16jgarry wrote:
J2EE beta released around 1999. Religious programming wars far preceded that. Here's but [one example|http://groups.google.com/group/comp.lang.lisp/browse_thread/thread/1c50bc13e9302f00/34bb8f3ac77e2388?q=programming+language+religion#34bb8f3ac77e2388] from a quick google. I'm no longer convinced that elegance is a desirable trait for a language. So call me a heretic.
Ever tried XLISP? :-)
It's different. Back then it was simply the language itself. And it was not really a religious kind of battle, but more a mine-is-bigger-and-better-than-yours one.
With Java, it is all about The Acrhitecture and the blessed language of Java. ;-)
I wouldn't so much blame J2EE believers for that. I think there is a fundamental complexity to web type paradigms that hasn't been described in a precise and encompassing enough manner to enable correct project planning.The basic problem is that the database is treated as a persistent storage layer only. A bit bucket. And that is exactly what a database is not.
But as it is used that, loads of database features now need to be duplicated in the application layer. Which is done. Very poorly.
Heck, I've even been told that J2EE's 3-tier architecture is not client server. Such ignorance is really unbelievable. Or is it pure stupidity?Until you just made me look it up, I would have thought that too, I'm sure I saw client/server defined as two-tier in the last century. But I have much more stupid misdefinitions to deal with on a daily basis, simply from the multiplicity of paradigms. I tend to retreat into my shell. Hehehe. Know that feeling... These days I rather run away, or set shields to full power, than try to get in yet another frustrating, fruitless and futile discussion with a Java head about the wonders of the J2EE architecture. Or trying to explain that this "new" architecture is predated with what we used in the 80's on mainframe systems with transaction monitors, block devices (the 80's web browsers) and databases - which software layer for software layer was almost identical to "+The Great Architecture+" of today. (and we did it without buzzwords too) ;-)
Client-server is a software architecture and in essence describes 3 basic software components. The User Interface (UI), the Application (APP) and the Database (DB). And there are various ways to put these components together in a client-server architecture. The mistake that the Java fanbois make is thinking that client-server means having the client as the UI and APP as a single component (so-called fat client) and then the DB component as the server.
There are numerous versions of these - including the APP component being a server component (as we now these days more commonly used in over the web).
My beef with the J2EE "+religion+" always has been that client-server is client-server. The fundamentals stay the same. -
Access SQL Function in Oracle?
Microsoft Access SQL has a function called LastOf which extracts
data from a column within the last row returned when multiple
rows are returned. This function works even when many tables are
joined and only one of them returns multiple rows. Does Oracle's
SQL implementation have anything like it?I can't find a reference to a LastOf function for MS-Access.
Perhaps you are refering to the Last(expr) function or MoveLast
method of DAO Recordset.
Last behavior can be reached in one of several ways depending on
the desired results, most depending on the ordering of the result
set. Both Access and VB use the concept of a recordset, which is
analogous to a CURSOR in Oracle.
To use an implicit cursor, and only retreive the one row, you
might use the sudo-colomn ROWNUM:
SELECT my_col FROM my_tab WHERE ROWNUM = 1
This would give you the first record of the result set, but there
is no guarantee on which row it would be - so you might consider
ordering the result set:
SELECT my_col FROM my_tab WHERE ROWNUM = 1 ORDER BY my_col ASC;
Which would return one row, the value of my_col being the
smallest value in the table. Now might be a good time to talk
aggrogate functions, such as:
SELECT MIN( my_col ) FROM my_tab;
which does the same thing as above.
If all else fails, RTFM.
-Kevin -
Recursive functions in Oracle SQL.
OK,
Here is the pivot problem. Only this time were on an Oracle 11.1.0.7.0.
I've created a table called:
CREATE TABLE STAGING.MY_TAB_COLS
TABLE_NAME VARCHAR2(30 BYTE),
COLUMN_NAME VARCHAR2(30 BYTE)
)And I've put the following data into it:
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAEADP1', 'SSN_SOURCE');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAEADP1', 'FIRST_NAME_SOURCE');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAEADP1', 'LAST_NAME_SOURCE');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAEADP1', 'DOB_SOURCE');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAEADP1', 'EMP_SSN_SOURCE');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAEADP1', 'EMP_FIRST_NAME_SOURCE');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAEADP1', 'EMP_LAST_NAME_SOURCE');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAEADP1', 'EMP_DOB_SOURCE');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAEADP1', 'MPI');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAEADP1', 'SSN_STANDARDIZED');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAEADP1', 'FIRST_NAME_A_STANDARDIZED');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAEADP1', 'FIRST_NAME_B_STANDARDIZED');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAEADP1', 'LAST_NAME_A_STANDARDIZED');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAEADP1', 'LAST_NAME_B_STANDARDIZED');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAEADP1', 'EMP_SSN_STANDARDIZED');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAEADP1', 'EMP_FIRST_NAME_A_STANDARDIZED');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAEADP1', 'EMP_FIRST_NAME_B_STANDARDIZED');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAEADP1', 'EMP_LAST_NAME_A_STANDARDIZED');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAEADP1', 'EMP_LAST_NAME_B_STANDARDIZED');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAMAET1', 'MPI_OLD');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAMAET1', 'EMPLOYEE_SSN_SOURCE');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAMAET1', 'EMPLOYEE_LAST_NAME_SOURCE');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAMAET1', 'EMPLOYEE_FIRST_NAME_SOURCE');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAMAET1', 'EMPLOYEE_DOB');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAMAET1', 'PATIENT_SSN');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAMAET1', 'PATIENT_LAST_NAME_SOURCE');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAMAET1', 'PATIENT_FIRST_NAME_SOURCE');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAMAET1', 'PATIENT_DOB');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAMAET1', 'EMPLOYEE_NON_SSN_ID');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAMAET1', 'EMPLOYEE_SSN_STANDARDIZED');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAMAET1', 'PATIENT_FIRST_NAME_A_STD');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAMAET1', 'PATIENT_FIRST_NAME_B_STD');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAMAET1', 'PATIENT_LAST_NAME_A_STD');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAMAET1', 'PATIENT_LAST_NAME_B_STD');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAMAET1', 'EMPLOYEE_FIRST_NAME_A_STD');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAMAET1', 'EMPLOYEE_FIRST_NAME_B_STD');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAMAET1', 'EMPLOYEE_LAST_NAME_A_STD');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAMAET1', 'EMPLOYEE_LAST_NAME_B_STD');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAMAET1', 'PATIENT_SSN_STANDARDIZED');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAMAET1', 'MPI');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAPMED1', 'EMPLOYEE_SSN');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAPMED1', 'EMPLOYEE_FIRST_NAME');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAPMED1', 'EMPLOYEE_LAST_NAME');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAPMED1', 'EMPLOYEE_DATE_OF_BIRTH');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAPMED1', 'PATIENT_SSN');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAPMED1', 'PATIENT_FIRST_NAME_SOURCE');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAPMED1', 'PATIENT_LAST_NAME_SOURCE');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAPMED1', 'PATIENT_DOB');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAPMED1', 'PRESCRIBER_LAST_NAME');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAPMED1', 'MPI');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAPMED1', 'PATIENT_FIRST_NAME_A_STD');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAPMED1', 'PATIENT_FIRST_NAME_B_STD');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAPMED1', 'PATIENT_LAST_NAME_A_STD');
Insert into STAGING.MY_TAB_COLS
(TABLE_NAME, COLUMN_NAME)
Values
('AAPMED1', 'PATIENT_LAST_NAME_B_STD');My task for this problem is pretty straight forward.
Using the ALL_TAB_COLS table I want to list out certain fields for each table name specified.
All the tables have fields that are similar. I just want these table names to go across the top.
And the field names to list out under each table.
So you would have something like:
AAEADP1 AAMAET1 AAPMED1
SSN_SOURCE MPI_OLD EMPLOYEE_SSN
FIRST_NAME_SOURCE EMPLOYEE_SSN_SOURCE EMPLOYEE_FIRST_NAME
LAST_NAME_SOURCE EMPLOYEE_LAST_NAME_SOURCE EMPLOYEE_LAST_NAME
DOB_SOURCE EMPLOYEE_FIRST_NAME_SOURCE EMPLOYEE_DATE_OF_BIRTH
EMP_SSN_SOURCE EMPLOYEE_DOB PATIENT_SSN
EMP_FIRST_NAME_SOURCE PATIENT_SSN PATIENT_FIRST_NAME_SOURCE
EMP_LAST_NAME_SOURCE PATIENT_LAST_NAME_SOURCE PATIENT_LAST_NAME_SOURCE
EMP_DOB_SOURCE PATIENT_FIRST_NAME_SOURCE PATIENT_DOB
MPI PATIENT_DOB PRESCRIBER_LAST_NAME
SSN_STANDARDIZED EMPLOYEE_NON_SSN_ID MPI
FIRST_NAME_A_STANDARDIZED EMPLOYEE_SSN_STANDARDIZED PATIENT_FIRST_NAME_A_STD
FIRST_NAME_B_STANDARDIZED PATIENT_FIRST_NAME_A_STD PATIENT_FIRST_NAME_B_STD
LAST_NAME_A_STANDARDIZED PATIENT_FIRST_NAME_B_STD PATIENT_LAST_NAME_A_STD
LAST_NAME_B_STANDARDIZED PATIENT_LAST_NAME_A_STD PATIENT_LAST_NAME_B_STD
EMP_SSN_STANDARDIZED PATIENT_LAST_NAME_B_STD
EMP_FIRST_NAME_A_STANDARDIZED EMPLOYEE_FIRST_NAME_A_STD
EMP_FIRST_NAME_B_STANDARDIZED EMPLOYEE_FIRST_NAME_B_STD
EMP_LAST_NAME_A_STANDARDIZED EMPLOYEE_LAST_NAME_A_STD
EMP_LAST_NAME_B_STANDARDIZED EMPLOYEE_LAST_NAME_B_STD
PATIENT_SSN_STANDARDIZED
MPI Where each table name lists across with all of their column names under each table.
The query that I have so far is The following:
SELECT T1.TABLE_NAME, T1.COLUMN_NAME
FROM my_tab_cols t1, ( SELECT DISTINCT UPPER (SOURCE_TABLE) TABLE_NAME
FROM MPI_DEMOGRAPHICS_TEST
ORDER BY UPPER (SOURCE_TABLE)) tn
WHERE T1.TABLE_NAME = tn.TABLE_NAME
AND ( T1.column_name LIKE '%MPI%'
OR T1.column_name LIKE '%SSN%'
OR T1.column_name LIKE '%E%SSN%'
OR T1.column_name LIKE '%R%SSN%'
OR T1.column_name LIKE '%P%SSN%'
OR T1.column_name LIKE '%BIRTH%'
OR T1.column_name LIKE '%DOB%'
OR T1.column_name LIKE '%FIRST%NAME%'
OR T1.column_name LIKE '%LAST%NAME%'
OR T1.column_name LIKE '%CLIENT%NAME%'
OR T1.column_name LIKE '%SOURCE_TABLE%'
OR T1.column_name LIKE '%TABLE%')
ORDER BY T1.TABLE_NAME, t1.column_id; It just list everything straight down.
Where the MPI_DEMOGRAPHIES_TEST table feeds the relevant table names to the ALL_TAB_COLS table.
It can just be substituted with a list of the values, AAEADP1, AAMAET1, AAPMED1.
Is there a 'pivot' function in Oracle 11.1 that I can use to list these column names out sideways as opposed to what I did before?
Thanks,Hi,
Here's one way to get results like that using the Oracle 11 SELECT ... PIVOT feature:
WITH got_nums AS
SELECT column_name
, ROW_NUMBER () OVER ( PARTITION BY table_name
ORDER BY column_name
) AS r_num
, DENSE_RANK () OVER ( ORDER BY table_name) AS c_num
FROM my_tab_cols
WHERE column_name LIKE '%MPI%'
OR column_name LIKE '%SSN%'
-- OR column_name LIKE '%E%SSN%' -- Included in '%SSN% above
-- OR column_name LIKE '%R%SSN%' -- Included in '%SSN% above
-- OR column_name LIKE '%P%SSN%' -- Included in '%SSN% above
OR column_name LIKE '%BIRTH%'
OR column_name LIKE '%DOB%'
OR column_name LIKE '%FIRST%NAME%'
OR column_name LIKE '%LAST%NAME%'
OR column_name LIKE '%CLIENT%NAME%'
-- OR column_name LIKE '%SOURCE_TABLE%' -- Included in %TABLE% below
OR column_name LIKE '%TABLE%'
UNION
SELECT table_name AS colum_name
, 0 AS r_num
, DENSE_RANK () OVER ( ORDER BY table_name) AS c_num
FROM my_tab_cols
SELECT *
FROM got_nums
PIVOT ( MIN (column_name)
FOR c_num IN ( 1 AS table_1
, 2 AS table_2
, 3 AS table_3
ORDER BY r_num
;Output:
R_NUM TABLE_1 TABLE_2 TABLE_3
0 AAEADP1 AAMAET1 AAPMED1
1 DOB_SOURCE EMPLOYEE_DOB EMPLOYEE_DATE_OF_BIRTH
2 EMP_DOB_SOURCE EMPLOYEE_FIRST_NAME_A_STD EMPLOYEE_FIRST_NAME
3 EMP_FIRST_NAME_A_STANDARDIZED EMPLOYEE_FIRST_NAME_B_STD EMPLOYEE_LAST_NAME
4 EMP_FIRST_NAME_B_STANDARDIZED EMPLOYEE_FIRST_NAME_SOURCE EMPLOYEE_SSN
5 EMP_FIRST_NAME_SOURCE EMPLOYEE_LAST_NAME_A_STD MPI
6 EMP_LAST_NAME_A_STANDARDIZED EMPLOYEE_LAST_NAME_B_STD PATIENT_DOB
7 EMP_LAST_NAME_B_STANDARDIZED EMPLOYEE_LAST_NAME_SOURCE PATIENT_FIRST_NAME_A_STD
8 EMP_LAST_NAME_SOURCE EMPLOYEE_NON_SSN_ID PATIENT_FIRST_NAME_B_STD
9 EMP_SSN_SOURCE EMPLOYEE_SSN_SOURCE PATIENT_FIRST_NAME_SOURCE
10 EMP_SSN_STANDARDIZED EMPLOYEE_SSN_STANDARDIZED PATIENT_LAST_NAME_A_STD
11 FIRST_NAME_A_STANDARDIZED MPI PATIENT_LAST_NAME_B_STD
12 FIRST_NAME_B_STANDARDIZED MPI_OLD PATIENT_LAST_NAME_SOURCE
13 LAST_NAME_A_STANDARDIZED PATIENT_DOB PATIENT_SSN
14 LAST_NAME_B_STANDARDIZED PATIENT_FIRST_NAME_A_STD PRESCRIBER_LAST_NAME
15 LAST_NAME_SOURCE PATIENT_FIRST_NAME_B_STD
16 MPI PATIENT_FIRST_NAME_SOURCE
17 SSN_SOURCE PATIENT_LAST_NAME_A_STD
18 SSN_STANDARDIZED PATIENT_LAST_NAME_B_STD
19 PATIENT_LAST_NAME_SOURCE
20 PATIENT_SSN
21 PATIENT_SSN_STANDARDIZEDIf you don't want to see the r_num column, use your front-end to hide it (e.g., in SQL*Plus: "COLUMN r_num NOPRINT"), or do the pivot in a sub-query, and only select table_1, table_2 and table_3 in the main query.
As with all pivots, you have to hard-code an upper bound to the number of pivoted columns. I used 3 above. You could use 4, or 5, or 45, but you must specify exactly how many columns to display.
If you say there will be 3 tables, and there actually are more than 3, then the query will still run, but all the tables after the first 3 will be ignored.
If you say there will be 3 tables, and there actually are fewer, then the query will still run, but you will have NULL columns at the end of each output row.
This sorts the output alphabetically by table_name and column_name. You can sort by anything you want by changing the analytic ORDER BY clauses. For example, if you are using all_tabl_columns and you want the columns to appear in order by column_id, then you would say:
, ROW_NUMBER () OVER ( PARTITION BY table_name
ORDER BY column_id -- instead of column_name
) AS r_num -
SQL Devloper Migration from SQL SerProcedurs created as Functions in Oracle
Hi All,
This is the first time I am using SQL Deveoper to migrate SQL Server database to Oracle.
I have SQL Developer 3 and I did migration from SQL Sever 2008 to Oracle 10g using online migration.
Everything was done perfectly, but there are some extra tables created in Oracle which are not present in SQL Server database.
And also I observed lot of programs which are stored procedures in SQL Server are converted as functions in Oracle.
Does someone knows how to fix this problem.
ThanksHi,
A SQL*Server stored procedure can be converted to an Oracle function depending on how it is written and what it is doing. In the documentation -
Oracle® SQL Developer
Supplementary Information for Microsoft SQL Server and
Sybase Adaptive Server Migrations
In Chapter 3 in the section -
3.4.2 Function
It says under Table 3-6 -
In Microsoft SQL Server or Sybase
Adaptive Server, you can convert a stored
procedure to a function in Oracle because
the stored procedure in Microsoft SQL
Server or Sybase Adaptive Server can
RETURN an integer value to the calling
routine using a RETURN statement. A
stored procedure returns a status value to
the calling routine even in the absence of
a RETURN statement. The returned status
is equal to ZERO if the procedure
execution is successful or NON-ZERO if
the procedure fails for some reason. The
RETURN statement can return only
integer values
And what tables do you see in oracle that are not there in SQL*Server ? Some tables are created as part of the migration as they are needed to have the same functionality as in SQL*Server.
Does your migrated Oracle database work in the same way as the SQL*Server database ? If not, then please give use specific examples and we can follow up.
Regards,
Mike -
Convert columns to row equivalent to stragg function in oracle sql
Hi,
Sorry i forgot my Oracle version :
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 64-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - ProductionI searched in google but i didn't found the solution.
I looking for a function in discoverer equivalent to stragg sql function.
Note : stragg function convert columns to rows.
Thanks
SELECT deptno, stragg ('-' || ename)
FROM emp_test
GROUP BY deptno;
DEPTNO STRAGG_STR
10 -CLARK-KING-MILLER
20 -SMITH-FORD-ADAMS-SCOTT-JONES
30 -ALLEN-BLAKE-MARTIN-TURNER-JAMES-WARD
3 rows selected.Edited by: Salim Chelabi on 2010-01-29 08:32Hi again,
*1- I created my function in my schema.*
CREATE OR REPLACE TYPE t_string_agg AS OBJECT
g_string VARCHAR2(32767),
STATIC FUNCTION ODCIAggregateInitialize(sctx IN OUT t_string_agg)
RETURN NUMBER,
MEMBER FUNCTION ODCIAggregateIterate(self IN OUT t_string_agg,
value IN VARCHAR2 )
RETURN NUMBER,
MEMBER FUNCTION ODCIAggregateTerminate(self IN t_string_agg,
returnValue OUT VARCHAR2,
flags IN NUMBER)
RETURN NUMBER,
MEMBER FUNCTION ODCIAggregateMerge(self IN OUT t_string_agg,
ctx2 IN t_string_agg)
RETURN NUMBER
SHOW ERRORS
CREATE OR REPLACE TYPE BODY t_string_agg IS
STATIC FUNCTION ODCIAggregateInitialize(sctx IN OUT t_string_agg)
RETURN NUMBER IS
BEGIN
sctx := t_string_agg(NULL);
RETURN ODCIConst.Success;
END;
MEMBER FUNCTION ODCIAggregateIterate(self IN OUT t_string_agg,
value IN VARCHAR2 )
RETURN NUMBER IS
BEGIN
SELF.g_string := self.g_string || ',' || value;
RETURN ODCIConst.Success;
END;
MEMBER FUNCTION ODCIAggregateTerminate(self IN t_string_agg,
returnValue OUT VARCHAR2,
flags IN NUMBER)
RETURN NUMBER IS
BEGIN
returnValue := RTRIM(LTRIM(SELF.g_string, ','), ',');
RETURN ODCIConst.Success;
END;
MEMBER FUNCTION ODCIAggregateMerge(self IN OUT t_string_agg,
ctx2 IN t_string_agg)
RETURN NUMBER IS
BEGIN
SELF.g_string := SELF.g_string || ',' || ctx2.g_string;
RETURN ODCIConst.Success;
END;
END;
SHOW ERRORS
CREATE OR REPLACE FUNCTION string_agg (p_input VARCHAR2)
RETURN VARCHAR2
PARALLEL_ENABLE AGGREGATE USING t_string_agg;
SHOW ERRORS
*2- I ran my query in my schema with sqlplus.*
SELECT deptno,ename,sal, string_agg(ename)over(partition by deptno) AS employees
FROM emp_test
order by deptno;
DEPTNO ENAME SAL EMPLOYEES
10 CLARK 2450 CLARK,KING,MILLER
10 KING 5000 CLARK,KING,MILLER
10 MILLER 1300 CLARK,KING,MILLER
20 JONES 2975 JONES,FORD,ADAMS,SMITH,SCOTT
20 FORD 3000 JONES,FORD,ADAMS,SMITH,SCOTT
20 ADAMS 1100 JONES,FORD,ADAMS,SMITH,SCOTT
20 SMITH 800 JONES,FORD,ADAMS,SMITH,SCOTT
20 SCOTT 3000 JONES,FORD,ADAMS,SMITH,SCOTT
30 WARD 1250 WARD,TURNER,ALLEN,JAMES,BLAKE,MARTIN
30 TURNER 1500 WARD,TURNER,ALLEN,JAMES,BLAKE,MARTIN
30 ALLEN 1600 WARD,TURNER,ALLEN,JAMES,BLAKE,MARTIN
30 JAMES 950 WARD,TURNER,ALLEN,JAMES,BLAKE,MARTIN
30 BLAKE 2850 WARD,TURNER,ALLEN,JAMES,BLAKE,MARTIN
30 MARTIN 1250 WARD,TURNER,ALLEN,JAMES,BLAKE,MARTIN
14 rows selected.
*3- I import this function in discoverer administration*
4- My problem :When i use the function string_agg(ename)over(partition by deptno) in discover deskto i got the error you can't use over in this place.
Any ideas.
Thank in advance.
Regards Salim. -
[OT] User-Defined string Functions Oracle PL/SQL
Ladies and Gentlemen,
I am pleased to offer the following string functions Oracle PL/SQL:
GETALLWORDS(): Inserts the words from a string into the table.
GETWORDCOUNT(): Counts the words in a string.
GETWORDNUM(): Returns a specified word from a string.
OCCURS(): Returns the number of times a character expression occurs within another character expression (including overlaps).
OCCURS2(): Returns the number of times a character expression occurs within another character expression (excluding overlaps).
PADC(): Returns a string from an expression, padded with spaces or characters to a specified length on the both sides.
STRTRAN(): Searches a character expression for occurrences of a second character expression, and then replaces each occurrence with a third character expression. Unlike a built-in function Replace, STRTRAN has three additional parameters.
STRFILTER(): Removes all characters from a string except those specified.
RAT(): Returns the numeric position of the last (rightmost) occurrence of a character string within another character string (including overlaps). The search performed by RAT() is case-sensitive. RAT similar to the PL/SQL function INSTR.
ATC(): Returns the beginning numeric position of the first occurrence of a character expression within another character expression, counting from the leftmost character (including overlaps). The search performed by ATC() is case-insensitive. ATC similar to the PL/SQL function INSTR.
RATC(): Returns the numeric position of the last (rightmost) occurrence of a character string within another character string (including overlaps). The search performed by RATC() is case-insensitive. RATC similar to the PL/SQL function INSTR.
AT2(): Returns the beginning numeric position of the first occurrence of a character expression within another character expression, counting from the leftmost character (excluding overlaps). The search performed by AT2() is case-sensitive. AT2 similar to the PL/SQL function INSTR.
REPLICATE(): Returns a character string that contains a specified character expression repeated a specified number of times.
ROMANTOARAB(): Returns the number equivalent of a specified character Roman numeral expression (from I to MMMCMXCIX).
Plus, there are versions for MS SQL SERVER, SYBASE ASA, DB2, MS SQL SERVER 2005 SQLCLR.
More than 8000 people have already downloaded my functions. I hope you will find them useful as well.
For more information about string UDFs Oracle PL/SQL please visit the
http://www.universalthread.com/wconnect/wc.dll?LevelExtreme~2,54,33,29233
Please, download the file
http://www.universalthread.com/wconnect/wc.dll?LevelExtreme~2,2,29233
With the best regards.>
I am using the Oracle Data Provider in vs2012. I am having trouble calling a function that returns an object type defined.
>
Returning a collection like that is a bad idea to begin with. That isn't scaleable and wastes memory.
Either return a REF CURSOR and let the client FETCH the rows or use a PIPELINED function and let the client query it like they would a table.
Here is an example similar to yours that uses a PIPELINED function.
create or replace
package pkg2
as
CURSOR emp_cur is (SELECT empno, ename, job, mgr, deptno FROM emp);
type pkg_emp_table_type is table of emp_cur%rowtype;
function get_emp(
p_deptno number
return pkg_emp_table_type
pipelined;
end;
create or replace
package body pkg2
as
function get_emp(
p_deptno number
return pkg_emp_table_type
pipelined
is
begin
for v_emp_rec in (SELECT empno, ename, job, mgr, deptno
FROM emp where deptno = p_deptno) loop
pipe row(v_emp_rec);
end loop;
end;
end;
select * from table(pkg2.get_emp(20));
EMPNO ENAME JOB MGR DEPTNO
7369 DALLAS CLERK2 7902 20
7566 DALLAS MANAGER 7839 20
7788 DALLAS ANALYST 7566 20
7876 DALLAS CLERK 7788 20
7902 DALLAS ANALYST 7566 20 -
Invoking SQL Server function from Oracle
Hi all,
My question involves Oracle and SQL Server. I have a function in SQL Server that returns the count of rows in a table in SQL Server itself. I
wish to invoke this function (in SQL Server) from Oracle. I have Transparent Gateway through which I usually connect to SQL Server to get the count. Is there a way in which I can execute the function (in SQL Server) from Oracle, something like below:
select function_in_sql_server@transparent_gateway from dual;Thanks,
...I found below two links:
how to call a sql server stored procedure from oracle
http://en.allexperts.com/q/Oracle-1451/2008/6/Calling-SQL-Stored-procedure-1.htm
Regards
Girish Sharma -
Oracle PL/SQL procedure/function to post message into weblogic jms queue
Hi All,
Is it possible to post messages to weblogic JMS queue from pl/sql procedure/function?
From this Queue, message will be read by OSB interface.
Any help will be highly appreciated.
Regards,
Steve904640 wrote:
Hi All,
Is it possible to post messages to weblogic JMS queue from pl/sql procedure/function?
From this Queue, message will be read by OSB interface.
Any help will be highly appreciated.
http://www.lmgtfy.com/?q=oracle+pl/sql+weblogic+jms+queue -
Calling SQL Server Function from Oracle Database link
Hi ,
i have some data from a old SQL server i would i can access with a database link but i cant call function from my database link.
i would like to do something like
@SPAN_PROD = Database link
_EnerttObtApReelBassSys is a Table function from my SQL server
SELECT *
FROM "_EnerttObtApReelBassSys('20120504',4,1)"@SPAN_PROD
WHERE DateEffectiveDebut <= GetDate()
AND DateEffectiveFin > GetDate()
any help ?
Thnx951879 wrote:
I have a SP in SQL Server which will return a Result Set.
My requirement is to call that procedure in ORACLE using DB Link and insert that resultset(Data) in the temp table.First you need to setup Oracle to SQL Server connectivity. To do that you can either use HS - heterogeneous connectivity which comes for free or use Oracle Transparent Gateway which is not free. HS uses ODBC, so if your Oracle database in not on windows, you'll have to get ODBC SQL Server driver for Unix/Linux (e.g. from EasySoft). Since SQL Server selecting from table function syntax is different from Oracle's you will have to, if you use HS, to use DBMS_HS_PASSTHROUGH package. I never worked with Oracle Transparent Gateway to SQL Server, so I don't know if and how it supports selecting from SQL Server table function.
SY. -
How I work with MS-SQL function in oracle
I’m working in oracle now but I don’t know how can I use following function in oracle.
convert, dateadd, datediff, fetch_status, isnumeric, reverse, str and stuffAlso available in 10g, the model clause version, taken from this How to display text in reverse order ?.
WITH t AS (SELECT 'abcdefg' col1
FROM DUAL
UNION
SELECT ''
FROM DUAL )
SELECT col1
, new_col1
FROM t
MODEL
PARTITION BY (ROWNUM rn)
DIMENSION BY (0 dim)
MEASURES (col1, CAST ('' AS VARCHAR2(255)) new_col1)
RULES ITERATE(99) UNTIL (LENGTH(new_col1[0]) = LENGTH(col1[0]))
(new_col1[0] = SUBSTR(col1[0], ITERATION_NUMBER + 1, 1) || new_col1[0])
COL1 NEW_COL1
abcdefg gfedcbaC. -
How to test a simple PL SQL function from another PL SQL script
Hi,
I have created a function. Now i need to test that whether it is returning the correct values or not.
For that, i have written anothe pl sql script and trying to call this function. Im passing all the IN parameters in that function. I assume here that OUT parameters will provide me the result. Im trying to display the OUT parameter one by one to see my result.
I'm using toad as sql client here connected with oracle.
pl sql script:-
DECLARE
BEGIN
DBMS_OUTPUT.PUT_LINE('$$$$$$$ VINOD KUMAR NAIR $$$$$$$');
FETCH_ORDER_PRODUCT_DATA(320171302, 1006, 6999,
ODNumber OUT VARCHAR2, Line_Number OUT VARCHAR2,
ServiceID OUT VARCHAR2, BilltoNumber OUT VARCHAR2,
AnnualPrice OUT NUMBER, CoverageCode OUT VARCHAR2)
DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | ODNumber );
DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | Line_Number );
DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | ServiceID );
DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | BilltoNumber );
DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | AnnualPrice );
DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | CoverageCode );
END;
Function:-
Program Name : SPOT_Order_Product_Data_For_CFS.sql
Description : Function to Validate parameters from CFS
By : Vinod Kumar
Date : 08/19/2011
Modification History
By When TAR Description
CREATE OR REPLACE FUNCTION FETCH_ORDER_PRODUCT_DATA(orderNumber IN VARCHAR2, customerNumber IN VARCHAR2,
productLine IN VARCHAR2, ODNumber OUT VARCHAR2,
Line_Number OUT VARCHAR2, ServiceID OUT VARCHAR2,
BilltoNumber OUT VARCHAR2, AnnualPrice OUT NUMBER,
CoverageCode OUT VARCHAR2)
RETURN VARCHAR2 IS
lv_err_msg VARCHAR2(100) := '';
lv_bucket_id VARCHAR2(14);
lv_bill_number VARCHAR2(30);
lv_anual_price NUMBER;
lv_coverage_code VARCHAR2(8);
lv_quote_num NUMBER(10) := NULL;
lv_line_num NUMBER(5) := 0;
lv_customer_number VARCHAR2(30) := customerNumber;
lv_product_id VARCHAR2(14) := productLine;
lv_count_quote NUMBER := 0;
lv_quote_status VARCHAR2(5);
lv_quote_version NUMBER(2):=0;
BEGIN
IF INSTR(orderNumber, '-') = 0 THEN
lv_quote_num := orderNumber;
ELSE
lv_quote_num := SPT_Delimiter(orderNumber, 1, '-');
lv_line_num := SPT_Delimiter(orderNumber, 2, '-');
END IF;
--Check status of the quote COM, APP
SELECT COUNT(*) INTO lv_count_quote FROM sot_order_header WHERE ORDER_NUMBER=lv_quote_num
AND ORDER_STATUS IN ('APP', 'COM') AND CUSTOMER_NUMBER = lv_customer_number;
IF lv_count_quote = 0 THEN
lv_err_msg := 'Invalid Order number';
RETURN lv_err_msg;
END IF;
-- Fetch the latest version on SPOT quote
SELECT MAX(VERSION_NUMBER) INTO lv_quote_version FROM SPT_QUOTE_HEADER WHERE QUOTE_NUMBER = lv_quote_num
AND CUSTOMER_NUMBER = lv_customer_number;
-- If quote is valid fetch the data in OUT parameters
IF lv_line_num = 0 THEN
BEGIN
SELECT a.CUSTOMER_BILLTO_NUMBER,
b.LINE_NUMBER, b.BUCKET_ID,
b.ANNUAL_REF_RATE_USD, b.COVERAGE_CODE
INTO lv_bill_number,lv_line_num,lv_bucket_id,lv_anual_price,lv_coverage_code
FROM SPT_QUOTE_HEADER a, SPT_QUOTE_LINE b
WHERE a.QUOTE_NUMBER = lv_quote_num
AND a.CUSTOMER_NUMBER = lv_customer_number
AND a.VERSION_NUMBER = lv_quote_version
AND a.QUOTE_NUMBER = b.QUOTE_NUMBER
AND a.VERSION_NUMBER = b.VERSION_NUMBER
AND b.PRODUCT_ID = lv_product_id;
ODNumber := lv_quote_num;
BilltoNumber := lv_bill_number;
Line_Number := lv_line_num;
ServiceID := lv_bucket_id;
AnnualPrice := lv_anual_price;
CoverageCode := lv_coverage_code;
RETURN '';
EXCEPTION WHEN OTHERS THEN
lv_err_msg := 'Multiple PIDs existing in the SPOT order, please provide the SPOT order + line number as input data';
RETURN lv_err_msg;
END;
ELSE
BEGIN
SELECT a.CUSTOMER_BILLTO_NUMBER,
b.BUCKET_ID, b.ANNUAL_REF_RATE_USD,
b.COVERAGE_CODE
INTO lv_bill_number,lv_bucket_id,lv_anual_price,lv_coverage_code
FROM SPT_QUOTE_HEADER a, SPT_QUOTE_LINE b
WHERE a.QUOTE_NUMBER = lv_quote_num
AND a.CUSTOMER_NUMBER = lv_customer_number
AND a.VERSION_NUMBER = lv_quote_version
AND a.QUOTE_NUMBER = b.QUOTE_NUMBER
AND a.VERSION_NUMBER = b.VERSION_NUMBER
AND b.PRODUCT_ID = lv_product_id
AND b.LINE_NUMBER = lv_line_num;
ODNumber := lv_quote_num;
BilltoNumber := lv_bill_number;
Line_Number := lv_line_num;
ServiceID := lv_bucket_id;
AnnualPrice := lv_anual_price;
CoverageCode := lv_coverage_code;
RETURN '';
EXCEPTION WHEN OTHERS THEN
lv_err_msg := 'Multiple SPOT lines exist with same parameter';
RETURN lv_err_msg;
END;
END IF;
EXCEPTION
WHEN OTHERS THEN
lv_err_msg := '@@@ EXCEPTION THROWN @@@ '|| SUBSTR(SQLERRM,1,120);
RETURN lv_err_msg ;
END;
Don't look at the function, it might have errors but my primary concern is how to test this function. Once I start doing its testing then only i can understand any bugs(if any).
My pl sql is not so good. Im still learning. I don't understand IN and OUT parameters are.
I just know that IN parameters r those whick we pass in to the function wen we call it and OUT parameters are those through which we get the result.
Thanks in advance
Vinod Kumar Nair20100511 wrote:
I wondered how I could test the output of the function from within TOAD?I usually create the following function in my developer schema:
create or replace function BoolToChar( b boolean ) return varchar2 is
begin
if b then
return( 'TRUE' );
else
return( 'FALSE' );
end if;
end;To test a function like yours, the following will do in SQL*Plus/TOAD/etc:
begin
DBMS_OUTPUT.put_line(
BoolToChar( XCCC_PO_APPROVALLIST_S1.does_cpa_exist(1017934) )
end;
I'm probably doing 101 things wrong here, but thought I'd ask anyway and risk being shouted at.Shout at? You reckon? I thought people risked being beaten with a lead pipe, or pelted with beer cans and stale pretzels - which makes being shouted at a really safe and viable alternative. {noformat};-){noformat} -
Equivalent of DB2 functions in ORACLE 11g
Hi,
I am trying to convert the SQL queries written in DB2 to ORACLE. There are some db2 specific functions are used in the queries.I am not able to find the equivalent function in ORACLE. The function names are written below:
1) DateDD()
2) SELECT @@IDENTITY
3) SELECT *
FROM (
SELECT ROWNUMBER() OVER() AS rowId_1, INNER_TABLE.*
FROM (----)as innertable
) AS Outertable
Error is: ROWNUMBER is INVALID identifier.
4) DAYOFWEEK()
5) DAYS()
6) dayofyear()
Please help me in finding the equivalent function in ORACLE.
Thanks in advance!!You probably don't need a DateAdd function in Oracle. You can add a number to a date in Oracle-- that adds the number of days to the date.
SELECT sysdate today, sysdate+1 tomorrow
FROM dualWhy are you using DAYS()? If, as in the example, you're just trying to determine the number of days between two dates, you can subtract dates in Oracle and the difference will be a number of days (including a fractional component if applicable)
SELECT date '2011-09-27' - date '2011-09-25' difference_in_days
FROM dualIf you really need the number of days since January 1, 0001, you could subtract the date from Jan 1, 0001, i.e.
SELECT date '2011-09-27' - date '0001-01-01'
FROM dualI would assume that Oracle and DB2 would return the same number but there could well be some differences since the current calendar didn't exist in the year 1 and I know there were issues in the transition from the Gregorian to the Julian calendar where some days were decreed not to exist. It wouldn't shock me if Oracle and DB2 counted some of the days in the 1500's differently.
Justin
Maybe you are looking for
-
Airport Extreme 802.11n with OS X v.10.3
Bought an Airport Extreme to boost the signal for 2 laptops on a wireless home network. However, I can't configure the airport because it's hooked up to an eMac that runs OS X v10.3 and according to documentation I need to have at least 10.4. Is ther
-
Why all time in iphone 5 coming no service
my iphone 5 make no service all the time i don't know why any way to solve this problem
-
Hi, since a few days I have big problems with the WLAN-connection of my late 2011 13" Macbook Pro that leads to very slow Intenet Connections and Slow SMB-Server access. In Detail: If I will open a Webpage it will take 50 times longer then from my iP
-
PreparedStatement.setCharacterStream() length
It seems perverse that PreparedStatement.setCharacterStream() requires the length of the character stream as a parameter. Is there a value you can feed it so it will simply read to EOF? public void setCharacterStream(int�parameterIndex, Reader�reader
-
Can anyone please help me? I'm trying to import my CD collection onto iTunes but many of my CDs fail to playback on iTunes after importing them. When I double click on a track I get the message that the song can't be used because the original file co