Using an array name stored in a String in a Statement
In my sequence, I build an array in one section and store it in a variable called Locals.Test_Array.
I build the name of the permanent place I would like to store this array and store it in a string called Locals.SG_Test_Array_Name.
I would like to move the values from Locals.Test_Array to the Station Globals Array name stored in Locals.SG_Test_Array_Name.
For example:
the string stored in Locals.SG_Test_Array_Name is "StationGlobals.Coolant_Temperature_Test_Array" (already created in Station Globals)
What I am trying to do is this:
Statement StationGlobals.Coolant_Temperature_Test_Array=Locals.Test_Array (this works)
The Station Global Array name needs to change as the sequence executes and the data in Locals.Test_Array changes.
What I need is something like this.
Statement Locals.SG_Test_Array_Name=Locals.Test_Array (where SG_Test_Array_Name is a string that holds the name of the array)
Thanks, Big_Will
Evaluate(Locals.SG_Test_Array_Name + " = Locals.Test_Array " )
Similar Messages
-
Using Parameterized Arrays in Stored Procedure
I tried following code to pass array value to stored procedure but its giving error, as I am new to this procedure, please advise what am I missing ?
Best Regards,
Luqman
My code is as below.
CREATE TYPE num_array AS table of number;
create or replace procedure give_me_an_array
( p_array in num_array )
as
begin
for i in 1 .. p_array.count
loop
dbms_output.put_line( p_array(i) );
end loop;
end give_me_an_array;
declare
mdata num_array;
begin
mdata(1) := 1234;
mdata(2) := 10;
give_me_an_array(mdata);
end;Hi Satya,
Now I got it, thanks,
Can you please advise, if I use the same stored procedure for EMP Table and use my array values to retrieve the selected EMPNo
I tried following but I could not succeed.
When I compile the stored procedure, error occurs:
"inconsistent datatypes: expected NUMBER got NUM_ARRAY"
for example:
CREATE TYPE NUM_ARRAY AS TABLE OF NUMBER;
Create or Replace Package TB_Data
Is Type CV_Type Is REF CURSOR;
END TB_DATA;
Create or Replace Stored Procedure give_me_an_array
(CV IN OUT TB_DATA.CV_TYPE,
MEmpNo In Num_Array)
Is
Begin
Open CV for
Select * from EMP
Where Empno in MEmpNo;
End myProc;
declare
mdata num_array:=num_array(7839,7844);
begin
give_me_an_array(mdata);
end;
Best Regards,
Luqman -
Get class object for primitive datatype name stored in a string
Hi,
I have an array of Strings:
String[] somePrimitives = {"int", "char", "void" };
I want to achieve the equivalent of :
for(int k = 0; k < somePrimitives.length; k++) {
Class myClass = Class.forName(somePrimitives[k]); //Wont work
We all know, we cannot do Class.forName("int") etc since "int" is not a path to
an actual class - whereas Class.forName("java.lang.Integer") will work.
Can anyone tell me how to achieve the above ?
Of course, I don't want to have numerous hardcoded checking conditions like
if(somePrimitives[k].equals("int")) return (Integer.TYPE);
thanks.1. Why couldn't java provide me a simple provision to list all available primitives and their corresponding
class mapping ? Why should I do the mapping...shouldn't the language have taken care of
its provisions ?Yes, and native compilation on the fly, dynamic modification of classes, a sensible types system, usable Number tree, quasiquotation, access to the AST of the source, getting a method based on argument types rather than parameter types, etc. etc.
2. Or even better they could have made the method
Class.getPrimitiveClass(String primitiveDatatTypeName)
as a public method. This would have solved the whole
problem with a one line piece of code. Why did they
have to make it non-public ???If you want it easy, go elsewhere.
But seriously, the reflection capabilities were tagged onto Java as it grew, and were not designed to reflect the state of the art, but as a 'just enough to get by' solution. Most of the time people don't need it, so it's not there, any you have to roll your own.
Pete -
Using field names stored in the database in a query
Hi,
I'm working on a database that has field names stored in tables. In order to construct a query using the field names stored in the table, normally I'd use dynamic SQL.
For example in table1 I have
Field_Name Value
Field1
'Name'
Field 2
'Address'
I want to build a select statement "SELECT Name, Address, FROM tblCustTable" - if possible not using dynamic SQL.
Is there a neat way to do this?
Thanks very much.
Sad old developerNo, it is not possible to dynamically include ANY object names (Columns, Tables, Functions, Procedures, etc) in SQL without using Dynamic SQL.
The closest you can get, if you are choosing from a known set of names, is to use CASE statements:
SELECT CASE
WHEN t1.Field1='Name' THEN ct.[Name]
WHEN t1.Field1='Address' THEN ct.[Address]
END AS Field1
FROM tblCustTable ct
CROSSJOIN table1 t1
WHERE ...
However there are several disadvantages to this approach, and the SQL will quickly get very convoluted and difficult to maintain. Dynamic SQL is much cleaner.
-Tab Alleman -
How to create an instance of a class which is stored in a String?
I've class name stored in a String Object.
now i've to create an instance of that class name.
How?This is very dangerous ground because you give up compile-time safety, but you can get a Class object using Class.forName(String). Then you can use methods of the class Class to operate on it (including creating an instance).
-
An array and scalar values together in an sql statement
Hi
We have a table called SERVICE and following are the 3 columns from SERVICE table,
SERVICESTATUSID - NUMBER(10)
ACCOUNTID - NUMBER(10)
SERVICENUMBER - VARCHAR(41)
My aim is to be able to update the status of a bunch of entries in this table from Pro C code with new ServiceStatusID where accountId matches the accountId supplied and SERVICENUMBER exists in the list of services supplied.
Now I am trying to use host arrays here for SERVICENUMBERs and then my Update statement looks like this,
UPDATE SERVICE SET SERVICESTATUSID = :x WHERE ACCOUNTID = :y AND SERVICENUMBER = :z
And then I am trying to execute it with the help of bind variables in Pro C as follows,
EXEC SQL AT DB_NAME CONTEXT USE :myContext;
EXEC SQL AT DB_NAME DECLARE sqlStatement STATEMENT;
EXEC SQL AT DB_NAME PREPARE sqlStatement FROM :str;
EXEC SQL AT DB_NAME EXECUTE sqlStatement USING :statusId, :accountId, :serviceNumbersList;
where statusId is integer,user12169137 wrote:
Now I am trying to use host arrays here for SERVICENUMBERs and then my Update statement looks like this,
UPDATE SERVICE SET SERVICESTATUSID = :x WHERE ACCOUNTID = :y AND SERVICENUMBER = :z
And then I am trying to execute it with the help of bind variables in Pro C as follows,
EXEC SQL AT DB_NAME CONTEXT USE :myContext;
EXEC SQL AT DB_NAME DECLARE sqlStatement STATEMENT;
EXEC SQL AT DB_NAME PREPARE sqlStatement FROM :str;
EXEC SQL AT DB_NAME EXECUTE sqlStatement USING :statusId, :accountId, :serviceNumbersList;
where statusId is integer,I am not sure what you are asking. I think you want statusId to be a scalar integer but use a series of values for the service numbers.
This can be done, but will take a little effort. It might be most easily done in a PL/SQL block where you can control the datatypes too. What you will have to do is create a database object with the datatype (integer, number, whatever), then another object as a table of that object. It should then be possible to convert your collection into a database nested table with the CAST() function. Don't expect really good performance from this.
Search OTN for cast conversions for more information on this method.
Another alternative if you have < 1000 items is to use dynamic SQL by generating an IN list from your collection contents. Again, performance will probably not be great.
Good luck. -
Using a ariable for an array name
I am currently working on the search method for my project.Which is to use breadth first search, to find the goal state of a problem.I am storing each new state encountered in a queue called states, and using an array for each state. So states would be a queue of arrays.
I was hoping to name each new state in order so state1 state2 state3 and so on. So for instance state1 would be an array containing the original board.
The problem I am having is declaring a new array for each new state. I was hoping to use a variable i to keep count of the number of states, so that when I declare a new array I could use something like
String[][] statei = original board array
So if i = 1 then state1 would contain a copy of the original array.
However I cannot seem to get java to recognise that i is a variable and not part of the name for the array.
Is there any way to let java know that I�m using i to represent a variable. Do I need to but i in quotation marks or something similar?
Thanks for any helpsorry i wasnt clear enough, what i have is an initial array called boards. Now every time i move a value in boards i need to create a new array. So for instance
i = no of states
new String [][] statei = a copy of boards[] with the affects of making the move
example if i was moving the value of boards[x][y] to boards[x][y+1]
i would need statei to be an array containg the change to the array above -
How to pass dynamically generated string value as array name in TestStand?
Hi All,
I have a string variable which holds an array name as its value. The string value is a dynamically generated one. Now my problem is how to retrieve the values within the array where as the array name is stored in a string variable.
for eg:
fileglobals.InfoName = "Array_Name" --> fileglobals.InfoName is a string variable, Array_Name is the array name generated dynamically and it is known only at run-time.
Array_Name[0] = "a";
Array_Name[1] = "b";
Array_Name[2] = "c";
In the above case, I have to retrieve the values of a, b and c
Any help is greatly appreciated
Thanks
Arun Prasath E GHi,
Looking at your sequencefile.
You seem to be trying to save into FlieGlobals.InfoName a string with the values of "FileGlobals.Info_0".."FileGlobals.Info_n" where n is the value of Parameter.TestSocket.Index.
Then you are setting the value into FileGlobals.TempName from "StationGlobals.FileGlobals.Info_0" assuming Parameter.TestSocket.Index is 0.
Is this correct?
I realise this is a cutdown sequence file but you must make sure These variable actually exist in either FileGlobals or StationGlobals. Also with FileGlobals each SequenceFile has its own FileGlobals unless you have set the properties of the SequencFile to use a common FileGlobals.
What was the precise error you was seeing as it will properly telling you what variable of property it can't find.
Regards
Ray Farmer
Regards
Ray Farmer -
. NET to call Oracle stored procedure, use an array of types of parameters
. NET to call Oracle stored procedure, use an array of types of parameters
Step1:(In the Oracle database define an array of types)
CREATE OR REPLACE TYPE STRING_VARRAY AS VARRAY (1000) OF NVARCHAR2(255)
Step2:
CREATE OR REPLACE PROCEDURE Test
(i_test in string_varray,o_result out int)
IS
BEGIN
o_result:=i_test.count;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
NULL;
WHEN OTHERS
THEN
o_result:=0;
END arraytest;
Step3:
Use System.Data.OracleClient
C# Code:
OracleConnection conn = new OracleConnection("User Id=test;Password=test;Data Source=test");
OracleCommand cmd = new OracleCommand("Test", conn);
cmd.CommandType = CommandType.StoredProcedure;
string[] str = new string[] { "11", "22" };
OracleParameter p1 = new OracleParameter("i_test", OracleType.NVarChar);
p1.Direction = ParameterDirection.Input;
p1.Value = str;
cmd.Parameters.Add(p1);
OracleParameter p2 = new OracleParameter("o_result", OracleType.Int32);
p2.Direction = ParameterDirection.Output;
cmd.Parameters.Add(p2);
int i = 0;
try
conn.Open();
cmd.ExecuteNonQuery();
i =(int) p2.Value;
catch (Exception ex)
finally
conn.Close();
Error:
Execution Failed:ORA-06550:Line 1,Column 7:
PLS-00306:Test parameters when calling the number or types of errors
ORA-06550:Line 1,Column 7:
PL/SQL:Statement ignored
Edited by: user10133982 on Jun 4, 2009 7:13 AM. NET to call Oracle stored procedure, use an array of types of parameters
The use of ODP.net(Oracle 10g), the error is still the same
Step1:(In the Oracle database define an array of types)
CREATE OR REPLACE TYPE STRING_VARRAY AS VARRAY (1000) OF NVARCHAR2(255)
Step2:
CREATE OR REPLACE PROCEDURE Test
(i_test in string_varray,o_result out int)
IS
BEGIN
o_result:=i_test.count;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
NULL;
WHEN OTHERS
THEN
o_result:=0;
END arraytest;
Step3:
ODP.NET(Oracle 10g)
OracleConnection conn = new OracleConnection("User Id=test;Password=test;Data Source=test");
OracleCommand cmd = new OracleCommand("Test", conn);
cmd.CommandType = CommandType.StoredProcedure;
string[] str = new string[2] { "11", "222" };
cmd.ArrayBindCount=2;
OracleParameter p1 = new OracleParameter("i_test", OracleDbType.NVarChar);
p1.Direction = ParameterDirection.Input;
p1.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
p1.Value = str;
p1.ArrayBindSize=new int[2]{2,3};
p1.ArrayBindStatus = new OracleParameterStatus[2]{
OracleParameterStatus.Success,
OracleParameterStatus.Success
cmd.Parameters.Add(p1);
OracleParameter p2 = new OracleParameter("o_result", OracleDbType.Int32);
p2.Direction = ParameterDirection.Output;
P2.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
p2.Value=0;
cmd.Parameters.Add(p2);
int i = 0;
try
conn.Open();
cmd.ExecuteNonQuery();
i =(int) p2.Value;
catch (Exception ex)
finally
conn.Close();
Error:
Execution Failed:ORA-06550:Line 1,Column 7:
PLS-00306:Test parameters when calling the number or types of errors
ORA-06550:Line 1,Column 7:
PL/SQL:Statement ignored
Edited by: user10133982 on Jun 5, 2009 7:48 AM -
Can I Execute a function whose name is stored in a string variable?
Can I execute a function whose name is stored in a string variable?
Like
Depending on the condition I will stroed the name of the function in a string variable. Then using that string variable i want to execute the function.
String str=��
iVal an int can take ne value
Switch(iVal)
Case 1:
str=�test1()�;
Case 2:
str=�test2()�;
I want whatever function name is in str to be executed.
----------------------------------------------------------------------------------For just executing a method or two, reflection might be easier than beanshell (or it might not). For executing entire scripts, beanshell will be preferable over reflection.
(I assume beanshell uses reflection under the hood, but I've never bothered to peek.) -
How to create a new file having a name that is stored in a string
Hello friends i am new to java and i need your help .
I have a string which will take different values at run time. I want to create a file which has the same name as stored in the string . Can anyone help me?The Java Almanac example I linked to uses createNewFile() - the API documentation is not particularly clear about exactly what happens if c:\some\value\assigned\at doesn't already exist. But you're only a small experiment away from finding out!
Another page gives examples of directory creation.
http://www.exampledepot.com/egs/java.io/CreateDir.html
Once (or if) the file is created using a File then, yes, that File is the name of the file: parent directories and all. If you create a FileReader based on the File it will read from the right place. -
how do I write a java method without using an array of strings?
for example:
import java.io.File;
public class rename
public static void main(String[] args)
File src = new File(args[0]);
File dst = new File("c:\\temp\\temp.txt");
boolean wasRenamed = src.renameTo(dst);
I don't want to have main use an array of strings but I want rename to work as a classThis is what I changed it to and am getting an -- Exception in thread "main" java.lang.NoSuchMethodError: main
Sorry this is my first java program
import java.io.File;
class App {
private App() {
super();
static final public void main(final String[] args) {
switch (args.length) {
case 1:
try {
Rename rename = new Rename();
rename.rename("c:\\felss\\charles.txt.bak"); // see, it's kind of silly to have same names for class and method
System.exit(0);
catch (Throwable e) {
e.printStackTrace();
System.exit(1);
break;
default:
System.err.println("Usage: java App [new name]");
System.exit(1);
public class Rename {
public Rename() {
super();
final public void rename(final String newName) {
File src = new File(newName);
File dst = new File("c:\\felss\\charles.txt");
boolean done = src.renameTo(dst);
} -
Every time I login I get the message "aosnotifyd wants to use your confidential information stored in "my name" in your keychain." How do I know if it is safe to allow this? Can anyone advise please?
My immediate reaction is to deny.
Have you downloaded or installed any application that may relate to the abbreviation AOS? It may not necessarily be the application's name, could be the developer or distributor.
As it's occuring at log-in, go to System Preferences > Accounts > your account > Login Items and look for a related item. If there's one there, right-click (or ctrl click) on it and select Reveal in Finder. That will show you where the originator of the item is on your system and should give you more of a clue as to what it is.
I'd remove the item from login items anyway (highlight and click the minus sign at the bottom of the window). There shouldn't be anything trying to use your keychain info to notify anyone. -
How to call a stored procedure using its package name in Oracle
hi
we're doing a JDBC scenario where we call a stored procedure(a.prc) using its package name(b)The stored procedure has In /Out/IN-OUT parameter.
i have got 2 queries:
1- How to call the stored procedure using it's package.
2- How to capture the In/Out parameter in the response.hi Prateek
thanks for the reply.
However when i tried mapping it to Package.procedure, communication channel throws the error saying that Package.proceudre needs to be declared.
As i said , the procedure has IN-OUT parameter too.In oracle we need to write a block if we want to read the IN-OUT parameter.
How to get the IN-OUT parameter in XI? -
Search given string array and replace with another string array using Regex
Hi All,
I want to search the given string array and replace with another string array using regex in java
for example,
String news = "If you wish to search for any of these characters, they must be preceded by the character to be interpreted"
String fromValue[] = {"you", "search", "for", "any"}
String toValue[] = {"me", "dont search", "never", "trip"}
so the string "you" needs to be converted to "me" i.e you --> me. Similarly
you --> me
search --> don't search
for --> never
any --> trip
I want a SINGLE Regular Expression with search and replaces and returns a SINGLE String after replacing all.
I don't like to iterate one by one and applying regex for each from and to value. Instead i want to iterate the array and form a SINGLE Regulare expression and use to replace the contents of the Entire String.
One Single regular expression which matches the pattern and solve the issue.
the output should be as:
If me wish to don't search never trip etc...,
Please help me to resolve this.
Thanks In Advance,
KathirAs stated, no, it can't be done. But that doesn't mean you have to make a separate pass over the input for each word you want to replace. You can employ a regex that matches any word, then use the lower-level Matcher methods to replace the word or not depending on what was matched. Here's an example: import java.util.*;
import java.util.regex.*;
public class Test
static final List<String> oldWords =
Arrays.asList("you", "search", "for", "any");
static final List<String> newWords =
Arrays.asList("me", "dont search", "never", "trip");
public static void main(String[] args) throws Exception
String str = "If you wish to search for any of these characters, "
+ "they must be preceded by the character to be interpreted";
System.out.println(doReplace(str));
public static String doReplace(String str)
Pattern p = Pattern.compile("\\b\\w+\\b");
Matcher m = p.matcher(str);
StringBuffer sb = new StringBuffer();
while (m.find())
int pos = oldWords.indexOf(m.group());
if (pos > -1)
m.appendReplacement(sb, "");
sb.append(newWords.get(pos));
m.appendTail(sb);
return sb.toString();
} This is just a demonstration of the technique; a real-world solution would require a more complicated regex, and I would probably use a Map instead of the two Lists (or arrays).
Maybe you are looking for
-
How do you use BOBJ SDK to retrieve the results of a query in XML
I am trying to programatically get the results of a query given the query id My old code used BusinessObjects Enterprise Web Services API to Retrieve a document's contents DocumentInformation biDocInfo; RetrieveData retBOData = RetrieveData.Factory.
-
I am a beginning programmer and I want to make a program that accepts weight to track weight loss for my own benefit How would you program this: Enter weight: (input here) I like to have everything in one line I was thinking: System.out.println("Ente
-
Problem In Executing Query In JSP-Oracle
I have one Query with some conditions in it. It showing error in JSP page when Run it like FROM keyword not found where expected, but this query running well in Oracle SQL Developer. The query is given below. SELECT SCC.STACK_ID, S.SEVERITY_LOWER AS
-
GRC AC 10.0 Maintain Master User ID Mapping
Hi, I try to configure "Maintain Master User ID Mapping" in the transaction SPRO->GRC->Access Control Example: SYSTEM: A USER ID: B MASTER USER ID: C If i try to launch the PSS for the C user, also change the password of the B user? This, not working
-
ok, my problem is that my macbook is not picking up other webcams. the specific one is the xbox live vision camera, but i have tried others and they do not work. i have all the updates, and even have quicktime pro, but nothing will recognize it. any