Need a query to compile .sql from sql+
Hi All,
I need to run a .sql file from sql+plus .
So share me the query to do this.
1011786 wrote:
Hi All,
I need to run a .sql file from sql+plus .
So share me the query to do this.
Hi
SQL> select dummy,sysdate from dual;
D SYSDATE
X 11-JUN-2013
SQL> save test_dual.sql
Created file test_dual.sql
SQL> @test_dual.sql
D SYSDATE
X 11-JUN-2013
SQL>
Hope this helps
Regards,
Achyut Kotekal
Similar Messages
-
Need a Query for getting ItemCost from PO Vendor wise
Hi,Experts We are not maintain different price list for some particular items , We raised the PO for Multiple vendors with differnt price for the same material. We need a query to find the Item cost with Various Vendor .
I need the query in the following format
Po Number, Vendor Name,Item Name, Item Description,Qty, Price,Tax.
Thanks
KamalHi,
Check this query which looks for the Item doctype Purchase Order and brings the data accordingly :
select t0.docnum as 'PO Number', t0.CardName as 'Vendor name', t1.itemcode as 'Item Name',
t1.Dscription as 'Item Description', t1.quantity as 'QTY', t1.Price as 'Price',
t1.vatsum as 'Tax Amount'
from OPOR t0 inner join POR1 t1 on t0.docentry = t1.docentry
where t0.doctype ='I'
Group by t1.itemcode, t1.Dscription, t0.docnum,
t0.cardname, t1.quantity, t1.Price, t1.vatsum
Order by t1.Itemcode
Check if it helps.
Kind Regards,
Jitin
SAP Business One Forum Team -
Need a query to retrive reocrds from a blob data type!
Hi,
I need a sql query to check in a cloumn which is a blob data type ,where the column stores the XML values and the query should check a particular value in the column if value is there it shud return with yes or no.Thanks for your reply...
Let me clearly explain my need.. for instance a table xyz and in that we have 5 columns but based on some conditions on 3 columns i need to retrive the records..like..
select * from xyz where a=** and b=** and c=***; here i need to pass the values of a,b and c while runtime only and not as static values and also i need to return with a message like records found,not found based on the condition where the particular record for the column C is there or not there. -
Need a Query to update table from another table.
I have two tables Table A and Table B , till now in table “A”. I have a column which consist of IDs and duplicate IDs( which are basically formed by Original Ids) , I have another table i.e. table “B” , which gives a mapping between original ids and duplicate Ids
TABLE A:
ID/DUPLICATEID NAME
1 Rahul
1_CAD Pawan
2 Nikhil
3 TOM
3_CAD Ravi
3_MQ Puneet
TABLE B:
ORIGINALID DUPLICATEID
1 1_CAD
3 3_CAD
3 3_MQ
Now I want to have another column in Table “A” , which will give me the mapping between the original Id and duplicate Id as shown in updated table “A”.
UPDATED TABLE A:
ID/DUPLICATEID NAME ORIGINAL_ID
1 Rahul
1_CAD Pawan
2 Nikhil
3 TOM
3_CAD Ravi
3_MQ Puneet
Now I want to write a Query in which I can update this column (ORIGINAL_ID) of Table “A”, from the table B(basically want to update mulitple rows using single query), because table B already has this mapping. Can any one help me in this. I am basically a Java guy , so I don’t know much about it. I hope to get a positive response from you people, Thanks in advance!Here you go...
<pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%">
<code>
SQL> CREATE TABLE A (ID VARCHAR2(10), NAME VARCHAR2(10), NEW_ID VARCHAR2(10));
Table created.
SQL> INSERT INTO A VALUES ('1', 'Rahul', '');
1 row created.
SQL> INSERT INTO A VALUES ('1_CAD', 'Pawan', '');
1 row created.
SQL> INSERT INTO A VALUES ('2', 'Nikhil', '');
1 row created.
SQL> INSERT INTO A VALUES ('3', 'TOM', '');
1 row created.
SQL> INSERT INTO A VALUES ('3_CAD', 'Ravi', '');
1 row created.
SQL> INSERT INTO A VALUES ('3_MQ', 'Puneet', '');
1 row created.
SQL> CREATE TABLE B (ID VARCHAR2(10), NAME VARCHAR2(10));
Table created.
SQL> INSERT INTO B VALUES ('1', '1_CAD');
1 row created.
SQL> INSERT INTO B VALUES ('3', '3_CAD');
1 row created.
SQL> INSERT INTO B VALUES ('3', '3_MQ');
1 row created.
SQL> COMMIT;
Commit complete.
SQL> UPDATE A
2 SET NEW_ID = NVL((SELECT B.ID FROM B WHERE A.ID = B.NAME),A.ID)
3 /
6 rows updated.
SQL> COMMIT;
Commit complete.
SQL> SELECT * FROM A;
ID NAME NEW_ID
1 Rahul 1
1_CAD Pawan 1
2 Nikhil 2
3 TOM 3
3_CAD Ravi 3
3_MQ Puneet 3
6 rows selected.
</code></pre>
Note: While asking question do give us DML/DDL script. It will make peoples life better.
Karthick.
http://www.karthickarp.blogspot.com/ -
Re: How to converting from PL/SQL query to T-SQL query
How to converting from PL/SQL query to T-SQL query... Its Urgent
Download the
SQL Server Migration Assistant for Oracle. It will convert whole Oracle databases, or single queries or PL/SQL stored procedures.
With caution that If your database is using Collation which is case sensitive SSMA will not work.SSMA doesnt guarantees 100% for conversion of Queries/stored proc /database if it fails to do so for some queries you will have to do it manually.
But you can try
Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers -
SQL query to fetch records from 26 onwards
Want to know SQL query to fetch records from 26 onwards.
See the fifth entry on the FAQ page:
Re: How to attach a java bean in forms6i -
I need a query that returns the average amount of characters for a text colum in MS SQL.
I need a query that returns the average amount of characters
for a text colum in MS SQL.
Could someone show me how?Sorted, i need the
DATALENGTH
function -
How will write SQL query to fetch data from each Sub-partition..
Hi All,
Anyone does have any idea about How to write SQL query to fetch data from Sub-partition.
Actually i have one table having composite paritition(Range+list)
Now if i want to fetch data from main partition(Range) the query will be
SELECT * FROM emp PARTITION(q1_2005);
Now i want to fetch data at sub-partition level(List) .But i am not able to get any SQL query for that.
Pls help me to sort out.
Thanks in Advance.
AnwarSELECT * FROM emp SUBPARTITION(sp1);
-
Sql query to get numbers from 0 to 99
How can we write an sql query to get values from 0 to 99 ... this shouldn't be coming from any table
Bawer wrote:
Result: (quickly replied by oracle)
SQL-Error: ORA-30009 (Not enough memory for connect by - 1GB reserved for oracle on VirtualBox)Oracle version? Takes about 8 seconds on my:
SQL> select * from v$version
2 /
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
Elapsed: 00:00:00.14
SQL> select count(*) from (
2 SELECT LEVEL - 1
3 FROM DUAL
4 CONNECT BY LEVEL <= 10000000
5 )
6 /
COUNT(*)
10000000
Elapsed: 00:00:07.76
SQL> SY. -
SQL HELP NEEDED IN QUERY FOR COUNT
I Have this Query
SUM (CASE WHEN b.VET_OTHR_ELIG_CDE IN ('02', '03', '04') THEN 1 END) AS VET_YES,
SUM (CASE WHEN b.VET_OTHR_ELIG_CDE = '01' THEN 1 END) VET_NO, COUNT (E.ACTV_CDE) AS CNT_ACTV_CDE
Now i need to Add two more columns from the same Query Showing the count of VET_YES and VET_NO i.e count of TOTAL Veterans And TOTAL Non Veterans
those two columns i will be using as summary columns in my report.The bolded columns are those which i need to show the total column .anyone please help in this issue ..
ACTV_DESC ACTV_CDE VET_YES VET_NO CNT_ACTV_CDE
INACT DUE 13993 2 1 3
NOW I NEED TO MAKE IT LIKE THIS
ACTV_DESC ACTV_CDE VET_YES VET_NO CNT_VET CNT_NONVET CNT_ACTV_CDE (This is the total count)
INACT DUE 13993 2 1 2 1 3
Thanks in Advance,
Dev Kishore.T
Message was edited by:
Dev Kishore
Message was edited by:
Dev KishoreCheck this link.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14223/aggreg.htm#sthref1612
Regards
Raj -
Hi All!
I want to write following type of query in PL/SQL
How can I write one which will work.
<B>
SELECT count(1) INTO v_count2 from TRJ_TRAN_REJ_T a and PEU_PUR_ENRL_UNT_T b
where a.TRJ_CVRG_PER_DATE IN (b.PEU_EFF_DATE AND b.PEU_END_DATE) AND
a.purik = b.purik AND a.peuik = b.peuik
<B>
Above query is not working correctly. Any changes?? DATE stored in database is like 01/01/2001
v_count2 is NUMBER variable declared in PL?SQL.
SAYou don't need to use a PL/SQL, a simple SQL will suffice. I guess you could write it as a function?
I think your SQL was wrong so I took the liberty of fixing it for you. You seperate tables with commas in a FROM clause, not AND.
Anyway, on the lines of a SQL Statement you can do the following.
SELECT count(1) AS mycount
FROM TRJ_TRAN_REJ_T a,
PEU_PUR_ENRL_UNT_T b
WHERE a.TRJ_CVRG_PER_DATE IN (b.PEU_EFF_DATE AND b.PEU_END_DATE)
AND a.purik = b.purik
AND a.peuik = b.peuik
Connection conn = DriverManager.getConnection(URL, username, password);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery( your sql);
while ( rs.next() )
int mycount = rs.getInt("mycount");
close stuff down here -
Avoid Distributed query in PL/SQL cursor code
Hi,
I have to avoid a distributed qry in my cursor code in PL/SQL.
The query follows like this,
cursor c1
is
select a.test,b.test1,a.test2
from apple a,
[email protected] b,
bat c
where a.listid = b.listid
and a.list_name = c.list_name;
Now i need to split the above cursor into two .
(1)I need to query appl and bat which is from local database into one and
(2)Have to do something for the value from [email protected] is stored in a temp. table or PL/SQL table.So that ,i can use the PL/SQL table or temp table in my join in cursor ,instead of having a distributed query.
By doing so,will the performance hit badly ?
[Note: Imagine this scenario is taking place in Oracle 11i Apps]
Regards,
Prasanna Natarajan,
Oracle ERP Tech Team.[url http://groups.google.de/group/comp.databases.oracle.server/browse_frm/thread/df893cf9be9b2451/54f9cf0e937d7158?hl=de&tvc=1&q=%22Beautified%22+code+runs+slower#54f9cf0e937d7158]Recently somebody complained about slow performance after code was beatified in PL SQL Developer, after recompilation without flag "Add Debug Information" it run faster...
(just a guess)
Best regards
Maxim -
Error in compiling SQL Expression
In the [Error in SQL Expression; thread, Kurt Reinhardt wrote "Please note, a SQL Expression can only return a single, distinct value per each record in the main recordset.", I tried this where my main Record Selection's SQL query is:
{GLF_LDG_ACC_TRANS.ldg_name} = {@&CH_LDG_GL_ACT_CURR} and
{GLF_LDG_ACC_TRANS.period} = {@&CH_PERIOD_GL_CURR} and
{GLF_LDG_ACC_TRANS.ACCNBRI} "99991103" and
{GLF_LDG_ACC_TRANS.DOC_REF1} "{%SundryCreditors}" and
{GLF_LDG_ACC_TRANS.DOC_TYPE} = "$APINVCE"
My SQL Expression %SundryCreditors is:
select doc_ref1
from glf_ldg_acc_trans
where ldg_name = 'APLED09'
and period = "GLF_LDG_ACC_TRANS"."PERIOD"
and doc_ref1 = "GLF_LDG_ACC_TRANS"."DOC_REF1"
and accnbri like 'SUNDRY%'
which essentially queries the same table as the main recordset using the same key fields, and returns one row only. However, when I click on the Check button in the Formula Workshop window, I get the error message "Error in compiling SQL Expression : Database Connection Error: '42000:MicrosoftODBC SQL Server DriverSQL ServerIncorrect syntax near the keyword 'select'. Database Vendor Code: 156 '".
Do you know what is my issue?If you know what you're doing, you can add a full select statement into a SQL Expression... And Kurt is correct when he says that it may only return a single row of info. Don is also correct when he says that this not what SQL commands are designed for.
Here's what's happening...
When you link your tables in the Database Expert and drop fields onto the design surface (and optionally, add criteria to the Select Expert), CR builds out a SQL statement that can is to be sent out to the db server so that the data can be returned. You can view this SQL by going to Database > Show SQL Query...
When you add a SQL Expression, CR inserts it into the SQL Query as another data column. This is typically done to take advantage of functions that are available in the data base but not in CR.
A few crafty individuals, like Kurt, have figured out that you can in fact inset a full SELECT query into a SQL Expression and it will be inserted into the CR generated querie's SELECT list as a sub-query.
Bear in mind 2 things... #1) You have to be familiar with SQL syntax, namely you have to know the proper syntax for using sub-queries in a SELECT list in your data base. #2) CR doesn't officially support is behavior and they won't offer you any help if the current functionality is removed in later versions.
HTH,
Jason -
InterMedia Text Query in Dynamic SQL
I have a query using score and contains interMedia operators that runs without problem from the SQL*Plus command line, but generates a "ORA-01858: a non-numeric character was found where a numeric was expected" error when run via dynamic sql.
The query runs something like this:
select
score(1),
score(2),
a.field1,
b.field2
from
a,
b,
where
b.id (+)= a.id and
b.name (+)= 'test' and
((contains(a.content, 'query', 1) +
(contains(b.valud, 'query', 2)) > 0
I'm trying to avoid an OR clause by adding the two contains clauses together. Could this error be caused by the outer join on table b? If so, why does it run without problems from SQLPlus?
nullThanks for the help.
Can you give me an example of how I have to specify the url in the database? For my intranet websites, I was able to use the foln. two formats http://host1/asptest/index.html (and)
URL:http://scott:tiger@host1:80/asptest/index.html
where host1 is the name of the host and 80, the port number.
I need to be able to access the oracle website(http://www.oracle.com/index.html) and run the foln. query,
SELECT id, url FROM test WHERE CONTAINS(url, 'Education')>0;
I tried setting the HTTP_PROXY attribute of the URL_DATASTORE, and specified the url as http://www.oracle.com/index.html in the database, but that didn't seem to help.
Thanks.
null -
Crosstab query using pure SQL only
Hi all,
Found a lot of threads on crosstab, but none seems to address what I need. I need to perform crosstab query using pure SQL only & the number of columns are dynamic. From a query, I obtained the below table:
Name Date Amount
Alex 2005-06-10 1000
Alex 2005-06-20 1000
Alex 2005-07-10 1000
Alex 2005-07-20 1000
Alex 2005-08-10 1000
Alex 2005-08-20 1000
John 2005-06-10 2000
John 2005-06-20 2000
John 2005-07-10 2000
John 2005-07-20 2000
John 2005-08-10 2000
John 2005-08-20 2000
And I need to transform it into:
Name 06-2005 07-2005 08-2005
Alex 2000 2000 2000
John 4000 4000 4000
Reason for the columns being dynamic is because they'll be a limit on the date ranges to select the data from. I'd have a lower & upper bound date say June-2005 to August-2005, which explains how I got the data from the above table.
Please advise.
Thanks!Hi,
I couldn't resist the intellectual challenge of a pure SQL solution for a pivot table with a dynamic number of columns. As Laurent pointed out, a SQL query can only have a fixed number of columns. You can fake a dynamic number of columns, though, by selecting a single column containing data at fixed positions.
<br>
<br>
If it were me, I'd use a PL/SQL solution, but if you must have a pure SQL solution, here is an admittedly gruesome one. It shows the sum of all EMP salaries per department over a date range defined by start and end date parameters (which I've hardcoded for simplicity). Perhaps some of the techniques demonstrated may help you in your situation.
<br>
<br>
set echo off
set heading on
set linesize 100
<br>
select version from v$instance ;
<br>
set heading off
<br>
column sort_order noprint
column sal_sums format a80
<br>
select -- header row
1 as sort_order,
'DEPTNO' as DEPTNO ,
sys_connect_by_path
( rpad
( to_char(month_column),
10
' | '
) as sal_sums
from
select
add_months( first_month, level - 1 ) as month_column
from
( select
date '1981-01-01' as first_month,
date '1981-03-01' as last_month,
months_between( date '1981-03-01', date '1981-01-01' ) + 1 total_months
from dual
connect by level < total_months + 1
) months
where
connect_by_isleaf = 1
connect by
month_column = add_months( prior month_column, 1 )
start with
month_column = date '1981-01-01'
union all
select -- data rows
2 as sort_order,
deptno,
sys_connect_by_path( sum_sal, ' | ' ) sal_sums
from
select
dept_months.deptno,
dept_months.month_column,
rpad( to_char( nvl( sum( emp.sal ), 0 ) ), 10 ) sum_sal
from
select
dept.deptno,
reporting_months.month_column
from
dept,
( select
add_months( first_month, level - 1 ) as month_column
from
( select
date '1981-01-01' as first_month,
date '1981-03-01' as last_month,
months_between( date '1981-03-01', date '1981-01-01' ) + 1 total_months
from
dual
connect by level < total_months + 1
) reporting_months
) dept_months,
emp
where
dept_months.deptno = emp.deptno (+) and
dept_months.month_column = trunc( emp.hiredate (+), 'MONTH' )
group by
dept_months.deptno,
dept_months.month_column
) dept_months_sal
where
month_column = date '1981-03-01'
connect by
deptno = prior deptno and
month_column = add_months( prior month_column, 1 )
start with
month_column = date '1981-01-01'
order by
1, 2
<br>
VERSION
10.1.0.3.0
<br>
DEPTNO | 81-01-01 | 81-02-01 | 81-03-01
10 | 0 | 0 | 0
20 | 0 | 0 | 0
30 | 0 | 2850 | 0
40 | 0 | 0 | 0
<br>
Now, if we substitute '1981-03-01' with '1981-06-01', we see 7 columns instead of 4
<br>
DEPTNO | 81-01-01 | 81-02-01 | 81-03-01 | 81-04-01 | 81-05-01 | 81-06-01
10 | 0 | 0 | 0 | 0 | 0 | 2450
20 | 0 | 0 | 0 | 2975 | 0 | 0
30 | 0 | 2850 | 0 | 0 | 2850 | 0
40 | 0 | 0 | 0 | 0 | 0 | 0
<br>To understand the solution, start by running the innermost subquery by itself and then work your way outward.
Maybe you are looking for
-
I would like to set up a media acc't for my family of four to listen to our music library and view all of our photo's. Then I would like to delete Itunes from my personal acc't. I have been able to establish a media acc't for all family member's an
-
Downloaded itunes 11.1.3 on my macbook pro and now my itunes store isn't working
Hi, I have recently upgraded to the new itunes software 11.1.3 on my 2010 macbook pro everything works fine except the itunes store. When I click to go into the itunes store and click music or movies etc it says "accessing music store" and looks like
-
I am hoping to connect my Cube to my macbook Pro via firewire
Hi All, I am hoping to connect my G4 Cube to my Macbook Pro via firewire. The cube has Firewire 400 and the macbook Pro had Firewire 800. Can anyone advise if the item below will be suitable? I have not got a DVD Drive with the cube so I am hoping to
-
Search feature in outlook only returning "no results" all of a sudden. Why?
I use outlook for my mail. all of a sudden, the search feature just returns a "no results" solution. Any ideas why?
-
Dear All, Windows 7 Ultimate Oracle 11g R2 I have problem with EM, it doesn't work. I tried all possible things to solve it by Renaming oc4j folder,recreating repository and changing TZ and .... etc and still doesn't work there is one more possible w