How to fill a variable in the script with the sql statement
Hello
I am trying to replace the toad by SQL Developer. I would like to start a main script, which selects the database name and host name and makes this information on behalf of a spoolfile and then rolls into this spoolfile.
As a result, I am able to see when and on what database the spoolfile belongs to.
With SQL * more or Toad, I was able to make it work with:
set SKRIPTNAME = "Mainscript_Release_4.04_00".
Set serveroutput on
undefine spoolfile
column spoolfile new_value by spoolfile
SELECT ' & SKRIPTNAME' | ' _'|| ora_database_name | » _'|| LOWER (HOST_NAME) | » _'|| To_char (sysdate, 'yyyymmdd_hh24miss'): '. Newspaper ' spoolfile of v$ instance;
coil & & spoolfile
-call other scripts here
spool off
Anyone knows a solution for this in SQL Developer scripts?
Best regards, Stefan
Just use this script. It worked for me.
I made a small adjustment - something SQLDev could write, vs, I changed the default directory that will be the directory \bin that they run on.
Tags: Database
Similar Questions
-
Problem with a variable in the SQL statement variable
Hello
I try the following query.
HSTMT = DBActivateSQL (hdbc, "UserLevel SELECT FROM ClassUsers WHERE Password =" + string + "");
At this point, I get this error:
Operands of + have illegal types "pointer to char" and "pointer to char".
I tried this:
HSTMT = DBActivateSQL (hdbc, "UserLevel SELECT FROM ClassUsers WHERE Password =" + & cadena + "");
HSTMT = DBActivateSQL (hdbc, "UserLevel SELECT FROM ClassUsers WHERE Password = '" + string + "'");
Still having the same problem.
It works fine if I do this.
HSTMT = DBActivateSQL (hdbc, "SELECT UserLevel UserClass WHERE the password =" cadena' "");
Where "cadena" is treated as a string.
Any ideas?
Thank you!
The Visual Basic method to concatenate strings with the + operator does not work in C. You can use a number of ways to do this - here is just a sample:
char string [256] = "SELECT UserLevel OF ClassUsers WHERE password = ';"
HSTMT = DBActivateSQL (hdbc, strcat (string, String));
JR
-
Can we use repository variables in the SQL statement of the guest of the column?
Hi guys,.
This is the query
SELECT '-End Date '. " End year"OF"The consumer sector"WHERE ("-End Date "." ") End of year' = valueof (current_year)) or ("-End Date". "") (Year-end' = valueof (current_year) - 1).
When you use this sql prompt of criteria being of error.
Please suggest.
Thanks.SriAppreciate if you score as correct on the suggestion
Also your old messages, at least let us know your comments ;)
-
How can I leave echo in the sql worksheet developer sql?
When I generate out of the script from a sql file that is loaded into the spreadsheet sqldeveloper, the statement appears in the output pane before the results of the query. This can occur because there are substitution (for example & site) variables in the query. However, I would really for Nothing of the sql statement displayed in the results - I want to save it as an output file. Is there a way to do this? 'left echo' is not recognized as a valid command.
I know that I can export data in the results pane of query to a text as well as a csv file, etc., but I don't like how it looks - I want the data as described in the output of the script.
Here is a portion of the script... just enough to show "set echo off" and use of the user variable.
Thank you
Carol
set echo off select s.site_id SID,substr(s.site_name,1, 50) SITE, month.start_date_time, sum(decode(sd.datatype_id,111,month.value,null)) EC, sum(decode(sd.datatype_id,1217,month.value,null)) PPM, round(sum(decode(sd.datatype_id,19,month.value,decode(sd.datatype_id,93,month.value,null))),2) CFS, round(sum(decode(sd.datatype_id,1216,month.value,decode(sd.datatype_id,1218,month.value,null))),0) TOTAL_CFS, round(sum(decode(sd.datatype_id,20,month.value,decode(sd.datatype_id,1113,month.value,null))),0) AF from hdb_site s, hdb_site_datatype sd, r_month month, ref_yao_sal_flow_site_map map where map.flow_site_id = &&site
set verify off
can hide variable replacements in sqlplus and sql developer
-
How to analysis of the XML in the sql statement?
Hi friends, I have a table that contains a column of type CLOB, stores in xml format. For example, the data are like that
<Employees xmlns="http://TargetNamespace.com/read_emp"> <C1>106</C1> <C2>Harish</C2> <C3>1998-05-12</C3> <C4>HR</C4> <C5>1600</C5> <C6>10</C6> </Employees>
So how can I write the sql statement for the analysis of the data at the top
create or replace procedure parsing_xml
(
clob trans_payload
trans_dir varchar2
)
as
Start
if(trans_dir='inbound/emp')
then
insert into emp_proj
(
employee_id
last_name
hire_date
job_id
salary
department_id
)
Select t1.c1
t1.c2
t1.c3
t1.c4
t1.c5
t1.c6
from xmltable
(
XmlNamespaces ('http://TargetNamespace.com/read_emp' as 'emp').
' / ' emp:Employees by the way of xmltype (trans_payload)
columns
whole path of C1 'emp:C1. "
path of varchar2 (10) C2 'emp:C2. "
C3 varchar2 (10) path "emp:C3."
C4 varchar2 (10) path "emp:C4."
whole path of C5 "emp:C5."
C6 varchar2 (10) path 'emp:C6 '.
) t1;
end if;
commit;
end;
-
problem with bind variables in the SQL query view object
Hi all
I use JDev 11.1.2.4.0.
I have a problem with bind variables in the SQL query view object.
This is my original SQL
SELECT sum(t.TIME) , t.legertype_id FROM LEDGER t WHERE t.nctuser_id = '20022' AND to_char(t.insertdate,'YYYYMMDD') in ('20130930','20130929') group by t.legertype_id
In my view .xml object query tab, I am writing this
SELECT sum(t.TIME) , t.legertype_id FROM LEDGER t WHERE t.nctuser_id = '20022' AND to_char(t.insertdate,'YYYYMMDD') in :dddd group by t.legertype_id
Davis here is a variable of Type liaison: String, updatable and necessary.
I try to deal with Davis as ('20130930 ', ' 20130929') hoping the view object, run as my original SQL.
But failed. The view object retrieves 0 line after that I run.
Why?
Thank you! ('2original SQL0130930', '20130929') ('20130930 ', ' 20130929')
A variable binding cannot be used as this is why you must use years table. Check decompilation binary ADF: using oracle.jbo.domain.Array with ViewCriteria to see a solution.
Timo
-
Why the sql statement was extucted twice in shell script?
I tried to test the rac load balancing using the shell script depending on suse 10 + oracle 10g rac.
After run the shell script, I got the result to follow.oracle@SZDB:~> more load_balance.sh #!/bin/bash for i in {1..20} do echo $i sqlplus -S system/oracle@ORA10G <<EOF select instance_name from v\$instance; / EOF sleep 1 done exit 0
Seem that the sql statement was run twice in each loop. If you help please take a look. Thanks in advance.oracle@SZDB:~> ./load_balance.sh 1 INSTANCE_NAME ---------------- ora10g2 INSTANCE_NAME ---------------- ora10g2 2 INSTANCE_NAME ---------------- ora10g1 INSTANCE_NAME ---------------- ora10g1 3 INSTANCE_NAME ---------------- ora10g1 INSTANCE_NAME ---------------- ora10g1
RobinsonBecause you have one; and one.
-
In an interview, no one asked me a question. How the sql statement
ex: select * from emp;
I answered him as if the select statement is in the library cache then it will retrieve data from the cache, otherwise it will retrieve data from database files. On this, he asked to go. I could not years itself. Anyone like elobarate me on the analysis?SMON,
I would have preferred the official documents from Oracle, as suggested by
http://download.Oracle.com/docs/CD/E11882_01/server.112/e16508/sqllangu.htm#CHDFCAGA
Concerning
Peter -
Set the Variable in the select statement
Hello
Can we define a variable in the select statement.
Example:
Select firstname, lastname
employees;
in this simple select statement we can define x as number?select fname,lname from employees where rownum <= 30;
-
How can I pass a condition of the table in the sql statement?
For example, in the table in the COND Varchar2 column (200) there is the value ' VAR > 10'.
| COND |
|' VAR > 10' |
where VAR is the name of the table column. I would like to make statement CASE WHEN VAR > 10 AND 0... I tried with as subquery
WHEN BOX (SELECT COND FROM TABLE WHERE...) THEN 0, but it does not work.
Hello
You can do this by using dynamic SQL.
that is to say:
declare v_stm varchar2(4000); v_cond varchar2(100); v_result integer; begin select cond into v_cond from yourtable where a=1; v_stm := 'select case when '||v_cond||' then 0 ...'; -- dynamic sql execute immediate v_stm into v_result; end; /
Remember that, in general, dynamic SQL has a performance degradation that SQL static and should be avoided when possible.
Storage condition or the SQL statements in the tables is not a good practice.
Kind regards.
Alberto
-
Get the SQL statement error programmatically
Hello
error SQL in the FORMS, you can display the erroneous SQL statement pressing (shift) (Ctrl) E on the screen. Is there a way to get the text of the SQL statement in a PL/SQL function for logging purposes?
I get the error using SQLERRM, it's not a problem. But how can I get the SQL text of the statement?
Thanks and regards,
Sascha
Sascha,
You should be able to use the: SYSTEM. System LAST_QUERY variable forms.
Craig...
-
copy and paste the sql statement into sql * more
How do you paste the sql statement into sql * more... I tried the following options, get the windows interface for this sequel to the documentation below, but that did not work
http://download.Oracle.com/docs/HTML/A88829_01/ch3.htm
then I tried to create a simple .txt file with my sql statement and tried to run using @name (where name is the name of the file) and it gives me the following error SP2-0310: cannot open the file 'firstscriot.sql '.You name the file name.txt? Then you cannot start with @name, because SQL * PLUS will add the extension .sql
Try instead the @name.txt or name the file name.sql
And check if you have the correct path.
Concerning
Marcus -
the SQL statements used to create views
Hello
How can I see the full text (with table) to create a sql view:
Thank you.SQL> select text from dba_views where rownum=1; TEXT -------------------------------------------------------------------------------- select "LIB_IDX","LIB_NAME","VENDOR_NAME","PROTOCOL_NUM","VERSION_NUM","PATH_NAM
Try the following in the SQL * faster before executing the SQL statement:
SET LONG 1000
If this does not work, increase it if necessary.
-
Hi all
I just created a function that returns a TABLE;
I am grateful if some body guide me how to display the values in the table at the call of my sqlplus as function
Select * from func_avg_cost() of double;
its fine when you return a single value of work. But I'm back a table to retrieve the value from the table in the sql statement
Thank you!now, I must return two numbers function. as possible through table.
which is also possible with a simple object:
SQL> create or replace type my_number_typ as object (n1 number, n2 number) / Type created. SQL> create or replace function my_numbers (n1 number := 0, n2 number := 0) return my_number_typ as begin return my_number_typ (n1, n2); end my_numbers; / Function created. SQL> select my_numbers (2, 3) from dual / MY_NUMBERS(2,3) -------------------------------------------------- (2; 3) 1 row selected. SQL> select my_numbers (sal, deptno) my_numbers from emp where empno = 7788 / MY_NUMBERS -------------------------------------------------- (3000; 20) 1 row selected. SQL> select my_numbers (sal, deptno).n1 sal, my_numbers (sal, deptno).n2 deptno from emp where empno = 7788 / SAL DEPTNO ---------- ---------- 3000 20 1 row selected.
-
Identify the SQL statements that are executed frequently
I would like to identify SQL statements that are executed may times (e.g., > 1000 times) during an interval AWR.
I am aware of coloring a SQL_ID with exec ('...') dbms_workload_repository.add_colored_sql; but then the SQL ID must be known.
Is it also possible to do the same for the (not yet known) SQL statements that are executed > 1000 times? I think that the SQL statements that run very quickly (for example 1 s <) won't be captured automatically in a CWA even if those statements are frequently performed.
Version 11.2.0.4 on SLES11
Try this...
fixed lines 155
execs from collar to 999 999 999
Col min_etime to 999,999.99
Col max_etime to 999,999.99
Col avg_etime to 999,999.999
Col avg_lio to 999,999,999.9
Col norm_stddev to 999,999.9999
Col begin_interval_time to a30
node of col to 99999
break on plan_hash_value on startup_time skip 1
Select * from)
Select sql_id, sum (execs), min (avg_etime) min_etime, max (avg_etime) max_etime stddev_etime/min (avg_etime) norm_stddev
de)
Select sql_id, execs, plan_hash_value, avg_etime,
StdDev (avg_etime) on stddev_etime (sql_id partition)
de)
Select sql_id, plan_hash_value,.
Sum (NVL(executions_delta,0)) execs,
(sum (elapsed_time_delta) /decode (sum (nvl(executions_delta,0)), 0.1, sum (executions_delta)) / 1000000) avg_etime
-sum ((buffer_gets_delta/decode (nvl(buffer_gets_delta,0), 0.1, executions_delta))) avg_lio
DBA_HIST_SQLSTAT s, DBA_HIST_SNAPSHOT SS
where ss.snap_id = S.snap_id
and ss.instance_number = S.instance_number
and executions_delta > 0
Group of sql_id, plan_hash_value
)
)
Group of sql_id, stddev_etime
)
where norm_stddev > nvl (to_number('&min_stddev'), 2)
and max_etime > nvl (to_number('&min_etime'),.1)
order of norm_stddev
/
Maybe you are looking for
-
Satellite L350D-201 - screen keeps freezing sometimes
Hello I was wondering if someone could help, Ive had my laptop Toshiba L350D-201, a little less than 7 months and recently the screen just freezes. Judgment of the mouse and the keyboard is not the answer to all commands such as Ctrl/alt/del and the
-
Satellite L500 - wireless network adapter disappeared
Satellite L500 model PSLS0A-084002. Wireless network adapter is not listed under network adapters in the devices menu. FN does not display the wireless tab. There is no off / switch for the wireless on this laptop model. In the BIOS, the wireless LAN
-
I recently bought a new camera, good Friday, April 18, EOS600D. I'm confused by the term "Rebel T3i", the box of my camera came to has no mention of the "Rebel T3i" or not the guide. The camera was introduced as a body 'bundle' EOS600D, Canon zoom le
-
Service Pack 1 will not be updated, should I ignore?
I have an update that will not be updated for Service pack 1. Should I just ignore it? I have the Service pack 2 & 3 on my computer. I have Windows XP pro.
-
Mobile data in stamina mode problem
Hi all Mobile data continue to work, when I chose in endurance mode. It works even if extended stanby was chosen. mobile data won't stay out of this mode. How can I solve this problem? Not: Active applications in stanby is empty. My problem has been