Passing value from plsql back to UNIX
I have a shell script which calls out to a plsql program using sqlplus command, but how do I return the values from the plsql program (a simple SELECT statement) back to the Unix script? Thanks.
James
Create one UNIX script
eg :- C2_ATG_Insert.sh
#!/usr/bin/ksh
#Variables to store the values
count=0
Count_ILX_EXCH=0
Count_ILX_CBOE_SERIES=0
Count_ILX_UNDLY_INST=0
Count_STOCK_TIPS=0
Count_TIPSSUM=0
# Block to check whether date is passed as a parameter
if (($# != 1))
then
echo "Usage: C2_ATG_Insert.sh dd-mon-yy"
exit 1
fi
# Assign the trade date to a variable
Temp_Date=$1
# Call the sql, Count_Temp.sql with date as parameter
sqlplus usernam/password@Database_Name @Counts_Temp.sql $Temp_Date
# remove the blank lines
sed '/^$/d' Counts_Temp.lst > Counts_C2ATG.lst
# Store variables from the spooled file which gets generated in Count_Temp.sql into variables defined
while read myline
do
count=$(($count + 1))
case $count in
1) Count_ILX_EXCH=$myline ;;
2) Count_ILX_CBOE_SERIES=$myline ;;
3) Count_ILX_UNDLY_INST=$myline ;;
4) Count_STOCK_TIPS=$myline ;;
5) Count_TIPSSUM=$myline ;;
esac
done < Counts_C2ATG.lst
echo "ILX_EXCH Count $Count_ILX_EXCH"
echo "ILX_CBOE_SERIES Count $Count_ILX_CBOE_SERIES"
echo "LX_UNDLY_INST Count $Count_ILX_UNDLY_INST"
echo "STOCK_TIPS Count $Count_STOCK_TIPS"
echo "TIPSSUM Count $Count_TIPSSUM"
if [ $Count_ILX_EXCH -eq 0 ] || [ $Count_ILX_CBOE_SERIES -eq 0 ] || [ $Count_ILX_UNDLY_INST -eq 0 ] || [ $Count_STOCK_TIPS -eq 0 ] || [ $Count_TIPSSUM -eq 0 ]
then
echo "*********** Count in one of the tables is Zero *****************"
exit 1
fi
Create the SQL File eg Count_Temp.sql
SET heading off
SET VERIFY OFF
SET PAUSE OFF
SET ECHO OFF
SET TIMING OFF
spool Counts_Temp.lst;
select count(*) from ILX_EXCH where trade_date= '&&1'
UNION ALL
select count(*) from ILX_NONCBOE_SERIES where trade_date= '&&1'
UNION ALL
select count(*) from ILX_UNDLY_INST where trade_date = '&&1'
UNION ALL
select count(*) from STOCK_TIPS where trade_date = '&&1'
UNION ALL
select count(*) from TIPSSUM where trade_date ='&&1
spool off;
exit;
Do reply in case you are unable to undertand any part of the scripts
Similar Messages
-
Script fails when passing values from pl/sql to unix variable
Script fails when passing values from pl/sql to unix variable
Dear All,
I am Automating STATSPACK reporting by modifying the sprepins.sql script.
Using DBMS_JOB I take the snap of the database and at the end of the day the cron job creates the statspack report and emails it to me.
I am storing the snapshot ids in the database and when running the report picking up the recent ids(begin snap and end snap).
From the sprepins.sql script
variable bid number;
variable eid number;
begin
select begin_snap into :bid from db_snap;
select end_snap into :eid from db_snap;
end;
This fails with the following error:
DB Name DB Id Instance Inst Num Release Cluster Host
RDMDEVL 3576140228 RDMDEVL 1 9.2.0.4.0 NO ibm-rdm
:ela := ;
ERROR at line 4:
ORA-06550: line 4, column 17:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
( - + case mod new not null <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
count current exists max min prior sql stddev sum variance
execute forall merge time timestamp interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL string> pipe
The symbol "null" was substituted for ";" to continue.
ORA-06550: line 6, column 16:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
( - + case mod new not null <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
count current exists max min prior sql stddev su
But when I change the select statements below the report runs successfully.
variable bid number;
variable eid number;
begin
select '46' into :bid from db_snap;
select '47' into :eid from db_snap;
end;
Even changing the select statements to:
select TO_CHAR(begin_snap) into :bid from db_snap;
select TO_CHAR(end_snap) into :eid from db_snap;
Does not help.
Please Help.
TIA,
NischalHi,
could it be the begin_ and end_ Colums of your query?
Seems SQL*PLUS hs parsing problems?
try to fetch another column from that table
and see if the error raises again.
Karl -
How can I pass value from sql query to unix script
I am new to oracle/unix.
I want to write a simple script to find max date from a table and then pass date into a variable in a korn shell script.
sql is select max(date) from table;
how can I pass that value in unix shell as a variable. ThanksI use to code like this.
Enjoy Scripting.
cmd.sql
select sysdate from dual;
exit
db.sh
#! /usr/bin/ksh
. ~oracle/.orapaths
dbdate=$(sqlplus -S user/pwd@servicename @cmd.sql)
echo $dbdate
Run shell scripts
./db.sh
SYSDATE --------- 19-JAN-07 -
Java Thread - difficulty while passing value from parent to child thread
Hi All,
I am calling a java program from a unix script .
My oblectives are
1)to pass value from scripts to main java class
2)main class should create a child thread and pass data to child and should return control back to script
3)child thread should run independtly of parent
The calling unix script is part of process and hence should return control back to its calling script immediately.
Findings
1)Without passing data thru setter getter /constructor method to child thread my objectives are met
2)When I pass the data from parent thread to child thread calling unix scripts wait till child thread finishesh its working
call.scr
java Main <list of Arguments>
Main.java
public class Main
public static void main(String args[]) throws Exception
String data2="Z";
String data1=null;
for(int i=0;i<args.length;i++)
data2=data2+","+args;
data1=data2;
Child cu=new Child();
cu.setData(data1);
data2=null;
data1=null;
cu.start();
Child.javaclass Child extends Thread
public String data;
void setData(String data)
this.data=data;
public void run()
----------> processing on data
I think due to passing of data from parent thread to child thread (Inter thread data communication/Inter process communication)
the threads are not working as desired.
Plz anybody can suggest something.....
Thanx.aschin,
You seem to be confusing Java Threads with Operating System Processes.
If you want you're java program to run in the unix background then you'll need to run it in the unix background. Java (being o/s agnostistic) doesn't provide process manipulation functionality (which would include the ability to throw itself into the background, as a C program can) in the standard API, and it's hard to imagine any third party producing anything as low level as a process controler... so yeah, just start the java program in the background... and you'll need to workout some interprocess communication protocol... named pipes have worked well for me in the past, as they doesn't suffer from the quit same performance issues as real disk files.
Good luck. Keith. -
Passing message from plsql code to page
Hello Everybody,
I am trying to pass a 'success message' from plsql code which runs on page processing to the page. This plsql is a insert statement and if statement runs successfully (on submit) then I want to show a success message on the page after summit.
Your comment and help would be appreciated.
Thanks,
Raj.Thank you Tony.
Stored Procedure which I am calling on the page is running in database. So if this procedure runs successfully(or vice versa), how I would know?? Is there a way to pass value from database stored procedure to it's calling page?
Following is procedure:
procedure load_stateday_result(key_loc ATM_STATE_DAY_INSP.KEY_LOCATION%type) is
temp_key_insp ATM_INSPECTION.KEY_ATM_INSPECTION%type;
temp_key_location number(8);
temp_dte_schedule date;
begin
temp_key_location := key_loc;
select key_atm_inspection,dte_schedule into temp_key_insp, temp_dte_schedule
from atm_inspection where
key_location = temp_key_location and exam_type = 'D' and exam_yr = to_char(sysdate,'yyyy');
insert into atm_state_day_insp(key_atm_state_day_insp,key_location,key_atm_insp,scheduled_dte)
values(state_day_insp_seq.nextval,key_loc,temp_key_insp,temp_dte_schedule);
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Error :'|| SQLCODE||':'||SQLERRM);
--ROLLBACK;
RAISE;
end load_stateday_result;
Will appreciate your reply.
Thanks,
Raj, NY -
Passing value from JavaScript window to form
Hi,
Coul'd You help me?
I have a test form. I open new JavaScript window from this form. I generate list of authors in this window by the procedure show_list. I want to pass value from JavaScript window back to test form, but
the command "window.opener.document.forms[idx_form].elements[idx_fld].value = val;"
don't pass value to test form. Where is mistake?
Thanks Vaclav
-------------- test form --------------
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=windows-1250">
<TITLE>Edit</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!-- Comment out script for old browsers
function get_list(frm, fld)
var idx_form, idx_fld;
idx_form = get_idx_form(frm);
idx_fld = get_idx_field(idx_form, fld);
var w = open ("http://vasekora/pls/portal309/ahs.RD_CISEL.SHOW_LIST" + "?startPg=1" + "&master_fld=" + "ID_AUTHOR" + "&slave_fld=" + "NAME" + "&ownr=" + "REDAKCE" + "&tbl_name=" + "AUTHORS" + "&cmd_qry=" +"" + "&idx_form=" + idx_form + "&idx_fld=" + idx_fld,"wn_Authors","width=500,height=600,resizable=yes,menubar=yes, location=yes");
if (w.opener == null)
w.opener = self;
w.focus();
function get_idx_form(p_form_name)
var v_index, v_full_name, v_return;
for(v_index=0; v_index < document.forms.length; v_index++)
v_return = -1;
v_full_name = document.forms[v_index].name.split(".");
if (v_full_name == p_form_name)
v_return = v_index;
break;
return v_return;
function get_idx_field(idx_form, field_name)
var v_index, v_full_name, v_return;
for(v_index=0; v_index < document.forms[idx_form].length; v_index++)
v_return = -1;
v_full_name = document.forms[idx_form].elements[v_index].name.split(".");
if (v_full_name == field_name)
v_return = v_index;
break;
return v_return;
//-->
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="f_aut_new" ACTION="javascript:testclose()" METHOD=POST TARGET="_blank">
<INPUT TYPE="text" NAME="id_aut">
<IMG SRC="images/list.gif" alt="Seznam" border="0" align=bottom><BR><BR>
<INPUT TYPE="submit" VALUE="Save">
<INPUT TYPE="reset" VALUE="Cancel">
</FORM>
</BODY>
</HTML>
-------------------- end test form --------------
procedure show_list
startPg integer,
master_fld varchar2,
show_fld varchar2,
ownr varchar2,
tbl_name varchar2,
cmd_qry varchar2,
idx_form integer,
idx_fld integer
is
TYPE cur_typ IS REF CURSOR;
c cur_typ;
c_cnt cur_typ;
i integer;
pg rd_types.pages_t;
odkaz varchar2(4000);
bk_url varchar2(4000);
s1 varchar2(4000);
var_mfld integer;
var_sfld varchar2(8000);
bl boolean;
var_cmd varchar2(2000);
begin
htp.HTMLOPEN;
htp.HEADOPEN;
htp.p('<SCRIPT LANGUAGE="JavaScript">');
htp.p('<!-- Comment out script for old browsers');
htp.p('function Close_List(val, idx_form, idx_fld)');
htp.p('{');
htp.p('window.opener.document.forms[idx_form].elements[idx_fld].value = val;');
htp.p('self.close();');
htp.p('}');
htp.p('//-->');
htp.p('</SCRIPT>');
htp.HEADCLOSE;
htp.BODYOPEN;
if cmd_qry is null then
s1 := 'SELECT a.'||master_fld||', a.'||show_fld||' FROM '||ownr||'.'||tbl_Name||
' a ORDER BY a.'||show_fld;
else
var_cmd := UPPER(cmd_qry);
s1 := 'SELECT a.'||master_fld||', a.'||show_fld||' FROM '||ownr||'.'||tbl_Name||
' a WHERE UPPER(a.'||show_fld||') LIKE ''%'||var_cmd||'%'' ORDER BY a.'||show_fld;
end if;
i := 1;
OPEN c FOR s1;
LOOP
FETCH c INTO var_mfld, var_sfld;
IF c%FOUND THEN
IF i >= pg.StartRec AND i <= pg.EndRec THEN
odkaz :=''||var_sfld||'';
htp.p(i||': '||odkaz||' ('||var_mfld||')<BR>');
ELSE
IF i > pg.EndRec THEN
EXIT;
END IF;
END IF;
ELSE
EXIT;
END IF;
i := i + 1;
END LOOP;
htp.p('<BR><B><INPUT TYPE=BUTTON ONCLICK="javascript:self.close();" VALUE="Close"></B><BR><BR>');
CLOSE c;
htp.BODYCLOSE;
htp.HTMLCLOSE;
end;If this makes any difference: Instead of using "var w = open..." try "var w = window.open..."
-
Display a value from PLSQL code to screen
How to display a value from PLSQL code to screen without loading or refreshing the page?
im using ajax to call the javascript to run the PLSQL code. i desire to view some value in the screen when i run the PLSQL code
skud.anything that you print from the PLSQL code(using htp.p, htp.prn etc) with will available in Javascript as the server response. You can parse that string it in javascript and display it on screen or modify page items or create dynamic items/elements using those values.
A minimal example
Ondemand PLSQL process : TEST_PROCESS
begin
htp.prn('hello world');
end;Javascript Code
var ajaxRequest = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=TEST_PROCESS',0);
ajaxResult = ajaxRequest.get();
alert(ajaxResult);Will display an alert message "hello world"
You can construct the string in JSON/XML format in PLSQL to pass complex data structures(or multiple values) or even HTML code, then do the required processing in Javascript, for example extract out item values from it and set items, convert the JSON array to a select list item in the page or put the HTML code with a div element in the page. -
Passing values from a FORM to another FORM
Hi,
I have to pass values from FORM "A" to FORM "B". What is the best way to do this?\
Can I use a GLOBAL variable?
Thanks,
Marc.I think he meant the global namespace.
You set a :global_your_name_here to a value and that value is available in your entire application. See the help file section on the global namespace for more information.
Forms parameters are parameters that you form picks up from the outside when it starts. The calling entity must supply them in the URL or they will be set to null. You set them up in the object navigator in the Parameters node. -
Passing values from javascript in pop up window to parent jsp
Hi
I am trying to pass values from a pop up window to the main window that popped this child window , with the idea to have the parent window refresh itself with value from pop up window.But the values are not going through.I do a request on the hidden variable but when the parent
jsp refreshes , the variable is still null...
The following is the code i have .
Parent jsp:a.jsp
<form name='summary'>
<input type=hidden name=customerid value="">
<input type="button" class="textButton" name="action" value="customerlist" onClick="javascript:openWin('b.jsp','800','350')">
<script>
function openWin(loc, w, h) {
var newWin = window.openloc,"HTML",'dependent=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=' + w + ',height=' + h);
newWin.window.focus();
</SCRIPT>
<%
String optionVal = request.getParameter("customerid");%>
var user = "<%= optionVal%>";
</form>
child jsp- b.jsp (pop up window)
<script>
function closer(){
var val = document.formname.id.selected.value;
window.opener.document.summary.customerid.value = val;
window.opener.location.reload();
</script>
<form name = formname>
<input type="text" name="id" value = ''>
<input type="button" class="textButton" value="select"
onClick="closer();window.close();">
</form>
Any ideas on what i am missing
Thanks
Arnuse window.opener.document.forms[0].filedname.value = 'value u need to set'
-
Passing Value from Crystal Report (special function) to Business View parameter
Friends,
Í have a scenario where i need to pass value from Crystal Report to a Business view's parameter.
Eg : CurrentCEUsername (func in crystal report)-- gives login user which i should pass to parameter in a Business view (used in the same report).
Will be able to explain more if required.
Thanks in Advance,
BharathI guess you got the picture wrong. User_id is not a report_level parameter .
In Data Foundation, below query is used..
select Acc_Number, Account_Group,User_id from Accounts where user_id={?User_id}
where in {?User_id} is the BV parameter...
The Filter was a solution. But it takes long time to Query all the data from DB and then filter at BV level.
How do i pass the CurrentCEUsername to {?User_id}
Value should ve CurrentCEusername always. so that query will be
select Acc_Number, Account_Group,User_id from Accounts where user_id=CurrentCEusername
It will restrict the data pulled from DB to BV .. right? -
Anyone knows how to pass value from Java to Perl program?
Did you write the perl program? Can you change it? Or are you trying to interface to something that already exists? This will limit your options, of course.
Anyway the first option is simple. The java program does this:
System.out.println("This is a line of input.");The perl program does this:
while(<>)and in that block, $_ is assigned to each line of input.
Then you can invoke both like this:
$ java MyJavaProgram | perl MyPerlProgram.pl -
Pass Value from Excel to custom program
Hello,
I want to pass value from Excel to Custom Program being called in the Custom Integrator and i am using the Import in the Importer section but it is not getting passed.
Please advise and i am on R12.1.3.
ThanksPl do not post duplicates - Concurrent Program Parameter
-
How can I pass values from one node to another
Give a standard and efficient way to pass values from child to parent
hai Prathap
You can use the custom event for passing values from child to parent -
Re: Help needed in passing values from workflow to Approve Forms
Dear Experts,
how do I pass values from a workflow to a step (Form) - approve form?
I am using a customized table structure as my data source (FORMCONTAINERELEMENT) but am stuck on how to access the data when i get to to the screen painter's flow logic... What am i missing? Can you give me a step by step example. the ones i see on the net are input fields that update the screen... nothing that shows value being passed from the outside.
I need to pass an exisitng value in the workflow into the form for approval of the the assigned agent.
Please help!!
Thank you.Hello !
Create a method just before the form step.This method should populate the values for the fields maintained in the form.
Pass the values populated from this method to your customized table structure (data source).In other words, you have to pass all the values to the workflow container.
To the step, pass this workflow container by binding.In the control tab of form step, you have to do the binding.
Regards,
S.Suresh -
Passing value from Webdynpro ABAP to Adobe form..
Hi experts,
In first view of web dynpro, im getting employee id as input and after clicking the create new button, an adobe form is called
to create the employee details ( in form i used the submit button and i stored the details ). so, in tat form i used the employee id as read only mode and it has to display the value which i given as input. But in tat form im not getting the value from web dynpro..
can anyone plz help me out for this..
Thanks in advance..Hi,
Try to set your values in Method->"wddomodify" of the View in which Adobe Form is present. If you want to pass values from one view to another then check this link [Passing Local Parameters between views in an ABAP Web Dynpro Application|http://wiki.sdn.sap.com/wiki/display/stage/PassingLocalParametersbetweenviewsinanABAPWebDynproApplication] or use Context declared in Component Controller.
Regards
Pradeep Goli
Maybe you are looking for
-
IPad 2 crash post iOS 6.01 update attempt
Hi, I was wondering if someone could help me restore my iPad. It’s an iPad 2 that I tried to update to iOS 6.01 yesterday. I clicked the update in general settings and then let it run in the background whilst also downloading the TED app, which I sub
-
How do I Install Adobe Flash Successfully?
I have Vista and Firefox. I've downloaded v. 11.4 several times and each one is a bad installation. Same thing with the plug-in. I have to keep it uninstalled or else I can't upload work files. But I constantly get prompted to install the damn th
-
Real quickly, I have my pdf export settings in PageMaker 7.0.1a to add .5 inches to magazine trim/document setup page size. If I place a full page ad with bleed in eps format, the resulting pdf image displays correctly within the full bleed size. But
-
Nokia unlimited music into Lumia 520
I have quite large collection of music lead using nokia music unlimited service. After moving my music into Lumia 520 with windows phone application no of the music plays on the device. If I use nokia music player to move my music it will give error
-
I'm just trying to find out how to get a replacement charging adapter. Post relates to: