Use of Keyword "IN" in PL/SQL
I have a SQL statement similar to the following:
SELECT *
FROM emailListTable
WHERE emailGroup IN ('Group1','Group2', ....)
In other words, I do not know in advance how many E-Mail Groups I will be fetching e-mail addresses for. How do I use a variable in PL/SQL to hold a variable # of groups. Is it an array? or something else.
TIA
This may get you on your way.
PROCEDURE Whatever( p_InVals IN varchar2 )
IS
v_SQLList varchar2(300) := 'SELECT * ' ||
'FROM emailListTable ' ||
'WHERE emailGroup IN (' || p_InVals || ')' ;
rAddr emailListTable%ROWTYPE;
BEGIN
-- p_InVals validation
OPEN csrEmailList FOR v_SQLList ;
LOOP
FETCH csrEmailList INTO rAddr ;
EXIT WHEN csrEmailList%NOTFOUND;
-- Do whatever here
END LOOP;
END;
Similar Messages
-
Oracle deadlock - how to use "synchronised" keyword in a transaction?
Hi,
I use WL6.1 SP4, Oracle 8.1.6, with some Java objects which execute a
lot
of SQL queries (mixed update, insert and select) using plain JDBC
calls,
and Weblogic connection pools. These objects are called by servlets.
I experienced recently deadlocks when two users call the object at the
same
time (See error below).
I execute the queries using "synchronized" keyword in the following
way:
synchronized (this)
conConnection.setAutoCommit(false);
executeTransaction(myStatement);
conConnection.commit();
executeTransaction is overriden in sub-classes and is the method which
executes
all the queries.
It calls methods in other objects. These methods are not declared as
synchronized.
1) Should they?
2) Should I use the keyword "synchronized" in another way?
3) This part of code is also called when I do only "select"
statements. I guess
it should only be synchronized when we do "update" and "insert" which
could lead
to a deadlock?
4) Do you have any idea why this deadlock occurs as I use the
"synchronized"
keyword, and one thread should wait until the other one has finished?
Thanks for any idea,
Stéphanie
----------------- error:
<ExecuteThread: '4' for queue: 'default'> <> <> <000000> <SQL request
sent to database: UPDATE PARTICIPANT par SET par.PARTICIPANTLASTRANK =
4 WHERE par.IDPARTICIPANT = 8983566>
<ExecuteThread: '11' for queue: 'default'> <> <> <000000> <SQL request
sent to database: UPDATE PARTICIPANT par SET par.PARTICIPANTLASTRANK =
6 WHERE par.IDPARTICIPANT = 8983570>
ORA-00060: deadlock detected while waiting for resource
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
at oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:796)
at weblogic.jdbc.pool.Statement.executeUpdate(Statement.java:872)
at weblogic.jdbc.rmi.internal.StatementImpl.executeUpdate(StatementImpl.java:89)
at weblogic.jdbc.rmi.SerialStatement.executeUpdate(SerialStatement.java:100)
at bfinance.framework.EDBBLBean.executeSQL(EDBBLBean.java:299)Hi Stepanie,
I'd try to group update statement together. Usually it helps.
Regards,
Slava Imeshev
"Stephanie" <[email protected]> wrote in message
news:[email protected]...
Thanks for your answer.
In the case you describe, is there a way to ensure that tx-2 waits for
tx-1
to be finished before beginning?
My transaction which causes the problem is the following (simplified):
UPDATE tableA SET islast=0 WHERE externalid=myid;
for (int i=0; i< aVector.size(); i++) {
INSERT INTO tableA (id, islast, ranking, externalid) (SELECT
SEQ_tableA.nextval, 1, 0, myid);
UPDATE tableA SET ranking = /*calculated ranking */
WHERE externalid=myid AND islast=1;
UPDATE tableB ....
commit;
tx-1 and tx-2 execute this transaction at the same time. tx-1 begins
The deadlock appears when tx-2 executes the second UPDATE tableA
query.
I don't see how I can avoid to execute these two update queries, so if
I can find another way to prevent deadlock, it would be great!
Stéphanie
Joseph Weinstein <[email protected]_this> wrote in message
news:<[email protected]_this>...
Stephanie wrote:
Hi,
I use WL6.1 SP4, Oracle 8.1.6, with some Java objects which execute a
lot
of SQL queries (mixed update, insert and select) using plain JDBC
calls,
and Weblogic connection pools. These objects are called by servlets.
I experienced recently deadlocks when two users call the object at the
same
time (See error below).Hi. The error you are getting isn't necessarily from a lack ofsynchronization
of your java objects. It has to do with the order in which you accessDBMS
data. You are getting ordinary DBMS deadlocks, which are caused when
two DBMS connections each have a lock the other wants, in order toproceed.
The DBMS will quickly discover this and will kill one transaction inorder to
let the other one proceed:
time 0: tx-1 and tx-2 have started.....
time 1: tx-1: update tableA set val = 1 where key = 'A'
time 2: tx-2: update tableB set val = 2 where key = 'B'
time 3: tx-1: update tableB set val = 1 where key = 'B' (waitsbecause tx-2 has the row
locked)
time 4: tx-2: update tableA set val = 2 where key = 'A' (waitsbecause tx-1 has the row
locked)
This is a deadlock. The solution is to organize your application code sothat every
transaction accesses the data in the same order, eg: update tableAfirst, then update tableB.
This will prevent deadlocks.
Joe Weinstein at BEA
I execute the queries using "synchronized" keyword in the following
way:
synchronized (this)
conConnection.setAutoCommit(false);
executeTransaction(myStatement);
conConnection.commit();
executeTransaction is overriden in sub-classes and is the method which
executes
all the queries.
It calls methods in other objects. These methods are not declared as
synchronized.
1) Should they?
2) Should I use the keyword "synchronized" in another way?
3) This part of code is also called when I do only "select"
statements. I guess
it should only be synchronized when we do "update" and "insert" which
could lead
to a deadlock?
4) Do you have any idea why this deadlock occurs as I use the
"synchronized"
keyword, and one thread should wait until the other one has finished?
Thanks for any idea,
Stéphanie
----------------- error:
<ExecuteThread: '4' for queue: 'default'> <> <> <000000> <SQL request
sent to database: UPDATE PARTICIPANT par SET par.PARTICIPANTLASTRANK =
4 WHERE par.IDPARTICIPANT = 8983566>
<ExecuteThread: '11' for queue: 'default'> <> <> <000000> <SQL request
sent to database: UPDATE PARTICIPANT par SET par.PARTICIPANTLASTRANK =
6 WHERE par.IDPARTICIPANT = 8983570>
ORA-00060: deadlock detected while waiting for resource
at
oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
atoracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
atoracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
atoracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047
atoracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
atoracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java
:2709)
atoracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:796)
atweblogic.jdbc.pool.Statement.executeUpdate(Statement.java:872)
atweblogic.jdbc.rmi.internal.StatementImpl.executeUpdate(StatementImpl.java:89
atweblogic.jdbc.rmi.SerialStatement.executeUpdate(SerialStatement.java:100)
at bfinance.framework.EDBBLBean.executeSQL(EDBBLBean.java:299) -
Use 'default' keyword in call string while calling stored proc?
I am calling following sql server stored procedure from java code using my jdbc driver for sql server: CREATE PROCEDURE test_findTbInfo (
@paramIn_Str varchar(10),
@paramOut_Int int OUT,
@paramIn_Int int = 20
AS
begin
set @paramOut_Int = @paramIn_Int * 100
end
If I make a call like this:
CallableStatement cs = conn.prepareCall(" { call test_findTbInfo(? , , ? ) }");
cs.setString(1, "test_tab");
cs.setInt(2, 4);
cs.execute();
It works without any error. But this is not a right behavior. !! The second parameter as you see is passed like an optional parameter. But in stored proc it is NOT an optional param and so if the value not passed it should fail...
Now if I change the code to
CallableStatement cs = conn.prepareCall(" { call test_findTbInfo(? , default, ? ) }");
it works correctly. Gives error that "Procedure 'test_findTbInfo' expects parameter '@paramOut_Int', which was not supplied." which is correct.
So is it a normal practice to use 'default' keyword while calling sql server stored procedures having optional parameters in jdbc ????
Anyone knows ??? As far as I know "call test_findTbInfo(? , , ? )" works fine except in some cases and also it forces users to put all optional parameters at the end of parameter list in stored proc.
Please let me know whether I should go with 'default' throuout for sql server stored proc while calling using my jdbc driver.
Amit{?= call <procedure-name>[<arg1>,<arg2>, ...]}The question mark in the above is the result parameter
that must be registered.
That is not the same as an OUT argument.Yes that is true. The result value and OUT parameters are different but they both MUST be registered as per jdbc API
"The type of all OUT parameters must be registered prior to executing the stored procedure; their values are retrieved after execution via the get methods provided here."
Anyway, my original question still stays as it was. If there are some optional IN parameters in stored procedure
e.g.
PROCEDURE test_findTbInfo (
@paramIn_Int int = 20,
@paramOut_Int int OUT
how do you call this?
CallableStatement cs = conn.prepareCall(" { call test_findTbInfo( , ? ) }");
cs.registerOutParameter(1, Types.INTEGER);
cs.execute();
or
CallableStatement cs = conn.prepareCall(" { call test_findTbInfo(default, ? ) }");
Also note that I am intending to use ONLY sql server driver for this.
The first as well second seem to work. Except that second way is seems reliable. I just wanted a second opinion on that...
Amit -
Display distinct rows from Oracle table without using "DISTINCT" keyword.
How to retrieve distinct rows from oracle table without using 'DISTINCT' keyword in SQL?
Thanks in advance.
MihirWelcome to the forum.
Besides GROUP BY you can use UNIQUE instead of DISTINCT as well, but that's probably not wanted here ;) , and the ROW_NUMBER() analytic:
SQL> create table t as
2 select 1 col1 from dual union all
3 select 1 from dual union all
4 select 2 from dual union all
5 select 3 from dual union all
6 select 4 from dual union all
7 select 4 from dual;
Table created
SQL> select col1 from t;
COL1
1
1
2
3
4
4
6 rows selected
SQL> select distinct col1 from t;
COL1
1
2
3
4
SQL> select unique col1 from t;
COL1
1
2
3
4
SQL> select col1 from t group by col1;
COL1
1
2
3
4
SQL> select col1
2 from ( select col1
3 , row_number() over (partition by col1 order by col1) rn
4 from t
5 )
6 where rn=1;
COL1
1
2
3
4 -
How do I filter photos using the keyword hierarchy?
Since Aperture 3.1 came out, I've been taking another look at it and considering switching back from Lightroom. One baby step was to set up a proper keyword hierarchy with Aperture. Trying to use that for sorting photos, I started feeling incredibly frustrated and felt like I must be missing something screamingly obvious.
Here's my issue. Using the keyword HUD, I can set up a nested, hierarchical keyword list. The HUD helpfully displays a running tally of all photos that keyword is applied to. "Great!" I thought, I've got 46 photos of John Smith, let's take a look at them. So I click on the number. Apparently, while Aperture is happy to show you the number of photos with the keyword, it's not willing to take you to those photos (i.e., create a library filter and show the results) via the Keyword HUD.
Bringing up the filter HUD seems unhelpful for the opposite reason. While you can search via the keywords there, it doesn't show the keyword hierarchy! Am I missing something? Say I've got keywords for two people, Adam and Zoe, filed under People/Friends/. Using the keyword box in the filter HUD will list one at the beginning and the other at the end of my entire list of keywords. Worse, the filter HUD only seems helpful for keywords if you know which ones you're looking for, which defeats the point of using a hierarchy. If, say, I know there's 3 or 4 people I'm looking for under a particular category, but I can't remember their name of the top of my head, how do I go about finding them using the filter HUD? All I have is the long, uncategorized master list of keywords.
Again, I feel I must be missing something obvious. Thanks for your help.
Cheers.I agree, clicking on a keyword in the HUD that has a number after it to get those photos seems like a no brainer. Even though I know it doesn't do that I still find myself clicking on it before I catch myself. Need to send feedback to Apple on this, clicking on a keyword should create a filter to and display those images.
In your example the images of Adam and Zoe should be tagged with the keywords that apply to them. That is they would have the keywords people, friends, male or female, Adam or Zoe, and whatever other keywords you use to describe these images. Then you check as many keywords in the filter that apply and you can remember.
While the keyword HUD shows the keywords in a hierarchy, keywords applied to an image are one dimensional, linear. Its just a string of words without structure. The hierarchy is just there to make it easier to conceptualize the structure. -
Retrieve alert values for use as parameter in corrective action sql script
I am trying to write a corrective action sql script to kill a session that is blocking other sessions. I have the "blocking session count" metric set and the alert is firing correctly.
Is there any way to retrieve the sid and serial number from the alert generated and use it in a corrective action sql script?
Here is the alert generated:
Target Name=myproddb.world
Target Type=Database Instance
Host=myprodserver
Metric=Blocking Session Count
Blocking Session ID=SID: 522 Serial#: 5228
Timestamp=Mar 4, 2008 5:57:12 PM EST
Severity=Warning
Message=Session 522 is blocking 1 other sessions
Notification Rule Name=Testing Corrective actions
Notification Rule Owner=sysman
Clearly the sid, and serial # is contained within the alert Message field
what I want to write for the sql script is :
alter system kill session '%sid%,%serial_no%' immediate;
and have GC pass in the sid and serial_no to the script.
The "Target Properties" listed on the right of the Edit Corrective Action screen lists minimal details pertaining to the alert and certainly not the session sid, serial no.
Generically, is there any way to retrieve the values from an alert and use them in a corrective action script or job?
I've looked into getting the values from the mgmt$alert_history table, but I'm hoping that GC can pass the values to the sql script.
thanks in advance for your help.Hi
You can implementing a procedure like this.
1. When a block session count alarms occurs, there is a column in the v$lock that you can examine.
#!/bin/ksh
#kill_block_session.sh
#first export your variables
export ORACLE_HOME=/oracle/product/10.2.0.3
export ORACLE_SID=SIDNAME
$ORACLE_HOME/bin/sqlplus "/ as sysdba" << EOF
execute immediate killed_blocks;
EOF
# end
The killed_blocks is a procedure:
create procedure
declare
v_sid varchar2(15);
v_serial varchar2(15);
-- now a sql query that retrieve the sid and serial
-- you can obtain these values from v$session and v$lock
select vs.sid,vs.serial into v_sid,v_serial
from v$session vs,v$lock vl
where vs.sid=vl.sid
and vl.block >0
-- After this, you execute a dbms_put line with these
-- values
But you understant that this response action is very dangerous, because its possible that you kill sessions that the blocking are transitient.
You must examine your enviroment and your application and establish the metric like UDM and not for only session blocking count.
You must to see:
- The type of block
- The ctime time in the v$lock for to understatn the amount of time to determine that the block is need killed.
- In my opinion you need a special UDM and deactivate the blocking sesion count
If you want help to create this UDM send me a mail to [email protected]
Regards
Robert -
Create a spatail table using a shape file (.shp) in SQL DB
Hi All,
I am trying to load shape file into a sql spatial table. A execution process task is used to run the ogr2ogr.exe program.
This is how the process tab looks like .
Executable : C:\gdal_ogr2ogr\bin\gdal\apps\ogr2ogr.exe
Argument : -f MSSQLSpatial MSSQL:server=SQL-ABC-DEV;database=MYSIMPLE_Dev;Trusted_Connection=True;\\mypath\files\shares\Data\www.mypage.htm\my_sample_file.shp
Success value : 1 (I am not sure why I need to change this value from 0 to 1.
For above settings, package runs fine. However the spatial table is not created always. It is created once in a while after switching Success value from 1 to 0 and 0 to 1 again. (After the spatial table is created, it is dropped using a execute sql statement).
If I run this command SDKShell.bat file, it always works.
I am running this in VS 2012.I saw in an article that we need to convert shp file to csv before we load it into sql server.I even tried to convert shp to csv using execute sql task and ogr2ogr.exe. Still the package runs successfully after changing Success
value from 0 to 1 but no csv file is created. If the success value is 0, it throws the following error.
[Execute Process Task] Error: In Executing "C:\gdal_ogr2ogr\bin\gdal\apps\ogr2ogr.exe" " -f CSV \\xxxxxxxxr.rdn\files\shares\xxx_Data\ImportData\www.xxxxxxx.hapepage.htm\xxxxxx\Watches\Warnings\myfile\CSV \\xxxxxxxxr.rdn\files\shares\xxx_Data\ImportData\www.xxxxxxx.hapepage.htm\xxxxxx\Watches\Warnings\myfiles\www.shp"
at "", The process exit code was "1" while the expected was "0".
Could long file name be a problem too?
Thanks for your help in advance..
shamenThank you Andreas
Yes I can run it manually without getting any error.I am also new to ogr2ogr.exe. This is used to load shape files into sql server.
Actually this execute process task was located inside a for each loop. As no parameter is passed from for each loop to execute process task, I placed the execute process task outside of for each loop. Now it is working.
Every time when the package is run, execute process task create a spatial table in the db.
Still I don't know why it is not working when I place it inside the for each loop container.
Thanks
shamen http://stalkingnightmare.wordpress.com/about/ -
Use of ROW_NUMBER() function in PL/SQL
I have a Table Emp with the following Structure
SQL> desc emp
Name Null? Type
EMPNO NUMBER(2)
ENAME VARCHAR2(50)
HIREDATE DATE
DEPTNO NUMBER(2)
If I write a following query on this table
SQL> SELECT deptno, hiredate, record_id
2 FROM (SELECT deptno, ename, hiredate, ROW_NUMBER()
3 OVER (ORDER BY hiredate) AS record_id
4 FROM emp)
5 WHERE record_id >= 2
6 AND record_id <=5;
The Result I get is
DEPTNO HIREDATE RECORD_ID
10 22-NOV-01 2
10 22-NOV-01 3
10 22-NOV-01 4
10 22-NOV-01 5
But if I put this query in a cursor in a PL/SQL block. The
pl/sql does not compiles and gives me the following address
SQL> DECLARE
2 CURSOR c_my IS
3 SELECT deptno, hiredate, record_id
4 FROM (SELECT deptno, ename, hiredate, ROW_NUMBER()
5 OVER (ORDER BY hiredate) AS record_id
6 FROM emp)
7 WHERE record_id >= 2
8 AND record_id <=5;
9 BEGIN
10 FOR c_rec IN c_my LOOP
11 dbms_output.put_line(c_rec.ename);
12 END LOOP;
13 END;
14 /
OVER (ORDER BY hiredate) AS record_id
ERROR at line 5:
ORA-06550: line 5, column 13:
PLS-00103: Encountered the symbol "(" when expecting one of the
following:
, from
Question: Can you please tell me how I can use the ROW_NUMBER()
function in PL/SQL. I need to use this for selecting the correct
range of records for Pagination on a website.
Thanks in advance
PrashantAs Andrew said, PL/SQL hasn't caught up with the newer bits of
SQL. I have heard that in 9i, they will be the same, but in 8i
there are still things that you can do in SQL that you cannot do
directly in PL/SQL, such as the new functions like ROW_NUMBER.
However, you can use NDS as a work around. The following does
the same as what you posted:
SET SERVEROUTPUT ON
DECLARE
TYPE c_my_type IS REF CURSOR;
c_my c_my_type;
TYPE c_rec_type IS RECORD
(deptno emp.deptno%TYPE,
ename emp.ename%TYPE,
hiredate emp.hiredate%TYPE,
record_id INTEGER);
c_rec c_rec_type;
v_sql VARCHAR2 (4000);
BEGIN
v_sql :=
'SELECT deptno, ename, hiredate, record_id
FROM (SELECT deptno, ename, hiredate,
ROW_NUMBER() OVER
(ORDER BY hiredate)
AS record_id
FROM emp)
WHERE record_id >= 2
AND record_id <= 5';
OPEN c_my FOR v_sql;
LOOP
FETCH c_my INTO c_rec;
EXIT WHEN c_my%NOTFOUND;
DBMS_OUTPUT.PUT_LINE (c_rec.ename);
END LOOP;
END;
However, you stated that you need it for selecting the correct
range of records for pagination on a website. For that, you
will want something more like this:
CREATE OR REPLACE PACKAGE package_name
AS
TYPE c_my_type IS REF cursor;
PROCEDURE procedure_name
(c_my IN OUT c_my_type,
p_record_id1 IN NUMBER DEFAULT 1,
p_record_id2 IN NUMBER DEFAULT 4);
END package_name;
CREATE OR REPLACE PACKAGE BODY package_name
AS
PROCEDURE procedure_name
(c_my IN OUT c_my_type,
p_record_id1 IN NUMBER DEFAULT 1,
p_record_id2 IN NUMBER DEFAULT 4)
IS
v_sql VARCHAR2 (4000);
BEGIN
v_sql :=
'SELECT deptno, ename, hiredate, record_id'
|| ' FROM (SELECT deptno, ename, hiredate,'
|| ' ROW_NUMBER() OVER'
|| ' (ORDER BY hiredate)'
|| ' AS record_id'
|| ' FROM emp)'
|| ' WHERE record_id >= :a'
|| ' AND record_id <= :b';
OPEN c_my FOR v_sql
USING p_record_id1, p_record_id2;
END procedure_name;
END package_name; -
How to use a Sybase table in Oracle SQL statement?
How to use a Sybase table in Oracle SQL statement?
Sybase version : 11.9.2.4
Oracle version : 10.2.05
Thanks.user12088323 wrote:
How to use a Sybase table in Oracle SQL statement?
Sybase version : 11.9.2.4
Oracle version : 10.2.05
Thanks.Any Oracle client connected to the Oracle database can access Sybase data through the <font style="background-color: #FFFFCC">Database Gateway for Sybase</font> (it requires an additional license) or the <font style="background-color: #FFFFCC">Database gateway for ODBC</font> (it's free).
The Oracle client and the Oracle database can reside on different machines. The gateway accepts connections only from the Oracle database.
A connection to the gateway is established through a database link when it is first used in an Oracle session. In this context, a connection refers to the connection between the Oracle database and the gateway. The connection remains established until the Oracle session ends. Another session or user can access the same database link and get a distinct connection to the gateway and Sybase database.
Database links are active for the duration of a gateway session. If you want to close a database link during a session, you can do so with the ALTER SESSION statement.
To access the Sybase server, you must create a <font style="background-color: #FFFFCC">database link</font>. A public database link is the most common of database links.
SQL> CREATE PUBLIC DATABASE LINK dblink CONNECT TO
2 "user" IDENTIFIED BY "password" USING 'tns_name_entry';
--dblink is the complete database link name.
--tns_name_entry specifies the Oracle Net connect descriptor specified in the tnsnames.ora file that identifies the gatewayAfter the database link is created you can verify the connection to the Sybase database, as follows:
SQL> SELECT * FROM DUAL@dblink;
Configuring Oracle Database Gateway for Sybase
<font style="background-color: #FFFFCC">{message:id=10649126}</font> -
Where we use the window class in the sql and how to use it
where we use the window class in the sql and how to use it
http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions004.htm#SQLRF06174
Regards
Etbin -
Equi Join and Outer join using outer keyword
Hi,
First lets take the create statment for scott schema.
create table scott.emp_details(empno number, bonus_date date);
Insert Into Scott.Emp_Details Values(7369, To_Date('01-jan-2013'));
Insert Into Scott.Emp_Details Values(7499, To_Date('05-jan-2013'));
Insert Into Scott.Emp_Details Values(7521, To_Date('10-jan-2013'));
Insert Into Scott.Emp_Details Values(7566, To_Date('01-feb-2013'));
Insert Into Scott.Emp_Details Values(7654, To_Date('05-feb-2013'));
commit;lets also consider the basic scott.emp and scott.dept tables
Now I would like to equi join emp table deptno col with dept table deptno col and left outer join emp table hiredate with emp_details bonus_date and empno col in emp_details can be joined(Equi Join) with empno col of emp table if needed .The outer join has to be placed using the keyword (left/right)outer join
The select statement can have all the detials of emp table .The requirement may look weird but we have some such requirement.
Please suggestHi,
sri wrote:
Hi,
First lets take the create statment for scott schema.
create table scott.emp_details(empno number, bonus_date date);
Insert Into Scott.Emp_Details Values(7369, To_Date('01-jan-2013'));
Insert Into Scott.Emp_Details Values(7499, To_Date('05-jan-2013'));
Insert Into Scott.Emp_Details Values(7521, To_Date('10-jan-2013'));
Insert Into Scott.Emp_Details Values(7566, To_Date('01-feb-2013'));
Insert Into Scott.Emp_Details Values(7654, To_Date('05-feb-2013'));
commit;
It's best not to create your own tables in Oracle-supplied schemas, such as SCOTT. Use your own schema for your own tables.
lets also consider the basic scott.emp and scott.dept tablesI see; you're using the standard scott,emp and scott.dept tables, plus the emp_details table you posted above.
Now I would like to equi join emp table deptno col with dept table deptno col and left outer join emp table hiredate with emp_details bonus_date and empno col in emp_details can be joined(Equi Join) with empno col of emp table if needed .The outer join has to be placed using the keyword (left/right)outer join
The select statement can have all the detials of emp table .The requirement may look weird but we have some such requirement.
Please suggestThanks for posting the sample data. Don't forget to post the exact output you want from that sample data.
Do you want something like this?
` EMPNO ENAME DEPTNO DNAME BONUS_DAT
7369 SMITH 20 RESEARCH 01-JAN-13
7499 ALLEN 30 SALES 05-JAN-13
7521 WARD 30 SALES 10-JAN-13
7566 JONES 20 RESEARCH 01-FEB-13
7654 MARTIN 30 SALES 05-FEB-13
7698 BLAKE 30 SALES
7782 CLARK 10 ACCOUNTING
7788 SCOTT 20 RESEARCH
7839 KING 10 ACCOUNTING
7844 TURNER 30 SALES
7876 ADAMS 20 RESEARCH
7900 JAMES 30 SALES
7902 FORD 20 RESEARCH
7934 MILLER 10 ACCOUNTING
40 OPERATIONSIf so, here's one way to do it:
SELECT e.empno, e.ename -- or whatever columns you want
, d.deptno, d.dname -- or whatever columns you want
, ed.bonus_date
FROM scott.dept d
LEFT OUTER JOIN scott.emp e ON e.deptno = d.deptno
LEFT OUTER JOIN emp_details ed ON ed.empno = e.empno
ORDER BY e.empno
; -
How to Use native keyword in java programming
Hi ,
I am using JDK 1.6.0_11 , and i was trying to create a java program using "native" keyword ,
i got the sample code for the same from the site : - http://www.javaworld.com/javaworld/javatips/jw-javatip23.html
But when i type this command " C:\javah -stubs Happy " following error occurs
" Error: JNI does not require stubs, please refer to the JNI documentation. "
then typed " c:\javah -jni Happy" without any error .
After that i wrote a HappyImpl.c as mentioned in the above tutorial
#include <StubPreamble.h> /* Standard native method stuff. */
#include "Happy.h" /* Generated earlier. */
#include <stdio.h> /* Standard C IO stuff. */
void Happy_printText (struct HHappy *this)
puts ("Happy New Year!!!");
then it is not compling and error is
"unable to open included file StubPreamble.h file
unable to open included file Happy.h file "
Please help me . i want to use native method , i did exactly the same in tutorial at above link.
Thanks & Regards
Mannatyou do need to know how to use your C compiler... It quite clearly can't find those files which indicates that you didn't tell it where to find them.
-
Want to use presentation date variable in Advance SQL filter option
Hi,
I want to use presentation date variable in Advance SQL filter option.....I am getting the below error.
SQL in Advance SQL filter ----
"Fact Status Details"."Load Date" =
(select min(Cast("D Time"."Business Date" as char))-1
from "D Time" where "D Time"."Operational Month Sk" =
(select "D Time"."Operational Month Sk" from "D Time" where date '@{Date1}'=cast("D Time"."Business Date" As char)))
Error ---
Error getting drill information: SELECT "Fact Status Details"."Load Date" saw_0 FROM "Pre RFAI Sales" WHERE "Fact Status Details"."Load Date" = (select min(Cast("D Time"."Business Date" as char))-1 from "D Time" where "D Time"."Operational Month Sk" = (select "D Time"."Operational Month Sk" from "D Time" where date '@{Date1}'=cast("D Time"."Business Date" As char)))
Error Details
Error Codes: YQCO4T56:OPR4ONWY:U9IM8TAC:OI2DL65P
Odbc driver returned an error (SQLExecDirectW).
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 27002] Near <select>: Syntax error [nQSError: 26012] . (HY000)
SQL Issued: {call NQSGetLevelDrillability('SELECT "Fact Status Details"."Load Date" saw_0 FROM "Pre RFAI Sales" WHERE "Fact Status Details"."Load Date" = (select min(Cast("D Time"."Business Date" as char))-1 from "D Time" where "D Time"."Operational Month Sk" = (select "D Time"."Operational Month Sk" from "D Time" where date ''@{Date1}''=cast("D Time"."Business Date" As char)))')}
Load Date format ---YYYYMMDD
Please advise...i need to fix this issue urgently.Thanks for your reply.
Could you please help me with the correct code...i tried to correct it....
"Fact Status Details"."Load Date" =
(select Cast(min("D Time"."Business Date" )-1 as char)
from "D Time" where "D Time"."Operational Month Sk" =
(select "D Time"."Operational Month Sk" from "D Time" where Date'@{Date1}'=cast("D Time"."Business Date" As char)))
Please let me know if i am wrong..this code is also not working. -
Can We use FDM as ETL tool between SQL and Oracle
I want to use FDM as ETL tool between SQL and Oracle. Can it be possible. I didn,t found any target adapter for oracle database.My source system is SQL and Target system is Oracle database.
Rahul
Edited by: user12190125 on Nov 9, 2009 4:23 AMRahul,
I believe this is possible to do, but not an easy one and there are a few considerations:
How much data are you processing? FDM has a lot of features which support the business process. While this is great for users and audit trail etc. it slows down performance if you want to process a lot of data. It also depends on the type of mappings you use (Like mappings are slower than explicit mappings).
How familiar are you with VBScript? There is no explicit target adapter for Oracle, but there is a data mart adapter which can be used for anything. You have to implement everything yourself though, mainly the Export and Load actions. In there you will also have to handle the the connections to the MSSQL and Oracle databases.
Check the data mart adapter and see if you feel comfortable with defining the vb code in there. There are reasons for and against this approach. ODI would probably be the better choice unless you really need to have FDM's process support.
Regards,
Matt -
Problems when using RUNLOGIC Keyword in Script Logic
Hello experts,
I have a problem using RUNLOGIC keyword within Script logic. Both scripts are mentioned below.
Following scenario:
- combination of DESTINATION_APP and LOOKUP to multiply values from two source applications in order to to write results in target application
- data volume in source application VALCHAIN are approx 187.000 records; source app SALES = 500 records
- created data records in target application QUANTITIES are approx 204.000 records
Running LOGIC01_QUANTITIES.LGF without "RUNLOGIC" keyword:
- time to execute logic and write records: 10-12 minutes
- created records 204.000
Running LOGIC01_QUANTITIES.LGF via CALL_RUNLOGIC.LGF
- script does not finish; system produces dumps
- Tcode ST22 shows error messages called "TSV_TNEW_PAGE_ALLOC_FAILED" as well as "SYSTEM_NO_ROLL" as well as "CALL_FUNCTION_SEND_ERROR"
Does anybody have a guess for that? Any answer appreciated.
Thanks a lot!
==================================================
CALL_RUNLOGIC.LGF
*START_BADI RUNLOGIC
QUERY=OFF
WRITE=ON
LOGIC=LOGIC01_QUANTITIES.LGF
APPSET=FINPLAN_PERFORM
APP=VALCHAIN
CHANGED=PRODUCT
DEBUG=OFF
*END_BADI
===========================================
LOGIC01_QUANTITIES.LGF
*XDIM_MEMBERSET DATASRC=ITEMIZED
*XDIM_MEMBERSET VERSION=%VERSION_SET%
*XDIM_MEMBERSET TIME=%TIME_SET%
*LOOKUP SALES
*DIM DATASRC="OUTPUT"
*DIM ITEM="IM_M02"
*DIM QUANTU="QU_TO"
*DIM MEASURES="PERIODIC"
*FOR %LOOP_CENTER%=PC_1000,PC_2000,PC_3000,PC_4000,PC_5000,PC_6000
*DIM C_%LOOP_CENTER%:PCENTER=%LOOP_CENTER%
*NEXT
*ENDLOOKUP
*DESTINATION_APP=QUANTITIES
*ADD_DIM COSELE=CE_NONE
*WHEN PRODUCT.LG
*IS "1"
*WHEN MATERIAL
*IS "MA_NONE"
*FOR %LOOP_CENTER%=PC_1000,PC_2000,PC_3000,PC_4000,PC_5000,PC_6000
REC(EXPRESSION=%VALUE%LOOKUP(C_%LOOP_CENTER%), PCENTER=%LOOP_CENTER%, ITEM="IM_M08", DATASRC="CALCULATED")
*NEXT
*ELSE
*FOR %LOOP_CENTER%=PC_1000,PC_2000,PC_3000,PC_4000,PC_5000,PC_6000
REC(EXPRESSION=%VALUE%LOOKUP(C_%LOOP_CENTER%), PCENTER=%LOOP_CENTER%, ITEM="IM_M05", DATASRC="CALCULATED")
*NEXT
*ENDWHEN
*IS "1000"
*WHEN MATERIAL
*IS "MA_NONE"
*FOR %LOOP_CENTER%=PC_1000,PC_2000,PC_3000,PC_4000,PC_5000,PC_6000
REC(EXPRESSION=%VALUE%LOOKUP(C_%LOOP_CENTER%)/1000, PCENTER=%LOOP_CENTER%, ITEM="IM_M08", DATASRC="CALCULATED")
*NEXT
*ELSE
*FOR %LOOP_CENTER%=PC_1000,PC_2000,PC_3000,PC_4000,PC_5000,PC_6000
REC(EXPRESSION=%VALUE%LOOKUP(C_%LOOP_CENTER%)/1000, PCENTER=%LOOP_CENTER%, ITEM="IM_M05", DATASRC="CALCULATED")
*NEXT
*ENDWHEN
*ENDWHEN
*COMMITHello,
This error comes up when there is no enough memory.
How many members do you have in PRODUCT and how many parallel processes did you set up in PARALLELSCRIPT?
Also, I'd suggest to put *XDIM_MEMBERSET PRODUCT = %PRODUCT_SET% in your LOGIC01_QUANTITIES.LGF script.
Did you get anything in RUNLOGIC log? In UJFS you can find logs for every parallel process ran, name if it is just it's time stamp.
Can you see from those what scripts ran and with what parameters?
This should simplify resolution of your issue.
Regards,
Gersh
Maybe you are looking for
-
"Could Not Find Key" error when trying to download iTunes 7
Everytime I try to install iTunes 7, it gets about half way done and then says that it cannot find some sort of key (HKEYLOCALMACHINE\Software\Classes\QuickTime.QuickTime\CLSID is the full text FYI). I have no clue what this means since I'm a far cry
-
Why I can't open my MacBook Pro?
how I can open my MacBook Pro?
-
Hi I have Acrobat 8 and it keeps closing on its own after a few seconds. Any recommendations?
-
A failure was reported when trying to invoke a service application: EndpointFailure
Event logs getting spammed with this - can't find anything specific on the internet: A failure was reported when trying to invoke a service application: EndpointFailure Process Name: OWSTIMER Process ID: 6316 AppDomain Name: DefaultDomain AppDomain I
-
I need Alt s to save my QuickBooks document, not bring up history in Firefox?
In QuickBooks , using 'alt s' saves my entry (saves time also).....switched from Internet Explorer to Firefox and 'alt s' is the shortcut for 'history' ..... is there a way to disable 'alt s' in Firefox and still be 'available' for use in QB?