Dynamic SQL from within DML - merging syntax issue #2
Further to my previous thread on a SQL - DML merging syntax issue, I have another problem with multiple conditions in the WHERE-clause:
vrb _retval decimal
vrb _val1 text
vrb _val2 text
_val1 = 'value1'
_val2 = 'value2'
SQL SELECT DIM1_ATTR1 FROM MYSCHEMA.DIM1_DIM WHERE COL1 = :_val1, AND COL2 = :_val2, INTO :_retval
The above SQL will return NA. If I use the text literals instead of the OLAP variables, the query just runs fine. Also, with a single condition (on COL1 only) the query returns the expected value.
A note in the help states that OLAP DML objects should clearly be sperated from the rest of the SQL but does not say how. I am using a colon before and a comma after as without them the line would not compile. I could not find any example that would use multiple conditions in the WHERE-clause however the help text indicates that it is possible.
Please help me, how.
Regards,
Csaba
Windows, Oracle10gRel2 Ver. 10.2.0.1.0 eversion: 84090
It does work, although I applied the finishing touch by removing the commas as well!
Thanks a lot! Good job!
Could you please have a look at issue #1 too? :-)
Regards,
Csaba
Similar Messages
-
How to execute a packaged function from within DML
Hi
can someone explain in how many ways can we execute a packaged function from within a DML statement.
examples will help.
ThanksHi,
There's no difference between using functions in DML and using functions in any other SQL statement. Almost any place where a literal is allowed, you can have any kind of expression, including a an expression involving one or more functions.
For example, in
UPDATE table_x
SET column_a = 0
WHERE column_b > SYSDATE;You could use functions instead of 0, column_b, or SYSDATE. (Actually, SYSDATE is a function.) You can not use functions instead of table_x or column_a (since it is to the left of the "=" sign). -
How to run dynamic SQL from an ODI procedure step
I am on ODI 11.1.1.6.4. From within an ODI IKM step I have no problem running a procedure step like the following which calls a pl/sql procedure to get SQL text then later runs that code. Is there anyway to do the same from within an ODI procedure? I've tried a couple of variations and can not seem to get the parsing levels to resolve within a procedure like they resolve from within a KM step.
<@
/* Setup Java variables */
String out_SQL = "";
try
java.sql.Connection sourceConnection = odiRef.getJDBCConnection("SRC");
String sqltxt = "{call set_sql(?)}";
java.sql.CallableStatement pstmt = sourceConnection.prepareCall(sqltxt);
try
pstmt.registerOutParameter( 1, java.sql.Types.VARCHAR);
pstmt.execute();
out_SQL = pstmt.getString(1);
catch(java.sql.SQLException ex)
errMessage = ex.getMessage();
errMessage = errMessage.replace("'","");
finally
pstmt.close();
catch(java.lang.Exception e)
errMessage = e.getMessage();
errMessage = errMessage.replace("'","");
@>
BEGIN
-- The SQL that I want to run
<@
out.println(out_SQL);
@>
-- Error handling
<@ if ( out_SQL.length() ==0 ) { @>
raise_application_error(-20101, '<@=errMessage@>');
<@ } else { @>
dbms_output.put_line('Successful.');
<@ } @>
END;
------Please understand that I know that I can do this all within PL/SQL -- I am explicitly doing it the way I have outlined because I want to better understand the parsing levels/behavior within ODI procedures and I want to understand why KMs steps behave differently.
Another observation -- putting this all within a pl/sql block prevents ODI from properly capturing insert/update/delete row counts like it would if it were running a SQL statement.
So the question remains -- is there a way to run a dynamic SQL statement in an ODI procedure where the SQL statement is generated from within an Oracle procedure call and then run as SQL within an ODI procedure step? Best would be if there is an example of how this can be done. -
can somebody please help me as I am starting to feel quite stupid. I create a report using Sql and get the following error
Error: ORA-00911: invalid character (WWV-11230)
Failed to parse as INTRANET - select name, surname, component, phone_number, building from PERSON_DETAILS where upper(surname) like 'A%';, SURNAME ASC, NAME ASC, COMPONENT ASC, BUILDING ASC (WWV-08300)
I run the same query under sql plus and it works. What am I doing wrong.
Thanks in advance.
nullAndy,
From the error message that you have posted, it looks that you are adding a semicolon ";" at the end of your query in your report. Do not add any ";" at the end of the query that you are writing and it should work fine.
e.g.
It should be:
"select * from emp"
and not:
"select * from emp;"
If you are still unable to rectify your problem then pls post the actual query that you are using.
Thanx,
Chetan. -
Encore CS6 Dynamic Link from Pr CS6 Problem/Issue
I switched from Production Premium CS5 to CS6. I first deactivated and uninstalled my CS5 then installed CS6 on my Windows 7 machine.
The problem:
When I edit together a video in Premiere CS6 and have finished, I use Dynamic Link from within Encore CS6 to bring in that timeline. After that, I use AME to transcode that Dynamic Link asset to the DVD MPEG standard, Encore CS6 keeps poping up a notification window that says: "The transcoded DynamicLink asset _______ has changed on the server. Would you like to reimport it? Yes/No" It prompts me each time I enter Encore and any time I move from another open program back to Encore.
And I have to click No for each timeline that I have used Dynamic Link for (which is usually 5 or so).
Any ideas or help? This is incredibly annoying.
Thank you.
JaredAs an update. I am using the newest version of PluralEyes (v 2.0.5 7358) to sync the audio of the multiple camera event films I have shot. I have since created a new project in Premiere and only manually lined up clips and then Dynamically Linked that to a new Encore project and so far Encore has not promtpted me with the error/message: "The transcoded DynamicLink asset _______ has changed on the server. Would you like to reimport it? Yes/No"
Any ideas? This is very frustrating. Thank you! -
Stored Procedures and Dynamic SQL
In order to return query results from a PL/SQL procedure, I currently use an IN OUT parameter to return a cursor to JDBC.
(Q: Is there any other way ???)
But if I want to use dynamic SQL (DBMS_SQL) within the procedure, I don't know how to return the results. How do I get a handle on the DBMS_SQL underlying cursor, rather than just its cursor-ID?
Can anyone help ?
Thanks,
Rob
([email protected])Very happy customer here!
-
How to create a function with dynamic sql or any better way to achieve this?
Hello,
I have created below SQL query which works fine however when scalar function created ,it
throws an error "Only functions and extended stored procedures can be executed from within a
function.". In below code First cursor reads all client database names and second cursor
reads client locations.
DECLARE @clientLocation nvarchar(100),@locationClientPath nvarchar(Max);
DECLARE @ItemID int;
SET @locationClientPath = char(0);
SET @ItemID = 67480;
--building dynamic sql to replace database name at runtime
DECLARE @strSQL nvarchar(Max);
DECLARE @DatabaseName nvarchar(100);
DECLARE @localClientPath nvarchar(MAX) ;
Declare databaselist_cursor Cursor for select [DBName] from [DataBase].[dbo].
[tblOrganization]
OPEN databaselist_cursor
FETCH NEXT FROM databaselist_cursor INTO @DatabaseName
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT 'Processing DATABASE: ' + @DatabaseName;
SET @strSQL = 'DECLARE organizationlist_cursor CURSOR
FOR SELECT '+ @DatabaseName +'.[dbo].[usGetLocationPathByRID]
([LocationRID])
FROM '+ @DatabaseName +'.[dbo].[tblItemLocationDetailOrg] where
ItemId = '+ cast(@ItemID as nvarchar(20)) ;
EXEC sp_executesql @strSQL;
-- Open the cursor
OPEN organizationlist_cursor
SET @localClientPath = '';
-- go through each Location path and return the
FETCH NEXT FROM organizationlist_cursor into @clientLocation
WHILE @@FETCH_STATUS = 0
BEGIN
SELECT @localClientPath = @clientLocation;
SELECT @locationClientPath =
@locationClientPath + @clientLocation + ','
FETCH NEXT FROM organizationlist_cursor INTO
@clientLocation
END
PRINT 'current databse client location'+ @localClientPath;
-- Close the Cursor
CLOSE organizationlist_cursor;
DEALLOCATE organizationlist_cursor;
FETCH NEXT FROM databaselist_cursor INTO @DatabaseName
END
CLOSE databaselist_cursor;
DEALLOCATE databaselist_cursor;
-- Trim the last comma from the string
SELECT @locationClientPath = SUBSTRING(@locationClientPath,1,LEN(@locationClientPath)- 1);
PRINT @locationClientPath;
I would like to create above query in function so that return value would be used in
another query select statement and I am using SQL 2005.
I would like to know if there is a way to make this work as a function or any better way
to achieve this?
Thanks,This very simple: We cannot use dynamic SQL from used-defined functions written in T-SQL. This is because you are not permitted do anything in a UDF that could change the database state (as the UDF may be invoked as part of a query). Since you can
do anything from dynamic SQL, including updates, it is obvious why dynamic SQL is not permitted as per the microsoft..
In SQL 2005 and later, we could implement your function as a CLR function. Recall that all data access from the CLR is dynamic SQL. (here you are safe-guarded, so that if you perform an update operation from your function, you will get caught.) A word of warning
though: data access from scalar UDFs can often give performance problems and its not recommended too..
Raju Rasagounder Sr MSSQL DBA
Hi Raju,
Can you help me writing CLR for my above function? I am newbie to SQL CLR programming.
Thanks in advance!
Satya
-
Problem in executing Dynamic SQL in SYSTEM Schema
Hi,
I am trying to execute the below given dynamic sql from SYSTEM account.
'SELECT cnt, SUBSTR(SYS_CONNECT_BY_PATH(column_name,'',''),2) AS COLS FROM
( SELECT b.column_name,b.position,COUNT(1) over (ORDER BY a.constraint_name) AS cnt
FROM SYS.dba_Constraints a JOIN SYS.dba_Cons_Columns b ON (a.constraint_name = b.constraint_name)
WHERE a.table_name = '''||UPPER(v_table)||''' AND a.owner = '''||UPPER(v_owner)||''' AND a.constraint_type = ''P'' ORDER BY b.position
) WHERE position = cnt START WITH position = 1 CONNECT BY PRIOR position = position -1';
I am getting the error ORA-00942:table or view does not exist.
If I execute the created SQL from SQLPlus it is getting executed without any errors. If I try the same from SYS account it is working fine without any issues.
Could some one share some light on it.
Thanks in Advance
Sree.Hi Guys,
I got the solution, for referening objects in DYNAMIC sqls need explicit grant on those objects (not through roles). That is the reason this SQL is working in SYS schema, since SYS owns these tables, but system grot the access to these tables through roles.
Regards,
Sree. -
Dynamic SQL and Oracle stored procedures
Does anybody has any experience with invoking an Oracle stored procedures
with output parameters, using dynamic SQL from Forte?
Thanks,
DimitarI would be interested. We are currently using a homegrown DataMapper architecture with the Microsoft OracleClient. I would like to move to ODP.Net once a production version supporting ADO.Net 2.0 is available. After that, I would then like to look at using an off the shelf persistence framework such as EntitySpaces, NHibernate or IdeaBlade's DevForce.
-
Oracle to MS SQL porting - dynamic sql - cursors
I have a stored procedure written for oracle which needs to be ported to MS SQL. Used SSMA to do that but the dynamic sql statements are not getting ported and are the same. Below is a dynamic sql from the SP after making changes with SSMA.
SET @dsql_statement =
'declare '
+
' p table_name%rowtype;'
+
' c table_name%rowtype;'
+
' TYPE DAT IS REF CURSOR;'
+
' type dtt is table of table_name1%rowtype index by binary_integer;'
+
' d dtt;'
+
' aRC DAT;'
+
' sq varchar2(1000);'
+
' i NUMBER:=0;'
+
' attributeLabel nvarchar2(255);'
+
' attributename nvarchar2(255);'
+
' attributetype nvarchar2(255);'
+
' fkvalue nvarchar2(255);'
+
' defaultfield nvarchar2(80);'
+
' tablename nvarchar2(80);'
+
' primarykeyfield nvarchar2(80);'
+
' begin '
+
' sq:=''SELECT * FROM mdbadmin.table_name WHERE lower(COLUMN1) IN'
+
' (''''update'''',''''insert'''') AND COLUMN2 >= '
+
ISNULL(CAST(@COLUMN2 AS nvarchar(max)), '')
+
+
' ORDER BY COLUMN3,COLUMN2 ASC'';'
+
' open aRC for sq;'
+
' fetch aRC into c;'
+
' loop '
+
' fetch aRC into p;'
+
' exit when aRC%NOTFOUND;'Some thing like
dsql_statement := 'begin '
|| ' for I in (SELECT * FROM mdbadmin.table_name WHERE lower(COLUMN1) IN '
|| ' (''update'',''insert'') AND COLUMN2 >= '
|| 'NVL(to_char('||'@COLUMN2'||'), '''') '
|| ' ORDER BY COLUMN3,COLUMN2 ASC ) '
|| 'loop '
|| 'end loop; '
|| 'end; '
you can use for loop instead -
Does anyone know if it is possible to have dynamic SQL statements
within a trigger.
for example,
sql_str := 'insert into log_'||table_name||'values
(''A'',:new.descr)';
execute immediate sql_str;
I kept on getting an internal error as follows
ORA-00600: internal error code, arguments: [15212], [3], [], [],
ORA-06512: at "CDC.TG_BI_COMPANY_C", line 30
ORA-04088: error during execution of trigger 'CDC.TG_BI_COMPANY_C'
Thanks in advanceHi,
This is a bug i think ... a long shot but let us see what the
people at oracle have to say for this.... I Am posting it on
metalink....
Here is the corrected code...
create or replace trigger atrig
before insert on A
For Each Row
Declare
a number;
begin
execute immediate 'insert into ' || 'a_log values(:1)'
using :new.a;
end;
This works....
Always use bind Variables in Dynamic SQl ... Good Practice ....
Regards,
Ganesh R -
I just starting to Learn and use Dynamic SQL.
I am trying use a inner join query in dynamic SQL
for Example say 'Select A.id as Itemid , A.name as Itemname from TableA A inner join TableB B On A.ID = B.ID where B.ID typeid = 1 '
for some reason this is not working . i for sure know the query works as when i run the query it works fine. when i try to run it dynamically it give me blank values.
Please let me know if you need more information.
Appreicate Your help!!
Thanks,
ChaitanyaHere is an example for dynamic SQL from BOL:
DECLARE @IntVariable int;
DECLARE @SQLString nvarchar(500);
DECLARE @ParmDefinition nvarchar(500);
/* Build the SQL string one time.*/
SET @SQLString =
N'SELECT BusinessEntityID, NationalIDNumber, JobTitle, LoginID
FROM AdventureWorks2012.HumanResources.Employee
WHERE BusinessEntityID = @BusinessEntityID';
SET @ParmDefinition = N'@BusinessEntityID tinyint';
/* Execute the string with the first parameter value. */
SET @IntVariable = 197;
EXECUTE sp_executesql @SQLString, @ParmDefinition,
@BusinessEntityID = @IntVariable;
/* Execute the same string with the second parameter value. */
SET @IntVariable = 109;
EXECUTE sp_executesql @SQLString, @ParmDefinition,
@BusinessEntityID = @IntVariable;
Basically any query can be run as dynamic SQL. However, static SQL is the first choice. Use dynamic SQL if needed.
Dynamic SQL examples:
http://www.sqlusa.com/bestpractices/dynamicsql/
Kalman Toth Database & OLAP Architect
SQL Server 2014 Design & Programming
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012 -
An issue with Dynamic SQL within Package using REF CURSOR
Hi there,
In the following package first two procedures works file but since I have added the third one ( GET_CONTRACT_BY_DYN_SQL) it does not work for me. When I try to compile and save it gives below error.
"Error(6,15): PLS-00323: subprogram or cursor 'GET_CONTRACT_BY_DYN_SQL' is declared in a package specification and must be defined in the package body"
Can you please help?
Package Header
create or replace
PACKAGE CONTRACTS_PKG AS
TYPE T_CURSOR IS REF CURSOR;
PROCEDURE GET_CONRACTS (IO_CURSOR IN OUT T_CURSOR);
PROCEDURE GET_CONTRACT_BY_ID (I_CONTRACTID IN NUMBER, IO_CURSOR IN OUT T_CURSOR);
PROCEDURE GET_CONTRACT_BY_DYN_SQL(P_CONTRATID IN NUMBER, P_COLS IN VARCHAR2, IO_CURSOR IN OUT T_CURSOR);
END CONTRACTS_PKG;
Package Body
create or replace
PACKAGE BODY CONTRACTS_PKG AS
-- Get All Contracts
PROCEDURE GET_CONRACTS(IO_CURSOR IN OUT T_CURSOR)
IS
V_CURSOR T_CURSOR;
BEGIN
OPEN V_CURSOR FOR
SELECT * FROM CONTRACTS;
IO_CURSOR := V_CURSOR;
END GET_CONRACTS;
-- Get Contract By ID
PROCEDURE GET_CONTRACT_BY_ID(I_CONTRACTID IN NUMBER, IO_CURSOR IN OUT T_CURSOR)
IS
V_CURSOR T_CURSOR;
BEGIN
OPEN V_CURSOR FOR
SELECT * FROM CONTRACTS WHERE contract_id = I_CONTRACTID;
IO_CURSOR := V_CURSOR;
END GET_CONTRACT_BY_ID;
-- Get Contract Using Dynamic SQL
PROCEDURE GET_CONTRACT_BY_DYN_SQL(P_CONTRACTID IN NUMBER, P_COLS IN VARCHAR2, IO_CURSOR IN OUT T_CURSOR)
IS
V_CURSOR T_CURSOR;
V_SQL VARCHAR2(200);
BEGIN
V_SQL := 'SELECT '|| P_COLS || ' FROM CONTRACTS WHERE contract_id = ' || P_CONTRACTID ;
--OPEN V_CURSOR FOR
--EXECUTE IMMEDIATE V_SQL INTO V_CURSOR;
OPEN V_CURSOR FOR V_SQL;
EXECUTE IMMEDIATE V_SQL;
--IO_CURSOR := V_CURSOR;
END GET_CONTRACT_BY_DYN_SQL;
END CONTRACTS_PKG;
Thanks in advance.
HiteshThanks guys. Finally I have tweaked as per your suggestions and it's working for all 3 cases (stored procedures).
Oracle
======
Package Header
create or replace
PACKAGE CONTRACTS_PKG AS
TYPE T_CURSOR IS REF CURSOR;
PROCEDURE GET_CONRACTS (IO_CURSOR IN OUT T_CURSOR);
PROCEDURE GET_CONTRACT_BY_ID (I_CONTRACTID IN NUMBER, IO_CURSOR IN OUT T_CURSOR);
PROCEDURE GET_CONTRACT_BY_DYN_SQL(P_CONTRACTID IN NUMBER, P_COLS IN VARCHAR2, IO_CURSOR IN OUT T_CURSOR);
END CONTRACTS_PKG;
Package Body
create or replace
PACKAGE BODY CONTRACTS_PKG AS
-- Get All Contracts
PROCEDURE GET_CONRACTS(IO_CURSOR IN OUT T_CURSOR)
IS
V_CURSOR T_CURSOR;
BEGIN
OPEN V_CURSOR FOR
SELECT * FROM CONTRACTS;
IO_CURSOR := V_CURSOR;
END GET_CONRACTS;
-- Get Contract By ID
PROCEDURE GET_CONTRACT_BY_ID(I_CONTRACTID IN NUMBER, IO_CURSOR IN OUT T_CURSOR)
IS
V_CURSOR T_CURSOR;
BEGIN
OPEN V_CURSOR FOR
SELECT * FROM CONTRACTS WHERE contract_id = I_CONTRACTID;
IO_CURSOR := V_CURSOR;
END GET_CONTRACT_BY_ID;
-- Get Contract Using Dynamic SQL
PROCEDURE GET_CONTRACT_BY_DYN_SQL(P_CONTRACTID IN NUMBER, P_COLS IN VARCHAR2, IO_CURSOR IN OUT T_CURSOR)
IS
V_CURSOR T_CURSOR;
V_SQL VARCHAR2(200);
BEGIN
IF p_contractid > 0 THEN
V_SQL := 'SELECT '|| P_COLS || ' FROM CONTRACTS WHERE contract_id = ' || P_CONTRACTID ;
ELSE
V_SQL := 'SELECT '|| P_COLS || ' FROM CONTRACTS';
END IF;
OPEN V_CURSOR FOR V_SQL;
IO_CURSOR := V_CURSOR;
END GET_CONTRACT_BY_DYN_SQL;
END CONTRACTS_PKG;
ColdFusion (calling app code)
=====================
<cfstoredproc procedure="CONTRACTS_PKG.GET_CONTRACT_BY_ID" datasource="#REQUEST.dsn#">
<cfprocparam cfsqltype="CF_SQL_INTEGER" type="in" value="1" variable="I_CONTRACTID">
<cfprocresult name="qData" resultset="1">
</cfstoredproc>
<br>Single Contract:
<cfdump var="#qData#" label="Single Contract">
<cfstoredproc procedure="CONTRACTS_PKG.GET_CONRACTS" datasource="#REQUEST.dsn#">
<cfprocresult name="qDataAll" resultset="1">
</cfstoredproc>
<br>All Contracts:
<cfdump var="#qDataAll#" label="All Contracts">
<cfstoredproc procedure="CONTRACTS_PKG.GET_CONTRACT_BY_DYN_SQL" datasource="#REQUEST.dsn#">
<cfprocparam cfsqltype="CF_SQL_INTEGER" type="in" value="1" variable="P_CONTRACTID">
<cfprocparam cfsqltype="CF_SQL_VARCHAR" type="in" value="contract_number,contract_title,created_date" variable="P_COLS">
<cfprocresult name="qDataDynSQL" resultset="1">
</cfstoredproc>
<br>Dynamic SQL Query:
<cfdump var="#qDataDynSQL#" label="Dynamic SQL Query">
Thanks,
Hitesh Patel -
Dynamic SQL within a SQL Query ?
is there any possibility to do like this ?
SELECT table_name, XXXXXXXX('SELECT Count(*) FROM '||table_name) tot_rows
FROM dba_tables
WHERE owner = 'SCOTT';or any other trick to run dynamic SQL within the SQL Query?
Hoping....that it should be.
Regards,
OrapdevOne small disadvantage: it is executing 202 SQL statements: 3 "user SQL statements" (the one above and the 2 "select count(*)..."), and 199 internal ones ...How did you get to those numbers?
I just traced this statement and found completely different results:
TKPROF: Release 10.2.0.3.0 - Production on Tue Jul 10 12:12:10 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Trace file: diesl10r2_ora_5440.trc
Sort options: default
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed time in seconds executing
disk = number of physical reads of buffers from disk
query = number of buffers gotten for consistent read
current = number of buffers gotten in current mode (usually for update)
rows = number of rows processed by the fetch or execute call
declare cursor NlsParamsCursor is SELECT * FROM
nls_session_parameters;begin SELECT Nvl(Lengthb(Chr(65536)),
Nvl(Lengthb(Chr(256)), 1)) INTO :CharLength FROM dual; for NlsRecord in
NlsParamsCursor loop if NlsRecord.parameter = 'NLS_DATE_LANGUAGE' then
:NlsDateLanguage := NlsRecord.value; elsif NlsRecord.parameter =
'NLS_DATE_FORMAT' then :NlsDateFormat := NlsRecord.value; elsif
NlsRecord.parameter = 'NLS_NUMERIC_CHARACTERS' then
:NlsNumericCharacters := NlsRecord.value; elsif NlsRecord.parameter =
'NLS_TIMESTAMP_FORMAT' then :NlsTimeStampFormat := NlsRecord.value;
elsif NlsRecord.parameter = 'NLS_TIMESTAMP_TZ_FORMAT' then
:NlsTimeStampTZFormat := NlsRecord.value; end if; end loop;end;
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 1
Fetch 0 0.00 0.00 0 0 0 0
total 2 0.00 0.00 0 0 0 1
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 50
SELECT NVL(LENGTHB(CHR(65536)), NVL(LENGTHB(CHR(256)), 1))
FROM
DUAL
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.01 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 0 0 1
total 3 0.01 0.00 0 0 0 1
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 50 (recursive depth: 1)
Rows Row Source Operation
1 FAST DUAL (cr=0 pr=0 pw=0 time=7 us)
SELECT *
FROM
NLS_SESSION_PARAMETERS
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 0 0 17
total 3 0.00 0.00 0 0 0 17
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 50 (recursive depth: 1)
Rows Row Source Operation
17 FIXED TABLE FULL X$NLS_PARAMETERS (cr=0 pr=0 pw=0 time=124 us)
select PARAMETER,VALUE
from
nls_session_parameters where PARAMETER in('NLS_NUMERIC_CHARACTERS',
'NLS_DATE_FORMAT','NLS_CURRENCY')
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 0 0 3
total 3 0.00 0.00 0 0 0 3
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 50
Rows Row Source Operation
3 FIXED TABLE FULL X$NLS_PARAMETERS (cr=0 pr=0 pw=0 time=57 us)
select to_char(9,'9C')
from
dual
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 0 0 1
total 3 0.00 0.00 0 0 0 1
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 50
Rows Row Source Operation
1 FAST DUAL (cr=0 pr=0 pw=0 time=2 us)
SELECT table_name,
DBMS_XMLGEN.getxmltype ('select count(*) c from ' || table_name).EXTRACT
('//text').getstringval
() tot
FROM dba_tables
WHERE table_name IN ('EMP', 'DEPT') AND owner = 'SCOTT'
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.01 0.02 0 48 0 2
total 3 0.01 0.02 0 48 0 2
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 50
Rows Row Source Operation
2 HASH JOIN (cr=42 pr=0 pw=0 time=2952 us)
2 MERGE JOIN CARTESIAN (cr=42 pr=0 pw=0 time=1206 us)
2 NESTED LOOPS OUTER (cr=42 pr=0 pw=0 time=478 us)
2 NESTED LOOPS OUTER (cr=36 pr=0 pw=0 time=421 us)
2 NESTED LOOPS OUTER (cr=30 pr=0 pw=0 time=379 us)
2 NESTED LOOPS OUTER (cr=30 pr=0 pw=0 time=365 us)
2 NESTED LOOPS (cr=22 pr=0 pw=0 time=312 us)
2 NESTED LOOPS (cr=16 pr=0 pw=0 time=272 us)
2 NESTED LOOPS (cr=8 pr=0 pw=0 time=172 us)
1 TABLE ACCESS BY INDEX ROWID USER$ (cr=2 pr=0 pw=0 time=56 us)
1 INDEX UNIQUE SCAN I_USER1 (cr=1 pr=0 pw=0 time=30 us)(object id 44)
2 INLIST ITERATOR (cr=6 pr=0 pw=0 time=111 us)
2 TABLE ACCESS BY INDEX ROWID OBJ$ (cr=6 pr=0 pw=0 time=87 us)
2 INDEX RANGE SCAN I_OBJ2 (cr=4 pr=0 pw=0 time=54 us)(object id 37)
2 TABLE ACCESS CLUSTER TAB$ (cr=8 pr=0 pw=0 time=98 us)
2 INDEX UNIQUE SCAN I_OBJ# (cr=4 pr=0 pw=0 time=26 us)(object id 3)
2 TABLE ACCESS CLUSTER TS$ (cr=6 pr=0 pw=0 time=39 us)
2 INDEX UNIQUE SCAN I_TS# (cr=2 pr=0 pw=0 time=13 us)(object id 7)
2 TABLE ACCESS CLUSTER SEG$ (cr=8 pr=0 pw=0 time=37 us)
2 INDEX UNIQUE SCAN I_FILE#_BLOCK# (cr=4 pr=0 pw=0 time=21 us)(object id 9)
0 INDEX UNIQUE SCAN I_OBJ1 (cr=0 pr=0 pw=0 time=4 us)(object id 36)
2 TABLE ACCESS BY INDEX ROWID OBJ$ (cr=6 pr=0 pw=0 time=33 us)
2 INDEX UNIQUE SCAN I_OBJ1 (cr=4 pr=0 pw=0 time=23 us)(object id 36)
2 TABLE ACCESS CLUSTER USER$ (cr=6 pr=0 pw=0 time=28 us)
2 INDEX UNIQUE SCAN I_USER# (cr=2 pr=0 pw=0 time=12 us)(object id 11)
2 BUFFER SORT (cr=0 pr=0 pw=0 time=716 us)
1 FIXED TABLE FULL X$KSPPI (cr=0 pr=0 pw=0 time=661 us)
1436 FIXED TABLE FULL X$KSPPCV (cr=0 pr=0 pw=0 time=1449 us)
select count(*) c
from
EMP
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 1 0 1
total 4 0.00 0.00 0 1 0 1
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 50 (recursive depth: 1)
Rows Row Source Operation
1 SORT AGGREGATE (cr=1 pr=0 pw=0 time=96 us)
14 INDEX FULL SCAN EMP_IDX (cr=1 pr=0 pw=0 time=46 us)(object id 61191)
select metadata
from
kopm$ where name='DB_FDO'
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 2 0 1
total 3 0.00 0.00 0 2 0 1
Misses in library cache during parse: 0
Optimizer mode: CHOOSE
Parsing user id: SYS (recursive depth: 1)
Rows Row Source Operation
1 TABLE ACCESS BY INDEX ROWID KOPM$ (cr=2 pr=0 pw=0 time=42 us)
1 INDEX UNIQUE SCAN I_KOPM1 (cr=1 pr=0 pw=0 time=22 us)(object id 365)
select count(*) c
from
DEPT
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 1 0 1
total 4 0.00 0.00 0 1 0 1
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 50 (recursive depth: 1)
ALTER SESSION SET sql_trace=FALSE
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
total 2 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Parsing user id: 50
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 5 0.00 0.00 0 0 0 0
Execute 5 0.00 0.00 0 0 0 1
Fetch 3 0.01 0.02 0 48 0 6
total 13 0.01 0.03 0 48 0 7
Misses in library cache during parse: 0
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 5 0.00 0.00 0 0 0 0
Execute 5 0.01 0.00 0 0 0 0
Fetch 7 0.00 0.00 0 4 0 21
total 17 0.01 0.00 0 4 0 21
Misses in library cache during parse: 0
9 user SQL statements in session.
1 internal SQL statements in session.
10 SQL statements in session.
Trace file: diesl10r2_ora_5440.trc
Trace file compatibility: 10.01.00
Sort options: default
1 session in tracefile.
9 user SQL statements in trace file.
1 internal SQL statements in trace file.
10 SQL statements in trace file.
10 unique SQL statements in trace file.
132 lines in trace file.
0 elapsed seconds in trace file.I only see a ratio of 1:9 for user- to internal SQL statements?
michaels> select * from v$version
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production -
Hi all,
I'm under 10G r1
I want to execute a dynamic SQL with merge in it
when I try with insert ,update it works
but I just want to use merge if possible
this is the code
CREATE OR REPLACE
PROCEDURE I_COLUMN_CDS_FIXINGS
v_ticker VARCHAR2,
v_date DATE,
v_tenor VARCHAR2,
v_bid NUMBER,
v_ask NUMBER)
AS
l_column VARCHAR2(80);
v_column_bid VARCHAR2(80);
v_column_ask VARCHAR2(80);
v_source VARCHAR2(60) :='CMAN@BBG';
v_gen_order pls_integer;
BEGIN
SELECT 'CDS_SPREAD_'
||v_TENOR
||'_BID'
INTO v_column_bid
FROM dual;
SELECT 'CDS_SPREAD_'
||v_TENOR
||'_ASK'
INTO v_column_ask
FROM dual;
dbms_output.put_line(v_ticker||' '||v_column_ask||' '||v_column_bid||' '||v_bid|| ' '||v_ask||' '||v_date);
EXECUTE immediate 'MERGE into CDS_FIXINGS C
using ( select v_ticker,'
||v_column_bid
||','
||v_column_ask
||',trunc(v_date) info_date ,v_bid,v_ask from dual ) B
on (C.cds_ticker=b.v_ticker and c.info_date=b.info_date)
WHEN MATCHED THEN
update set '||v_column_bid||'=:1,'||v_column_ask||'=:2 using v_bid,v_ask
WHEN NOT MATCHED THEN
INSERT
CDS_TICKER ,
INFO_DATE ,
'||v_column_bid||' ,
'||v_column_ask||' ,
SOURCE
VALUES (:1, :2,:3,:4,:5) ' using v_ticker,
v_date ,
v_bid ,
v_ask ,
v_source
---EXCEPTION
---when others then raise;
end;
when I launch hte procedure
exec i_column_cds_fixings('TEST',trunc(sysdate-1),'8Y',4232.01,4234.02);
I get
ERROR at line 1:
ORA-00933: SQL command not properly ended
ORA-06512: at "OWNER_HISTO.I_COLUMN_CDS_FIXINGS", line 26
ORA-06512: at line 1
How can I deal with this
Thanks
babata
I getSorry
this is formatted one
REATE OR REPLACE PROCEDURE i_Column_cds_FixIngs
(v_Ticker VARCHAR2,
v_Date DATE,
v_Tenor VARCHAR2,
v_Bid NUMBER,
v_Ask NUMBER)
AS
l_Column VARCHAR2(80);
v_Column_Bid VARCHAR2(80);
v_Column_Ask VARCHAR2(80);
v_Source VARCHAR2(60) := 'CMAN@BBG';
v_gen_Order PLS_INTEGER;
BEGIN
SELECT 'CDS_SPREAD_'
||v_Tenor
||'_BID'
INTO v_Column_Bid
FROM Dual;
SELECT 'CDS_SPREAD_'
||v_Tenor
||'_ASK'
INTO v_Column_Ask
FROM Dual;
dbms_Output.Put_Line(v_Ticker
||' '
||v_Column_Ask
||' '
||v_Column_Bid
||' '
||v_Bid
||' '
||v_Ask
||' '
||v_Date);
EXECUTE IMMEDIATE 'MERGE into CDS_FIXINGS C
using ( select v_ticker,'
||v_Column_Bid
||','
||v_Column_Ask
||',trunc(v_date) info_date ,v_bid,v_ask from dual ) B
on (C.cds_ticker=b.v_ticker and c.info_date=b.info_date)
WHEN MATCHED THEN
update set '
||v_Column_Bid
||'=:1,'
||v_Column_Ask
||'=:2 USING v_bid,v_ask
WHEN NOT MATCHED THEN
INSERT
CDS_TICKER ,
INFO_DATE ,
||v_Column_Bid
||' ,
||v_Column_Ask
||' ,
SOURCE
VALUES
:1,
:2,
:3,
:4,
:5
USING v_Ticker,v_Date,v_Bid,v_Ask,v_Source;
---EXCEPTION
---when others then raise;
END;
/
Maybe you are looking for
-
I would Like to know where i can see the date AND time on a picture i take With My iPhone? AND if not on the phone automaticly,.. Why not?... If even the cheapest phones provide this BASIC info.
-
Manual Authorization of Credit card in Sales Order
Hi All. can some one let me know , how can I manually authorise a credit card in Sales order. Thank u. Regards madhu.
-
Web Service Connection on fresh SUM formula is zero
I am using Xcelsius SP1. I have a field in the spreadsheet that has the formula "=SUM(H12:H16)". I am using a Web Service Connection to refresh the data. Following a refresh from the web service connection the field with the SUM formula is 0. I h
-
English language in ESS which should be German
Hi, I have a little translation problem in our portal. We installed German language pack but there is still english text displayed in ESS but only in forms such as edit/change address, material status and so on. Can you give me a hint were I can chan
-
Can I send group e-mails from an IPad?
Can I send group e-mails from an IPad?