Advanced functions in sql
Hi.. i am saravanan working as a software engineer..i am interested in sql.i want to know about the advanced functions in sql ..like cube , over ,rank...etc...if any one explain with good example..it will be very much helpful to me...with thanks and rgds...sarao..
Hi,
For Oracle 10.2 you can check [Analytic Functions|http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions001.htm#i81407].
Regards,
Similar Messages
-
Hi,
Can any one suggest me site for the advanced functions of SQL Like measure, dimension by, rules(), dense_rank,dense_rank over partition by, etc..I think your best place to go would be the SQL Language Reference for your Oracle version at http://tahiti.oracle.com. Another guide that goes over other things like the MODEL clause, ROLLUP, CUBE is the Data Warehousing Guide.
Hope this helps! -
Call userdefined function on sql server 2000 from a rpt/crystalviewer CR11
Post Author: schste0
CA Forum: Data Connectivity and SQL
Hi, i have userdefined functions in an sql2k database and look for a way to use them in cr11 and in the reportviewer with RAS. Thx in advance.Use a SQL Expression if the Driver supports it. Or a Command Object.
-
Want to convert function in SQL Server 2000
Hi ,
i am writing this function in oracle.Could you please convert this function in SQL Server 2000 because i am new in this and dont know how to use decode function in sql.
Please following is the code for oracle.
CREATE OR REPLACE function fun ( localex varchar2,titlex varchar2)
return number
as x number;
begin
select sum ( decode (count (username),max(prereq_count),1,0) ) x into x from
SELECT
prereq_count,
username
FROM
table1
group by username ;
return x;
end fun;
Regards
VishalJust take a look example below might give you idea :
create or replace function f_makeAddress_tx (
i_address_tx VARCHAR2,
i_city_tx VARCHAR2,
i_state_tx VARCHAR2,
i_zip_tx VARCHAR2)
return VARCHAR2
is
e_badZip EXCEPTION; u279E8
pragma EXCEPTION_init(e_badZip,-20998); u279E9
v_out_tx VARCHAR2(256);
begin
p_validateZip (i_zip_tx); u279E12
v_out_tx:= i_address_tx||u2019, u2018|| u279E13
i_city_tx ||u2019, u2018||
i_state_tx ||u2019, u2018||
i_zip_tx;
return v_out_tx; u279E17
exception
when e_badZip then u279E19
return i_zip_tx || u2018: Invalid zip code.u2019;
end;
Regards,
Clint -
Report- Pl/sql function returning sql query parsing page items as text?
Hi Team,
I am facing a strange issue .
I have four page items namely
1)JOB_CODE
2)MIN_EXP
3) MAX_EXP
4) SOURCES1
I have a report of the type "Pl/sql function returning sql query"
declare
v_sql varchar2(4000);
begin
if (:JOB_CODE IS NOT NULL and :MIN_EXP IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
v_sql:= 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
elsif (:JOB_CODE IS NULL and :MIN_EXP IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
elsif (:MIN_EXP IS NULL and :JOB_CODE IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where v_experience_years <= :MAX_EXP and V_REQUIREMENT = :JOB_CODE and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
elsif (:MAX_EXP is null and :JOB_CODE IS NOT NULL and :MIN_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
end if;
insert into query_list values (v_sql);
insert into debug values (:JOB_CODE , :MIN_EXP , :MAX_EXP , :SOURCES1);
return v_sql;
end;
Please not that I am insertin the query into a table called Query_list and the page item values into the table called Debug thru the pl/sql function which returns teh query.
Now I select the data from the debug tables.
select unique(query) from query_list;
select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like '%:SOURCES1%'
select * from debug;
JOBCODE MINEX MAXEX SOURCE
21 1 10 donkeyHire
And if I run the query in sql I get some records returned
select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = 21 and v_experience_years >= 1 and v_experience_years <= and source like 'donkeyHire'
V_CANDIDATE_ID V_FNAME V_CURRENT_EMPLOYER V_EXPERIENCE_YEARS
2 Vengu Andale Tech 4
But the record does not show up in the report!
does this type of report parse page items as text?
Why is it so?
Waiting for an early reply.
Thanks,
venkatVenkat - You don't want to put ':SOURCES1' in quotes like that.
Scott -
Issue with running PL/SQL function returning Sql query
hi, I am trying to create a report region by using the option of PL/SQL function returning sql query.
I notice that it's very slow for the report region page to show up. In my PL/SQL function body, there are only 3 steps, first update all the 10 rows of varchar2 fields to null,then insert values to those fields, then select all from the table to show report results. It takes more than 5 minitues for the page to load up, how ever, if i run those steps in SQL*Plus, it only takes a couple of seconds to finish. Any suggestions?
Thanks,
ginaSergio, the codes are as followed,
Declare
q varchar2(32767); -- query
Begin
q := 'select "ID",'||
'"ENTRY NAME","TOTAL","#CM","%CM","#CA",'||
'"%CA", from Info_table';
update info_table
set "TOTAL" = '',
"#CM" = '',
"%CM" = '',
"#CA" ='',
"%CA"=''
where "ID"<=10;
// set all data in column Total to null,there is only 10 rows in the table
update info_Table set Total = vTotal,
"#CM" = vCM
(those variables hold user key-in Text filed value)
where ID = 1;
return q;
End; -
I don't know if I should be posting this in this Forum or the BI Publisher forum, so I am posting in BOTH forums..
I love APEX, let me say that first.. And appreciate the support offered here by the group, but am running int a confusing issue when BI Publisher tries to build a report from the above type APEX report..
Here is my dilemma:
I have a number of reports that are part of a Oracle package. They return an SQL Query back to a reports region on a page. I am having to deal with the column names returned are col01, col02..
The issue I have is, when building the Application Level query to download the XML sample from in building RTF layouts in Word, you can not use this code, you MUST use a standard SQL Select.
I have taken the sql from the function returning sql, and copied into the application query, supplying the required data values for bind variables being used in the query.
An XML file is produced, and I use this to build the RTF format file that I load back into APEX and try to use it for the PDF rendering of the report. I can view the output as a PDF in the Word add on, but when I try using it with the report, it is returning an empty PDF file.
Can anyone tell me what error log files on the bi publisher side I can look at to see what error is happening?
Thank you,
Tony Miller
UTMB/EHN
Title changed, maybe SOMEONE has an idea on this??
Message was edited by:
Tony MillerHi,
1/ first check you are passing the bind variables and
appropriate values in the call to your report - if
the query returns no data then you get an empty page
So if your query takes :P10_USERNAME variable then
pass it to the report in the URL
f?p=&APP_ID.:0:&SESSION.:PRINT_REPORT=YOUR_REP_QUERY_N
AME:::P10_USERNAME:MYUSER
2/ try to use the Default layout first to check your
report query really returns the data when called
3/ if you defined a header in your rtf template check
there is no & (ampersand) - if using & in the header
and preview the template from word it displays data
OK, but if you use this template in the report query
it fails to render the data (bug in Apex-> Bi
Publisher integration maybe?)
4/ If using the table in the rtf template check its
width does not overflow the page margins - there is a
problem with pdf export
5/ check
/oc4j/j2ee/home/application-deployments/xmlpserver/app
lication.log forthe information on BI Publisher runs
RadoIssue was in the APEX page having issues.. I recoded a new page and am able to generate BI Publisher based PDF files..
Thank you,
Tony Miller
UTMB/EHN -
On Submit process not firing -report (PL/SQL function returning SQL query)
Can anyone suggest possible causes / solutions for the following problem?
I have a report region that uses a PL/SQL function returning SQL query. The report allows the user to update multiple fields / rows and then click a button to submit the page which should run the On-Submit process to update the database. However the process does not run and I get a 'HTTP404 page cannot be found' error; and when I navigate back using the Back button I cannot then navigate to any other page in my application without getting the same error. The button was created by a wizard selecting the options to submit the page and redirect to a (same) page. The button does not actually have a redirect in its definition but the wizard created a branch to the same page which should work and the button has the text 'submit as SUBMIT' next to it so it appears to be set up correctly.
I have recreated this page several times in my application and I cannot get the On-Submit process to run. However I have created a cut down version of the same page in the sample application on apex.oracle.com at http://apex.oracle.com/pls/otn/f?p=4550:1:179951678764332 and this works perfectly so I am at a loss to understand why it does not work in my application. I cannot post any part of the application itself but if anybody would like to check out page 30 of the sample application (Customer Update Test tab) updating the surnames only, using credentials ja, demo, demo this is pretty much what I have got in my application.
Any ideas would be much appreciated?Thanks for the suggestions guys. I have now identified that the problem goes away when I remove the second table from my report query. The original report query retrieved data from two tables and the process was updating only one of the tables. I thought I had approached the task logically i.e. first get the report to display the records from the two tables, then get the process to update the first table and finally to modify the process further to update the second table.
Can anyone point me to an example of multiple row updates on multiple tables using a PL/SQL function returning an SQL query? -
Using User Defined Function is SQL
Hi
I did the following test to see how expensive it is to use user defined functions in SQL queries, and found that it is really expensive.
Calling SQRT in SQL costs less than calling a dummy function that just returns
the parameter value; this has to do with context switchings, but how can we have
a decent performance compared to Oracle provided functions?
Any comments are welcome, specially regarding the performance of UDF in sql
and for solutions.
create or replace function f(i in number) return number is
begin
return i;
end;
declare
l_start number;
l_elapsed number;
n number;
begin
select to_char(sysdate, 'sssssss')
into l_start
from dual;
for i in 1 .. 20 loop
select max(rownum)
into n
from t_tdz12_a0090;
end loop;
select to_char(sysdate, 'sssssss') - l_start
into l_elapsed
from dual;
dbms_output.put_line('first: '||l_elapsed);
select to_char(sysdate, 'sssssss')
into l_start
from dual;
for i in 1 .. 20 loop
select max(sqrt(rownum))
into n
from t_tdz12_a0090;
end loop;
select to_char(sysdate, 'sssssss') - l_start
into l_elapsed
from dual;
dbms_output.put_line('second: '||l_elapsed);
select to_char(sysdate, 'sssssss')
into l_start
from dual;
for i in 1 .. 20 loop
select max(f(rownum))
into n
from t_tdz12_a0090;
end loop;
select to_char(sysdate, 'sssssss') - l_start
into l_elapsed
from dual;
dbms_output.put_line('third: '||l_elapsed);
end;
Results:
first: 303
second: 1051
third: 1515
Kind regards
TaoufikI find that inline SQL is bad for performance but
good to simplify SQL. I keep thinking that it should
be possible somehow to use a function to improve
performance but have never seen that happen.inline SQL is only bad for performance if the database design (table structure, indexes etc.) is poor or the way the SQL is written is poor.
Context switching between SQL and PL/SQL for a User defined function is definitely a way to slow down performance.
Obviously built-in Oracle functions are going to be quicker than User-defined functions because they are written into the SQL and PL/SQL engines and are optimized for the internals of those engines.
There are a few things you can do to improve function
performance, shaving microseconds off execution time.
Consider using the NOCOPY hints for your parameters
to use pointers instead of copying values. NOCOPY
is a hint rather than a directive so it may or may
not work. Optimize any SQL in the called function.
Don't do anything in loops that does not have to be
done inside a loop.Well, yes, but it's even better to keep all processing in SQL where possible and only resort to PL/SQL when absolutely necessary.
The on-line documentation has suggested that using a
DETERMINISTIC function can improve performance but I
have not been able to demonstrate this and there are
notes in Metalink suggesting that this does not
happen. My experience is that DETERMINISTIC
functions always get executed. There's supposed to
be a feature in 11g that acually caches function
return values.Deterministic functions will work well if used in conjunction with a function based index. That can improve access times when querying data on the function results.
You can use DBMS_PROFILER to get run-time statistics
for each line of your function as it is executed to
help tune it.Or code it as SQL. ;) -
I use function in SQL statement. It is a dynamicaly build SQL, therefore I need overload functions. These funcs defined in package. The package has PRAGMA Restrict_References (.., WNDS). So all functions should be restricted to update database.
But Oracle returns an error:
Function NVL_ does not guarantee not to update database
This is my build SQL:
----- the execution string is: ---------------
Begin
INSERT INTO TEST_TBL_BS (MILL_ORDER, CLM1, CLM2, CLM3, NOTES, INIT_DATE )
VALUES (NV.NVL_(Arc_Utl.TEST_TBL_dltd.MILL_ORDER),
NV.NVL_(Arc_Utl.TEST_TBL_dltd.CLM1),
NV.NVL_(Arc_Utl.TEST_TBL_dltd.CLM2),
NV.NVL_(Arc_Utl.TEST_TBL_dltd.CLM3),
NV.NVL_(Arc_Utl.TEST_TBL_dltd.NOTES),
Arch.Init_Time );
End;
This is NV package:
PACKAGE NV IS
PRAGMA Restrict_References ( NV, WNDS );
NULL_date DATE := TO_DATE ('01/01/1001', 'mm/dd/yyyy');
NULL_numb NUMBER := 0;
NULL_str VARCHAR2 (10)
:= '?';
-- overloaded NULL_Val function returns NULL_<type> value (defined early)
-- depend on received variable type
FUNCTION NULL_Val ( val_in IN DATE )
RETURN DATE ;
FUNCTION NULL_Val ( val_in IN NUMBER )
RETURN NUMBER ;
FUNCTION NULL_Val ( val_in IN VARCHAR2 )
RETURN VARCHAR2 ;
-- PRAGMA Restrict_References ( NULL_Val, WNDS ); -- can be used in SQLs
-- these pretends to cover hole of the SYS.NVL that do not have posibility
-- to return default NULL value for every given type
FUNCTION NVL_ ( val_in IN DATE )
RETURN DATE ;
FUNCTION NVL_ ( val_in IN NUMBER )
RETURN NUMBER ;
FUNCTION NVL_ ( val_in IN VARCHAR2 )
RETURN VARCHAR2 ;
-- PRAGMA Restrict_References ( NVL_, WNDS ); -- can be used in SQLs
END NV;
CREATE OR REPLACE PACKAGE BODY NV AS
-- NULL_Val set of overloaded functions - returns appropriate NULL value
FUNCTION NULL_Val ( val_in IN DATE )
RETURN DATE IS
BEGIN RETURN NULL_date;
END NULL_Val; -- for date
FUNCTION NULL_Val ( val_in IN NUMBER )
RETURN NUMBER IS
BEGIN RETURN NULL_numb;
END NULL_Val; -- for NUMBER
FUNCTION NULL_Val ( val_in IN VARCHAR2 )
RETURN VARCHAR2 IS
BEGIN RETURN NULL_str;
END NULL_Val; -- for VARCHAR2
-- set NVL_ function to return default NULL value if received variable
-- is NULL or the received variable if it is not NULL
FUNCTION NVL_ ( val_in IN DATE )
RETURN DATE IS
BEGIN RETURN NVL( val_in, NULL_Val ( val_in )); END NVL_;
FUNCTION NVL_ ( val_in IN NUMBER )
RETURN NUMBER IS
BEGIN RETURN NVL( val_in, NULL_Val ( val_in )); END NVL_;
FUNCTION NVL_ ( val_in IN VARCHAR2 )
RETURN VARCHAR2 IS
BEGIN RETURN NVL( val_in, NULL_Val ( val_in )); END NVL_;
END NV;
Can anybody help : where is a problem and what I can do in my case?
I work in Oracle 7.3
Thank you,
AlexHi Alex,
I've found that on the RDBS docs:
If you specify DEFAULT instead of a function name, the pragma applies to all functions in the package spec or object type spec (including, in the latter case, the
system-defined constructor). You can still declare the pragma for individual functions. Such pragmas override the default pragma.
Try using that and let me know.
The docs says also that the declaration of the pragma for an overloaded function applies to the nearest one. You may also try to insert several declaration, one after every function declaration.
Bye Max -
SQL Query(PL/SQL Function Returning SQL Query)
I am trying to write a dynamic report using SQL Query(PL/SQL Function Returning SQL Query).
I can get the report to run but I need to concatinate some columns into one, seperated by a comma or a dash.
I have tried select *****||','||***** alias
also select *****||'-'||***** alias
but I always get an error.
Is there a way of doing this please
GusThis is my full query
declare
v_query varchar2(4000);
begin
if :P63_TRAN_INFO = 2 THEN
v_query := 'select
A.FILENR,
A.EXERCISENAME,
A.STARTDATE,
A.ENDDATE,
A.UNIT,
A.ACCADDRESSES, B.ADDRESS, B.ADDRESS_1, B.POST_CODE, B.TOWN,
A.EXERCISEAREAS,
A.TOTALVEHICLES,
A.TOTALTROOPS+A.RNTOTALTROOPS+A.RAFTOTALTROOPS TOTALTROOPS,
A.CAR, A.MINIBUS, A.HGV,
A.NAMERANK, A.ADDRESS, A.ADDRESSI, A.ADDRESSII, A.POSTCODE,
A.TRANSIT,
A.INFOONLY
from BFLOG_AT A, BFLOG_ACCADDRESS B
WHERE A.ACCADDRESSES = B.NAME
AND A.STARTDATE >= :P63_START_DATE
AND A.ENDDATE <= :P63_END_DATE
AND A.AUTHORISED = 1
AND A.INFOONLY = 1' ;
END IF;
RETURN v_query;
END;
This query runs ok, but if I try changing it to the code below with fields concatinated, then it fails
declare
v_query varchar2(4000);
begin
if :P63_TRAN_INFO = 2 THEN
v_query := 'select
A.FILENR,
A.EXERCISENAME,
A.STARTDATE,
A.ENDDATE,
A.UNIT,
A.ACCADDRESSES||','||B.ADDRESS||','||B.ADDRESS_1||','||B.POST_CODE||','||B.TOWN ADDRESS,
A.EXERCISEAREAS,
A.TOTALVEHICLES,
A.TOTALTROOPS+A.RNTOTALTROOPS+A.RAFTOTALTROOPS TOTALTROOPS,
A.CAR, A.MINIBUS, A.HGV,
A.NAMERANK, A.ADDRESS, A.ADDRESSI, A.ADDRESSII, A.POSTCODE,
A.TRANSIT,
A.INFOONLY
from BFLOG_AT A, BFLOG_ACCADDRESS B
WHERE A.ACCADDRESSES = B.NAME
AND A.STARTDATE >= :P63_START_DATE
AND A.ENDDATE <= :P63_END_DATE
--AND (A.EXERCISEAREAS LIKE "GAP, OA, OAL")
--OR (A.EXERCISEAREAS LIKE "Harz")
AND A.AUTHORISED = 1
AND A.INFOONLY = 1' ;
END IF;
RETURN v_query;
END;
Cheers
Gus -
How to create a dynamic multi-line function in SQL Server
I am attempting to create a Multi-Line Function in SQL Server that accepts a dynamic WHERE clause as a parameter. I need this so that the function can be as versatile as possible for the filter that needs to be applied. I am unfortunately getting an error
upon creation of the function. I don't know how to solve the problem. Can someone advise me?
SQL:
SET
ANSI_NULLSON
GO
SET
QUOTED_IDENTIFIERON
GO
-- =============================================
-- Author:
-- Create date: 2/3/2014
-- Description: This multiline function will accept a generic WHERE Clause and apply it to the query for return.
-- =============================================
CREATE
FUNCTIONTESTMULTILINEFUNCTION
@WHEREvarchar(1024)
,@CHANGEDDATEasdatetime
RETURNS
@TESTTABLE
TABLE
IDint
,REVint
AS
BEGIN
Declare@SQLSTRINGvarchar(4096)
SET@SQLSTRING=''
SET@SQLSTRING=@SQLSTRING+'SELECT
REVS.ID, REVS.Revision
FROM
Select distinct result.ID, Max(Rev) as ''''Revision''''
FROM
Select * from dbo.BugsAll
where
[Changed Date] < @CHANGEDDATE
) result
GROUP BY result.ID
) REVS
join dbo.BugsAll BA on (BA.ID=REVS.ID AND BA.REV=REVS.revision)'
IF
(@WHEREisnotnullOR@WHERE<>'')
BEGIN
SET@SQLSTRING=@SQLSTRING+'
WHERE '+@WHERE;
END
INSERT@TESTTABLE
EXEC
(@SQLSTRING)
RETURN
END
GO
ERROR:
Msg 443, Level 16, State 14, Procedure TESTMULTILINEFUNCTION, Line 44
Invalid use of a side-effecting operator 'INSERT EXEC' within a function.
Senior Test Lead -- Microsoft>> Unfortunately I really need to form a dynamic query in a table valued function on the SQL SERVER. I have another tabled valued function that needs something returned as a table in order to further join the data. I am not allowed to use Stored
Procedures in that function. <<
You do know that real SQL programmers hate the proprietary nightmare of tabled valued functions? This is how you procedural programmers avoid learning set-oriented declarative and functional programming.
Your mindset wants to write to a scratch tape or disk file (aka “tabled valued function result table”) just like you did BASIC, FORTRAN or COBOL. QL programmers do not have to materialize their data. We can use VIEW or a drive table as well as a base table.
>> Plus, there are occasions where I don't want to pass in a field [sic: columns are not fields] parameter or need to change a parameter list such that I don't wish the table function to filter by a particular field [sic] or other setting. <<
What you want is a magical “Automobiles, Squids and Lady Gaga” function. An SQL programmer might write a complex VIEW then do simpler SELECTs off it.
>> My application pushes the WHERE clause from EXCEL to SQL to do the hard work as EXCEL is not the application in which I want to process the SQL statement and pass it via ODBC. I cannot run macros in Excel on the web.<<
This is a crazy language system. Usually we fetch data in SQL and then pass it to a math package, report writer, etc. We never keep logic (aka WHERE clauses) outside the database.
>> I am bummed about the fact that this feature doesn't work. It will up my server management costs to maintain unique tabular based functions based on WHERE clause query <<
So stop writing those “tabular based functions”, change your mindset and start learning SQL and do it right.
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
Calling Function in SQL Server through DBLINK
Hello
I need to call a function that exists in other database (*SQL Server*) through DBLINK
Is It possible? If yes, please give me the syntax
ThanksHi,
You can call remote functions on SQL*Server if you create the database link using the Database Gateway for SQL*Server (DG4MSQL).
You need to install and configure DG4MSQL then you can call remote functions as follows -
SELECT function1@Remote_DB(7782) FROM dual;
You need to set the parameter -
HS_CALL_NAME
in the DG4MSQL init<sid>.ora file with the owner and name of the function, for example -
HS_CALL_NAME = "owner1.function1, owner2.function2 "
and if you want to return values using the function you need to set the parameter in the gateway init file -
HS_FDS_PROC_IS_FUNC=TRUE
For full details you need to refer to the documentation -
Oracle® Database Gateway for SQL Server User’s Guide, 11g Release 2 (11.2)
Oracle® Database Heterogeneous Connectivity User’s Guide 11g Release 2 (11.2)
which is available from -
http://www.oracle.com/pls/db112/homepage
and click on the 'Integration Information' option on the left.
The documentation has further details on how to call and use remote functions.
For information about installing and configuring the gateway and links to further information have a look at the following note -
Note.1083703.1 Master Note for Oracle Gateway Products
available in My Oracle Support
You cannot use the Database Gateway for ODBC (DG4ODBC) to create the database link as it does not supported stored procedures or remote functions.
Regards,
Mike
Edited by: mkirtley on Sep 2, 2011 11:09 AM -
CONVERT function in SQL Server to oracle
All,
How to convert CONVERT function in SQL Server to oracle, below mentioned format is in SQL Server:
variable1 = convert(numeric(20), SUBSTRING( parameter1,parameter2,parameter3)
parameter1 datatype nvarchar2(100)
parameter2 datatype bigint
parameter3 datatype bigint
I did bit R&D, but was not successful..but still getting on..
If any help that would be great...
Regards,
~ORAYou cannot specify the precision/scale or length of input paramters to a stored procedure in Oracle, or at least the pl/sql engine does not respect the sizing. Assuming that you want to do something with variable1 in the procedure, and not just return it, the Oracle equivalent would be something along the lines of:
SQL> CREATE FUNCTION f (p_param1 IN VARCHAR2,
2 p_param2 IN NUMBER,
3 p_param3 IN NUMBER) RETURN NUMBER IS
4 l_var1 NUMBER(20) := SUBSTR(p_param1, p_param2, p_param3);
5 BEGIN
6 RETURN l_var1 * 10;
7 END;
8 /
Function created.
SQL> SELECT f('ABC10DEF', 4, 2) FROM dual;
F('ABC10DEF',4,2)
100You may need to adjust the return type to match what you are actually returning.
You can also use this iin a direct assignment in pl/sql without doig a select, something like:
SQL> DECLARE
2 l_num NUMBER(20);
3 BEGIN
4 l_num := f('ABC10DEF', 4, 2);
5 DBMS_OUTPUT.Put_Line('The number is: '||l_num);
6 END;
7 /
The number is: 100John -
Problem in Calling a function in sql statement.
hi,
I am having a function ops_safex_utl.EDIT_ASSC_CNTR_LOG(id number);
when i am trying to use this inside a sql statement as shown below, it is giving error (exception part inside the function).
SQL> select ops_safex_utl.EDIT_ASSC_CNTR_LOG(688) from dual;
OPS_SAFEX_UTL.EDIT_ASSC_CNTR_LOG(688)
-1 (-- exception )
when i am trying to call this function using a PL/SQL Block then it is woking fine as shown below.
SQL> DECLARE
2
3 x NUMBER(2);
4
5 BEGIN
6
7 x := ops_safex_utl.EDIT_ASSC_CNTR_LOG(688);
8
9 dbms_output.put_line('x '||' '||x);
10
11 END;
12 /
hi
insert into ops_assc_cntr_log
insert into ops_ac_ex_gratia_log
insert into ops_ac_sls_dlvry_slab_dtls_log
insert into ops_ac_sls_dlvry_slab_dtls_log
insert into ops_ac_sls_dlvry_slab_dtls_log
insert into ops_ac_sls_dlvry_slab_dtls_log
insert into ops_ac_sls_dlvry_slab_dtls_log
insert into ops_ac_spl_acct_dtls_log
insert into ops_ac_spl_acct_slab_dtls_log
insert into ops_ac_spl_acct_slab_dtls_log
insert into ops_ac_spl_acct_slab_dtls_log
insert into ops_ac_spl_acct_dtls_log
insert into ops_ac_spl_acct_slab_dtls_log
insert into ops_ac_spl_acct_slab_dtls_log
insert into ops_ac_spl_acct_slab_dtls_log
update ops_assc_cntr
success
x 0
PL/SQL procedure successfully completed.
when i am trying to run the SQL statement it is returning a exception from the function.
SELECT ops_safex_utl.EDIT_ASSC_CNTR_LOG(688) from dual --it is returning -1 (i.e exception).
My sql client version is 9.2.0.1.0. and my data base version is 10.2.0.2.0.
Please advice.Could you post the exception handler within the function.
It sounds like you return -1 if you experience an error - it would be easier to determine the cause of the problem if you return the Oracle error details, E.g:
EXCEPTION
WHEN OTHERS THEN
RETURN dbms_utility.format_error_backtrace;This will then return a meaningful error, identifying exactly what is causing the error to be generated.
Maybe you are looking for
-
How to install Windows 8 on Macbook pro with retina display ?
Hi - How to install Windows 8 on Macbook pro with retina display ? I am pretty new to the apple world. Tried doing it through bootcamp but did not success. I am not interested to install it through Parallels or Fusion. Plz guide. Thanks !
-
Hi - I have had iCloud photos turned on for about 2 weeks. My old iPhoto library of around 22k pics uploaded no problem. My issues are with now viewing them on my iPhone and iPad, which are set to optimise storage. On the iPad I used to have a fold
-
PREPARE doesn't create sub directories
Hi, I am trying to upgrade BW 3.0 to 3.5. I copied latest R3up into the /usr/sap/put/bin directory and tried to run R3up . It created an empty log subdirectory, but no other subdirectories such as ua, tools etc were not created. Any ideas? Thanks, Sa
-
Hi, I have just converted 1,200 clips form MPEG to quicktime format to edit in FCP. When I bring the clips on to the time-line I am not able to add any transitions to either the sound of video tracks. I can only do so bey shortening the clip at eithe
-
SSD install in dv7t - 6100 CTO
I installed a Intel 330 Series SSD in the dv7t - 6100 notebook and the Intel toolbox reports the transfer rate as 3Gb/s instead of the 6Gb/s that I thought this notebook should be. I have replaced the original HDD with this SSD and in doing so loaded