How to use Arrays in Oracle
Can any one help me to use an Array in oracle.Also i want to search whether an element is already existing in the array
One possible approach
SQL> create or replace type array as table of number;
2 /
Type created.
SQL> select case when count(*) = 1 then 'found' else 'not found' end
2 from dual
3 where exists (
4 select null from table(array(1,2,3,4,5))
5 where column_value = 3);
CASEWHENC
found
SQL> edi
Wrote file afiedt.sql
1 select case when count(*) = 1 then 'found' else 'not found' end
2 from dual
3 where exists (
4 select null from table(array(1,2,3,4,5))
5* where column_value = 1)
SQL> /
CASEWHENC
found
SQL> edi
Wrote file afiedt.sql
1 select case when count(*) = 1 then 'found' else 'not found' end
2 from dual
3 where exists (
4 select null from table(array(1,2,3,4,5))
5* where column_value = 6)
SQL> /
CASEWHENC
not found
Similar Messages
-
How to use css in oracle forms
Hello, I am using oracle forms 11g with weblogic server 10.3.5 at windows 7.I have to use CSS in oracle forms.i have tried to search it but no profit.please some one else tell me that how can use css in oracle forms. Thnak You regards aaditya
Hi
As Francois pointed out Oracle forms has nothing to do with html based technology. The way you can get the equivalent effect of creating consistancy in the way your objects are displayed is by creating a set of items you want and alter their apperance and behaviour and place them into object libraries (one library should do the trick). From there you subclass all of you forms items off these libraries.
Regards
Quintin -
How to use iframes in oracle 10g
I have to load two jsp pages in a single html . I have done that thru iframes. But i have to dynamically load the second jsp page in the frame 2 , when the user clicks upon certain details in the frame 1 jsp page. I have wriiten the code of document.iframe in format trigger attribute. It doesn't work. Is there any other way to achieve this. I want to load the frame 2 jsp page dynamically , according to the input i get from frame 1 jsp page.
Hi,
>>Anybody know how to use profiler in oracle 10g
What do you mean "profiler". About Resource Limits/Create Profiles ?
>>i couldn't able to install the enterprise manager console.
What OS ?
>>because i need to trace the execution of a stored procedure.waiting the reply.
Debug ? You can use SQL Developer, TOAD, PLSQL Developer for this purpose.
Cheers -
How to Use Profiler in ORACLE 10g
Hi all,
Anybody know how to use profiler in oracle 10g and also i couldn't able to install the enterprise manager console.is there any tools available for that.because i need to trace the execution of a stored procedure.waiting the reply.
SathishHi,
>>Anybody know how to use profiler in oracle 10g
What do you mean "profiler". About Resource Limits/Create Profiles ?
>>i couldn't able to install the enterprise manager console.
What OS ?
>>because i need to trace the execution of a stored procedure.waiting the reply.
Debug ? You can use SQL Developer, TOAD, PLSQL Developer for this purpose.
Cheers -
How to use array as parameter in procedure
Hello,
I am using Oracle SQL Developer 1.5.5
I wanted to write a procedure which does insert into table.
It should take 2 parameters.How to take array as parameter?
One is a array of strings ('abc','def','erg') and another is a varchar ('abc').
How to do this?
Can somebody pls give a small example?
Thanks
Edited by: user13305573 on Aug 5, 2010 11:27 PMHello,
I am sorry if u didnt get my point.
My req is i am using Orcale SQL Developer.
Db is Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
I want to write a procedure which will be called from a java file.
The parameter to that procedure will be a arr(array of strings) and username(varchar).
I want to insert that data into a tableA.
like if parameters are
(abc01,edfg02,efg03) as arr and honey as username
then it should insert 3 rows to the tableA
abc01 honey
edfg02 honey
efg03 honey
Thanks
Edited by: user13305573 on Aug 5, 2010 11:54 PM -
How to pass ARRAY to Oracle Procedure
Hi
We are using BC4J with JSP in our project. We need to send an Array to the procedure.
Could somebody provide some info as how this can be achieved.A while back, I used a SQLJ client to call a Java (also SQLJ) stored procedure and I needed to pass an array of strings to the procedure. I did something like this:
Java Class that was loaded in DB:
public class MyClass
// method that the stored procedure uses
public static void CALL_DOSTUFF(String a,
oracle.sql.ARRAY b,
oracle.sql.ARRAY c)
String[] bb = (String[])b.getArray();
String[] cc = (String[])c.getArray();
doStuff(a,bb,cc);
public static void doStuff(String a,
String[] b,
String[] c)
// process the input
In the database I added the type:
create or replace type STR_ARRAY as table of varchar2(20);
and the procedure:
create or replace procedure CALL_DOSTUFF(a varchar2,
b STR_ARRAY,
c STR_ARRAY)
as
language java
name 'MyClass.CALL_DOSTUFF(java.lang.String,
oracle.sql.ARRAY,
oracle.sql.ARRAY)';
I then used jpub to publish a STR_ARRAY.java file. I compiled this and used it with my SQLJ client to call to the stored procedure. The STR_ARRAY constructor takes a String[], so you do something like this in the SQLJ client:
String x = "X";
String y = {"y1","y2"};
String z = {"z1","z2"};
STR_ARRAY y1 = new STR_ARRAY(y);
STR_ARRAY z1 = new STR_ARRAY(z);
#sql {CALL CALL_DOSTUFF(:x,:y1,:z1)};
Hope this helps. -
How to use array or type in "IN" criteria
Hi all,
anybody knows how to use group of same datatype data ( array or type ) in SQL statement
For example
ls_dept[1] = 'abc';
ls_dept[2] = 'xyz';
ls_dept[10] = 'ppr';
i want to use this group of data in "IN" criteria like
Select * from department where dept in ('abc','xyz'.....''ppr');
if anybody know how to use please reply me as soon as possible.
Thanks,I hope you are not suggesting concatenating literals from a web front-end application ;) Is it not what he was saying.. he is getting user input info from an application.. if the user sends multiple values.. he has to build a string with concatenating literals..
correct me if I am wrong. -
How to use parameters in oracle SQL script????
Right now I am writing a SQL script to create a schema and build the objects of this schema....
I use a .net winform program to run sqlplus to parse this sql script ...
The problem is that the schema name and the tablespace's location and the sys password must be input by the user, so my SQL script should use these runtime input parameters instead of const parameters....
So, how to use parameter in SQL script ...........
Are there some example scripts in oracle home directory for me to refer to????Hi,
UNISTD wrote:
thanks .....
what's the difference between variable , define, accept in sqlplus ???VARIABLE declares (but does not assign a value to) a bind variable. Unlike substitution variables, bind variables are passed to the back end to be compiled, and they can only be values in certain data types. You can not use a bind vaiable in place of an identifier, so to do something like
CREATE USER &1 ...a bind variable won't work.
"DEFINE x = y" sets the substitution variable &x to have the value y. There is no user interaction (unless x or y happen to contain undefined substtiution variables).
"DEFINE x" shiows the value of the substitution variable &x, or, if it is undefined, raises a SQL*Plus error. I use this feature below.
ACCEPT sets a substitution variable with user interaction.
And if the user miss some parameters in “sqlplus /nolog ssss.sql par1 par2 par5 par6”, how to use default value of the miss parameters??Don't you need a @ befiore the script name, e.g.
sqlplus /nolog @ssss.sql par1 par2 par5 par6Sorry, I don't know of any good way to use default values.
The foloowing works, but, as you can see, it's ugly.
"DEFINE 1" display a message like
DEFINE 1 = "par1" (CHAR)if &1 is defined; otherwise,it will display a SQL*Plus error message like
SP2-035: symbol 1 is UNDEFINEDNotice that the former contains an '=' sign, but the latter does not.
The best way I know to use default values is to run the DEFINE command, save the output to a filee, read the file, and see if it's an error message or not.
So you can use a script like this:
-- This is DEFINE_DEFAULT.SQL
SPOOL got_define_txt.sql
DEFINE &dd_old
SPOOL OFF
COLUMN dd_new_col NEW_VALUE &dd_new
WITH got_define_txt AS
SELECT q'[
@got_define_txt
]' AS define_txt
FROM dual
SELECT CASE
WHEN define_txt LIKE '%=%'
THEN REGEXP_REPLACE ( define_txt
, '.+"
([^"]*)
, '\1'
ELSE '&dd_default'
END AS dd_new_col
FROM got_define_txt
{code}
and start your real script, ssss.sql, something like this:
{code}
DEFINE dd_new = sv1
DEFINE dd_old = 1
DEFINE dd_default = FOO
@DEFINE_DEFAULT
DEFINE dd_new = sv2
DEFINE dd_old = 2
DEFINE dd_default = "Testing spaces in value"
@DEFINE_DEFAULT
{code}
when this finishes running, the substitution variable &sv1 will either have the value you passed in &1 or, if you didn't pass anything, the default value you specified, that is FOO.
Likewise, &sw2 will have the value you passed, or, if you didn't pass anything, the 23-character string 'Testing spaces in value'.
Here's how it works:
Define_default.sql puts the output of the "DEFINE x" command into a column, define_txt, in a query. That query displays either the existing value of the substitution variable indicated by &dd_old or, if it is undefined, the default value you want to use, which is stored in the substitution variable &dd_default. The substitution variable named in &dd_new is always set to something, but that something may be its existing value.
Notice that the paramerters to define_default.sql must be passed as global varibales.
Why didn't I just use arguments, so that we could simply say:
{code}
@DEFINE_DEFAULT sv1 1 FOO
{code}
? Because that would set the substitution variables &1, &2 and &3, which are miost likely the very ones in which you're interested.
I repeat: there must be a better way, but I'm sorry, I don't know what it is.
I usually don't do the method above. Instead, I always pass the required number of parameters, but I pass dummy or plce-holder values.
For example, if I wanted to call ssss.sql, but use defulat vlaues for &1 and &3, then I would say something like:
{code}
@ssss ? par2 ?
{code}
and, inside ssss.sql, test to see if the values are the place holder '?', and, if so, replace them with some real default value. The use has to remember what the special place holder-value is, but does not need to know anything more, and only ssss.sql itself needs to change if the default values change. -
How to use help in oracle 10g XE
Hello,
I just wanted to know how to use help in sql command line in oracle 10g XE
regards,
Sreekanth.Hi thankyou very much for the answer, that web-page is very good but....
I was hoping for answer that would walk me through the help command used in the SQL PLUS like: "help create"
after i have read few manuals i came to know we can use @hlpbld.sql for building help tables it asks me for entering value 1 and 2, after that it exits the prompt and when i re-login i dont see "help command" working...
any comments ot procedure to do this... -
How to use a non-Oracle database?
Oracle Lite is used as the database per default. Technical
notes describe how to use Oracle 9i. I'm more interested in using more light-weight RDBMSes like HSQLDB for example. It is been said that Oracle BPEL supports Oracle, Oracle Lite, DB2, SQL Server and Pointbase. Now how to configure Oracle BPEL to use each of the non-Oracle datbases listed above?I've managed to setup the PM to use Pointbase rather than the default Oracle Lite. Along the way, several questions came up:
1. Since the directory system\database\scripts already provides DDL scripts for Pointbase, creating the tables of a Pointbase database was easy. However, I wonder why you don't support HSQL. After all, OC4J supports HSQL data sources (see database-schemas\hypersonic.xml). Are there any features required by Oracle BPEL that are not provided by HSQL? If not, can we just use the Pointbase DDL scripts for HSQL?
2. Editing the data-sources.xml file also wasn't a big deal although templates for Pointbase were missing. BTW, my XML editor reports the data-sources.xml file to be invalid: "Document cannot be stand-alone because default-value attribute 'connection-retry-interval' is not explicitly assigned.
3. The changes in StartOraBPEL.bat were:
- Comment out running kill_olite.bat and start_olite.bat
- Start the Pointbase server (rather than Oracle Lite)
4. The needed changes in obsetenv.bat were not that obvious: It was required to add the Pointbase libs to the BOOT_LIB classpath. Otherwise the Pointbase driver cannot be loaded. To be on the safe side, I've also added the Pointbase libs to the MY_CLASSPATH classpath but I'm not sure if that is really required. Is it?
5. Finally, it would be good if shutting down the Pointbase server could be done in a similar fashion as that is configured for Oracle Lite. Apparently, some sort of hooking is used. Now how to setup a shutdown hook for a Pointbase server? -
How to use ed in oracle 11g as we do in 10g
Hi,
Anyone can u tell me how to use text editor in oracle 11g as
we do in 10g.
thanks
srinivasWell, that would be because notepad doesn't exist on *nix - isn't that obvious?
-
How to use EBU in oracle 7.3.4
I want to use ebu to create the catalog database and target
database.I have use rman in oracle8.1.7 successfully.But I don't
know the procedure for ebu .If you know how to use the ebu
please let me know .Thanks.
Best regards.Touch and hold the App until the apps wiggle and show an X in the upper left corner of the App.
Click the X to delete it from your device.
Not all Apps can be deleted.
If they came with the device, you cannot delete them. -
How to use array of Point Class
I use Point class as array. I already create that. However I can't access to setLocation.
Ex.
Point myPoint[] = new Point[10];
myPoint[0].setLocation(10, 2);
It has a error.
Please Explain me.DeltaGeek wrote:
BalusC wrote:
Or use [Arrays#fill()|http://java.sun.com/javase/6/docs/api/java/util/Arrays.html]. Point[] points = new Point[10];
Arrays.fill(points, new Point());
That doesn't do what you think it does, unless you want your array to contain 10 references to the same Point object.The OP has received a good answer, I believe. So it's worth risking diverting this thread into the weeds by pointing out that if Java had closures then BalusC's code could be modified to work. -
How to use Array in Formcalc?
Please share syntax for using Array in Formcalc.
Hi,
FormCalc is a simple scripting language and does not support objects like arrays.
The only function that come close to an array in JavaScript is Choose(),
This first parameter selects the nth value of the following comma separated strings.
Choose(3, "String1", "String2", "String3", "String4")
returns String3 -
How to use Array in Calc script.
Hi, <BR> I want to use Array in Calc scripts. Can anyone provide me some examples. <BR><BR>Thanks<BR>Murali
For information on the ARRAY command, check out <a target=_blank class=ftalternatingbarlinklarge href="http://dev.hyperion.com/techdocs/essbase/essbase_712/Docs/techref/techref.htm">this hyperlink</a>.<BR><BR>Click on <b>Calculation Commands</b>, then choose <b>ARRAY</b>.<BR><BR>Can you give me some information explaining why you want to use ARRAY? It's use is pretty rare and I would like to understand what you're trying to do.
Maybe you are looking for
-
How can I create an instance of "java.util.prefs.WindowsPreferences"?
Hi All, I was trying to find out a way to access the Windows Registry to add soome keys and and later add a string. I found WindowsPreferences might be useful in the above mentioned context. I was trying to create an instance of it, but when I import
-
Hi I have been using Mac's now for about 10 years and this is my first problem. I have recently moved into an office that use PC's with a Windows server. I have set up the network to transfer files and view the windows server and it works fine. I ha
-
My artists section on my ipod keeps crashing ever i click it and the whole app closes
So bassicaly when ever i click on my artists in my music app it will just crash and the while app will just close
-
Subcontractor and supplier material
i want to know where is the particular material allocate to which vendor for example there are two more vendors ,we provide contract to any of one vendors i want to know curently which vendor has that material ifor raw material which supplier has t
-
We are using a vbscript to assign a Outlook 2010 signature to the users that are logging in the network. A few things are a problem. First the logo is different when we open it in a editor it looks sharp etc. In Outlook it looks less sharp and smalle