How to assigne a value to UNIX variable inside a oracle plsql block
Hi All,
How can a assign a value to my UNIX (Shell script)variable inside a oracle procedure and read it back from shell script.
Can you please help me out regarding this.
Thanks in advances.
Regards
Krishna Shrivas.
SQL> create or replace function setvar return varchar2 is
2 begin
3 return('SOMETHING');
4* end;
SQL> /
Function created.
SQL> get readvar
1 select setvar from dual
2 /
SETVAR
SOMETHING
SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@linuxas tmp]$ cat readvar.sh
MYVAR=`sqlplus -s scott/tiger @readvar`
echo $MYVAR | awk '{print $3}'
[oracle@linuxas tmp]$ ./readvar.sh
SOMETHING
[oracle@linuxas tmp]$
Similar Messages
-
How to Print the Value of a variable inside a PL/SQL package
Hi Friends,
Here is my Scenario
I have a PL/SQL Package. Let us call it Baseline Package.
This Package includes a dynamically built merge Statement.
Execute Immediate v_merge_query.
I have a procedure which replaces which few Keywords from the Package Text and Creates a new one depending on Inputs I provide. (This is something like a Code generator)
Now while Creating the new package, I need to print the Value of v_merge_query.... I Need s Static Query to be Printed inside the new package and not a dynamic query.
My Question is "Is there a way to print the value of the variable inside a different PL/SQL package?
Thanks in Advance,
MohitPrint where?
That PL/SQL code is server-side code. It runs in an Oracle server process.
That server process does not have a keyboard. Or a screen/monitor. Or display canvas. Or an attached printer.
That server process is incapable of "printing" as that is not its job or responsibility and not part of its environment.
What is can do is record data for the client to look at afterwards. This can be done using static PL/SQL session variables. Or a SQL table.
The former is done by DBMS_OUTPUT - a very primitive interface for writing text into a static PL/SQL string array. That btw resides in expensive private process server memory. The client can query the array after a database call and render the contents.
PS. Also keep in mind that bind variables are critical for performance and server robustness - especially when (ab)using dynamic SQL. -
How to assign a value to ODI Variable using ODI Procedure
Hi ,
Is it possible to assign a value to a ODI Variable using ODI Procedure ?
If it is possible how we can do that.
BEGIN
IF #Counter=1
Then
#Next_Increment:=#Counter+1;
End if;
END;
In my example I have 2 ODI Variables #counter and #Next_increment.
I am trying to assign VALUE TO A ODI VARIABLE #next_increment from another ODI Variable #counter.
thanks
prasannaPrasanna,
I have a similar requirement where I need to assign values to ODI variables within a procedure. How do we make use of an ODI package to accomplish this ?
Actually, I have a sequence of ODI steps, and there is a call to a procedure 'LOG ERROR' from every step which gets called in case error occurs in any step. I just need to identify from which step the error came.
Please help. -
How to check empty string and null? Assign same value to multiple variables
Hi,
1.
How do I check for empty string and null?
in_value IN VARCHAR2
2. Also how do I assign same value to multiple variables?
var_one NUMBER := 0;
var_two NUMBER := 0;
var_one := var_two := 0; --- Gives an error
ThanksMichaelS wrote:
Not always: Beware of CHAR's:
Bug 727361: ZERO-LENGTH STRING DOES NOT RETURN NULL WHEN USED WITH CHAR DATA TYPE IN PL/SQL:
SQL> declare
2 l_str1 char (10) := '';
3 l_str2 char (10) := null;
4 begin
5
6 if l_str1 is null
7 then
8 dbms_output.put_line ('oh STR1 is null');
9 elsif l_str1 is not null
10 then
11 dbms_output.put_line ('oh STR1 is NOT null');
12 end if;
13
14 if l_str2 is null
15 then
16 dbms_output.put_line ('oh STR2 is null');
17 elsif l_str2 is not null
18 then
19 dbms_output.put_line ('oh STR2 is NOT null');
20 end if;
21 end;
22 /
oh STR1 is NOT null
oh STR2 is null
PL/SQL procedure successfully completed.
SQL> alter session set events '10932 trace name context forever, level 16384';
Session altered.
SQL> declare
2 l_str1 char (10) := '';
3 l_str2 char (10) := null;
4 begin
5
6 if l_str1 is null
7 then
8 dbms_output.put_line ('oh STR1 is null');
9 elsif l_str1 is not null
10 then
11 dbms_output.put_line ('oh STR1 is NOT null');
12 end if;
13
14 if l_str2 is null
15 then
16 dbms_output.put_line ('oh STR2 is null');
17 elsif l_str2 is not null
18 then
19 dbms_output.put_line ('oh STR2 is NOT null');
20 end if;
21 end;
22 /
oh STR1 is null
oh STR2 is null
PL/SQL procedure successfully completed.
SQL> SY. -
How to upload a value of the variable to a file.
Hi All,
1. am using below line to uploading data to notepad
UTL_FILE.PUT_LINE(v_file,'User_name,age,college');
here the problem is The user_name i am getting as parameter and assigning that values to a variable.
like
User_name:=usrname;
but in output file instead of user name (Sree, sunil, ravi) am getting User_name as value
even i tried like as below
UTL_FILE.PUT_LINE(v_file,''||User_name||'','age,college');
but no use.
How to use variables when we are uploading the file.
Thanks
SreeWhat's with all the quotes?
If user_name, age and college are variables and you want them for instance comma separated, just do:
UTL_FILE.PUT_LINE(v_file, user_name || ',' || age || ',' || college); -
How to find the value of a variable in other program
How to find the value of a variable in other program say I am in a FM and this FM is being called in from other program and I want to know some of the variable details of the program from the FM itself. Imagine if this is a txn. and I need to know the details from some of the programs while executing the same transaction
Regards
VinHi Vinayak,
you will be having your first program values in internal table or some variables,
when you are calling the second program you wii use like this,
SUBMIT <Second Program Name> USING SELECTION-SCREEN '1000'
WITH s_emp(second program select-options) IN t_emp(first program variables)
WITH p_chk EQ t_chk
WITH p_r1 EQ t_r1
WITH p_month EQ t_month
WITH s_cust1 IN t_cust1
WITH p_r2 EQ t_r2
WITH s_cust2 IN t_cust2
WITH s_week IN t_week
AND RETURN.
you have pas like this to get your first program details. -
How to get the value of a variable defined in javascript in JSP
how to get the value of a variable defined in javascript in/through JSP????
In Javascript you can use the DOM to access the input element and set it's value before submitting the form. Then it's value will just be passed.
-
How to get the value of a variable in FOX?
Hi,
In the FOX program how to get the value of a variable defined in planning area?
can anyone give me some sample code?
thanksAdding to the last reply,
you can use VARI(variable) to get the count of the values.
In the latest version of BPS, you may also use the following new foreach construct:
FOREACH var IN VARIABLE variable_id.
Regards - Ravi -
How to assigne multiple value in key of read table
Hi gurus,
I want read table xxxx with key field1 = ' xxx' or field1 = 'yyy'.
how to assign multiple value as key for the same field while reading internal table.
Regards
sagarHi ,
You can loop the internal table like
loop at <table xxxx> where field1 = ' xxx' or field1 = 'yyy'
or you can write two read statements to read the internal table in wrk area.
read table <table xxxx> with key field1 = ' xxx'.
if sy-subrc <>0
read table <table xxxx> with key field1 = 'yyy'.
if sy-subrc = 0
endif.
else.
do your data processing.
endif.
Thans. -
How to assign NULL value to an ITEM in Forms Personalization?
Hi,
how to assign NULL value to an ITEM in Forms Personalization?
please suggest me.
ThanksI don't know what your form personalization does and maybe I misunderstand you ...
Try
:item_name := null; -
Hi,
How to assign a value for Unit of measure (like PC, KG...) in ABAP program?
I want to assign PC in a field to execute the program, like wa-ENTRY_UOM = 'pc'.
But the system returen a message that "Unit of measure is not convertible to stockkeeping unit PC"
Could anyone tell me how to assign the value??
Thanks!hi,
first convert the quantity in the same unit ( like in you case ST to PC ) by using FM : MD_CONVERT_MATERIAL_UNIT
CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
EXPORTING
i_matnr = matnr
i_in_me = entry_uom
i_out_me = out_uom
i_menge = quantity
IMPORTING
E_MENGE = fp_l_v_quant
EXCEPTIONS
ERROR_IN_APPLICATION = 1
ERROR = 2
OTHERS = 3.
IF sy-subrc <> 0.
give error message here
ENDIF.
bcoz in ur program somewhere the quantities etc are compared and there units may be different... so that is why it is showing such error. so just convert convert the quantity in the same unit .
regards
rahul
Edited by: RAHUL SHARMA on Jun 17, 2009 9:31 AM -
How do I edit value of PATH variable in AIX?
How do I edit value of PATH variable in AIX?
Hi Sandy,
You need to edit .profile file from the users home directory...
(Please note DOT before filename, which make the file hidden...)
use "ls -a" command to list hidden files.
its a basic question, why don't you search google for such issues.
It will also help you to understand the system better...
Regards.
Rajesh Narkhede -
How to assign a value to a parameter {?MyParam} dynamically?
How to assign a value to a parameter {?MyParam} dynamically?
Example:
{?One_Or_Two} <- my first parameter
{?MyParam} <- My second parameter
The Code:
If ( {?One_Or_Two} = 'One' then
{?MyParam} = 'One' ;
else
{?MyParam} = 'Two' ;
(THIS IS NOT WORKING FOR ME! ANYONE KNOW WHY?)
IT NEVER ASSIGN THE VALUE?
My Command query looks like:
SELECT * FROM MyTable
WHERE MyTable.MyColumn = {?MyParam}
THANKSHi Joseph,
I'm a bit unclear as to what you are doing and from what I see you're running in circles.
Your Command query is looking for a field that is equal to {?MyParam}.
Now you want to take {?MyParam} in the report and change the value after you've set it.
Parameters cannot be set from the Command, you can format it and manipulate it but they cannot be set except from the parameters window or from a front-end.
Thanks,
Brian -
How to get the values of the objects inside an object??
Hi,
I am trying to write code to display name and memory usage of all session attributes, in a recursive way.
I suppose reflection is needed here, but I cant figure out how to get the values of the objects inside an object...
private void handleIt(String attributeName, Object attributeValue) {
boolean isPrimitiveOrNull = ((null == attributeValue) ||
(attributeValue.getClass().isPrimitive()));
if (isPrimitiveOrNull) {
sb.append("{" + attributeName + ":" + sizeOf(attributeValue) + "}");
} else {
sb.append("{" + attributeName + ":" + sizeOf(attributeValue) + "{");
Field[] fields = attributeValue.getClass().getDeclaredFields();
int lim = fields.length;
String name;
Object value = null;
for (int i = 0; i < lim; i++) {
name = fields.getName();
//LOOK AT THIS LINE: !!!!!!!!!!!!!!!!!!!!!!!!!!!
value = fields[i].get(obj); //I don´t know what 'obj' should be??
handleIt(name, value);
sb.append("}");
Any suggestions will be greatly appreciated...I realized that massive int objects called MAX_VALUE, MIN_VALUE and SIZE where causing the StackOverflow, so I removed them from the analysis.
This is the resultant code. But I think it isnt accurate in calculating the real size of objects being got using reflexion.
Do you or somebody have any more suggestions?
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.lang.reflect.Field;
import java.util.Enumeration;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class SessionMeasurer extends HttpServlet {
private static final long serialVersionUID = 1470488362727841992L;
private StringBuilder sb = new StringBuilder();
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
performTask(request, response);
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
performTask(request, response);
public void performTask(HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession(false);
String attributeName = "";
Object attributeValue = null;
for (Enumeration<?> attributeNames = session.getAttributeNames(); attributeNames.hasMoreElements();) {
attributeName = (String)attributeNames.nextElement();
attributeValue = session.getAttribute(attributeName);
handleIt(attributeName, attributeValue);
System.out.println(sb.toString());
private void handleIt(String attributeName, Object attributeValue) {
if (attributeValue != null) {
boolean isPrimitive = attributeValue.getClass().isPrimitive();
if (isPrimitive) {
sb.append("{" + attributeName + ":" + sizeOf(attributeValue) + "}");
} else {
sb.append("{" + attributeName + ":" + sizeOf(attributeValue) + "{");
Field[] fields = attributeValue.getClass().getDeclaredFields();
String name;
Object value = null;
int lim = fields.length;
for (int i = 0; i < lim; i++) {
name = fields.getName();
if (!name.endsWith("_VALUE") && !name.equals("SIZE") && !name.equals("serialVersionUID")) {
try {
value = fields[i].get(attributeValue);
} catch(Exception e) {
//PENDIENTE: Tratamiento excepción
handleIt(name, value);
sb.append("}");
private int sizeOf(Object obj) {
//Valid only for Serializables
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = null;
byte[] bytes = null;
try {
oos = new ObjectOutputStream(baos);
oos.writeObject(obj);
bytes = baos.toByteArray();
} catch(Exception e) {
//PENDIENTE: Tratamiento excepción
} finally {
if (oos != null) {
try {
oos.close();
} catch(Exception e) {
//PENDIENTE: Tratamiento excepción
if (baos != null) {
try {
baos.close();
} catch(Exception e) {
//PENDIENTE: Tratamiento excepción
int size = -1;
if (bytes != null) {
size = bytes.length;
return size; -
How to assign bean value to a local variable in JSP using struts.
Hi everybody!
I've a problem that puzzled me on how to assign a bean value to a local variable like String in JSP using struts.
we can have someting like this to display the value
<bean:write name="detailService" property="status" />or
<bean:define id="theStatus" name="detailService" property="status"/>
This is country: <%=theStatus%>but an error occured when I tried like this:
String currentStatus = "<bean:define id="theStatus" name="detailService" property="status"/>";
or
String currentStatus = "<bean:write name="detailService" property="status" />";Is there a way to do this?.....
Any help pretty much appreciatedJava != JSP.
The <bean:define> and <bean:write> tags are custom tags meant to appear in the HTML section of a JSP file, as opposed to the scriptlet section. They actually get turned into java code as part of the translation process.
The <bean:write> tag naturally just writes out what you tell it to.
The <bean:define> tag defines a local variable, and gives it a value.
this should do it.
<bean:define id="theStatus" name="detailService" property="status" type="java.lang.String"/>
<%
String currentStatus = theStatus;
%>With the advent of JSTL, you shouldn't really need to use scriptlet code anymore. Personally I am for 0% scriptlet code in any jsp I write.
Maybe you are looking for
-
How to transfer my music to my pc via itunes?
I want to transfer mymusic from Iphone to Pc via itunes, how to do it ?
-
Weird chart shifting problem?
I'm having a problem that's easy to reproduce. Create a pie chart on a blank slide (the default data will work fine). In the inspector move the Labels so they are outside of the pie chart -- around the perimeter. Now set the chart so the build is by
-
Getting lines in prints Photoshop CS6
Hello, I am getting lines in my prints from PhotoShop CS6. My printer is the Canon MX522. Ive noticed that printing from other *dumb* programs such as Microsoft Paint the images look fine BUT with photoshop the images print ultra fast and have lines.
-
Hi i am using oracle 9i rel 2 on windows 2000 server Can you explain me the use of NOCOPY mode in stored procedures thanks in advance
-
Wireless adapter speed question
Hello, I was wondering if anyone else has faced this 'problem'. I just got the new advanced router from Verizon that supports my 75/75 speed plan. Wired i'm getting that speed.. sometimes even 80Mbps. My laptop has a 'g' wireless card so I went an