Select query need result
I have table T_PROCESS ,here there are contains 2 columns...
Process_flag
Process_type
1
END DATE CHANGE:PLAN ID CHANGE
1
PLAN ID CHANGE
1
MENU OPTION INSERT
1
END DATE CHANGE:PLAN ID CHANGE:MENU OPTION INSERT
1
END DATE CHANGE:PLAN ID CHANGE:MENU OPTION CHANGE
1
PLAN ID CHANGE:MENU OPTION INSERT
My requirement is ,need report only contain PLAN ID CHANGE or MENU OPTION INSERT
need out put only
Process_type
Process_type
1
PLAN ID CHANGE
1
MENU OPTION INSERT
1
PLAN ID CHANGE:MENU OPTION INSERT
Please help me on this..
24c14495-35a9-4391-8c06-25ca6abf36bd wrote:
To get the Third row alos as output, we also need to make ":" also as NULL
Replace(Replace(Replace(process_type,'PLAN ID CHANGE',null),'MENU OPTION INSERT',null),':', null) is null
sure, i forgot about it
Ramin Hashimzade
Similar Messages
-
Select query gives result in abc order instead of creation order
Hi,
I used the following command in sql command window to insert some rows to my table:
SQL>
SQL> insert into regions (Region_ID, Region_Name) values (1 , 'Zafon');
1 row inserted
SQL> insert into regions (Region_ID, Region_Name) values (2 , 'Hasharon');
1 row inserted
SQL> insert into regions (Region_ID, Region_Name) values (3 , 'Merkaz');
1 row inserted
SQL> insert into regions (Region_ID, Region_Name) values (4 , 'Jerusalem');
1 row inserted
SQL> insert into regions (Region_ID, Region_Name) values (5 , 'Hashfela');
1 row inserted
SQL> insert into regions (Region_ID, Region_Name) values (6 , 'Darom');
1 row insertedWhen I use select * query to see the table, I get the content in abc order:
SQL> SELECT * FROM REGIONS;
REGION_ID REGION_NAME
6 Darom
2 Hasharon
5 Hashfela
4 Jerusalem
3 Merkaz
1 Zafon
6 rows selectedHow can I get the result in the creation order (first created- first shown)?
Thanks>
How can I get the result in the creation order (first created- first shown)?
>
You can't - not unless you use a solution that you should NEVER use unless absolutely necessary.
WHY do you need to do this? You never provide a reason.
To get a result in creation order there are two requirements:
1. Use an ORDER BY when you query the table - this is the only requirement others have mentioned
2. Control and specify the creation order when you INSERT the data
Unfortunately there is only ONE way that I am aware of to implement #2 above (i.e. to control the insertion order) and that is to SERIALIZE the insertion of rows into the table. That means that only ONE user can insert rows into the table at a time perhaps by using a stored procedure to perform the insert.
In a multi-user system a USER can NOT see uncommitted data of other users. If a user uses a trigger and a SEQUENCE generator to generate ascending numbers another user can use that same trigger and sequence to generate numbers also. If the first user performs an INSERT and gets number 37 but doesn't commit a second user can perform an INSERT, get number 38 and COMMIT before the first user commits.
That means that the row with 38 was created (committed) first but has a higher sequence than the row with 37.
The best you can do is use a sequence generator to generate unique ascending numbers. Then you can query the data using an ORDER BY on the column that contains the sequence value. But, as shown above, that doesn't guarantee that the rows were actually committed in that order.
That may sound like a trivial distinction but it has a very important implication. It means that you can NOT use that sequenced column to extract data reliably for batch-type processing. For the above example supposed your batch process extracted data for values from 1 to 38 and then that first user did a COMMIT.
The next extract would be for values from 39 to 50 (or some other value) and the row with 37 would never be extracted. For the same reasons you can't use a CREATION_DATE value for such extract purposes either since you would have the same issue. -
hi
sample table can be considered as scott.emp table
CREATE TABLE "EMP"
( "EMPNO" NUMBER(4,0),
"ENAME" VARCHAR2(10 BYTE),
"JOB" VARCHAR2(9 BYTE),
"MGR" NUMBER(4,0),
"HIREDATE" DATE,
"SAL" NUMBER(7,2),
"DEPTNO" NUMBER(2,0)
-- INSERTING into EMP
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7369,'SMITH','CLERK',7902,to_date('17-DEC-80','DD-MON-RR'),800,20);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7499,'ALLEN','SALESMAN',7698,to_date('20-FEB-81','DD-MON-RR'),1600,30);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7521,'WARD','SALESMAN',7698,to_date('22-FEB-81','DD-MON-RR'),1250,30);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7566,'JONES','MANAGER',7839,to_date('02-APR-81','DD-MON-RR'),2975,20);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7654,'MARTIN','SALESMAN',7698,to_date('28-SEP-81','DD-MON-RR'),1250,30);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7698,'BLAKE','MANAGER',7839,to_date('01-MAY-81','DD-MON-RR'),2850,30);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7782,'CLARK','MANAGER',7839,to_date('09-JUN-81','DD-MON-RR'),2450,10);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7788,'SCOTT','ANALYST',7566,to_date('19-APR-87','DD-MON-RR'),3000,20);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7839,'KING','PRESIDENT',null,to_date('17-NOV-81','DD-MON-RR'),5000,10);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7844,'TURNER','SALESMAN',7698,to_date('08-SEP-81','DD-MON-RR'),1500,30);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7876,'ADAMS','CLERK',7788,to_date('23-MAY-87','DD-MON-RR'),1100,20);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7900,'JAMES','CLERK',7698,to_date('03-DEC-81','DD-MON-RR'),950,30);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7902,'FORD','ANALYST',7566,to_date('03-DEC-81','DD-MON-RR'),3000,20);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7934,'MILLER','CLERK',7782,to_date('23-JAN-82','DD-MON-RR'),1300,10); In this we can see we do not have any data for the hiredate between '01-feb-81' and '20-feb-81' . But the select statement must retrun
values in between those days too with ename,job AS NULL and empno, mgr,sal as 0,depno can be 0 or any number.
i have tried something and i got the count for few columns . THe query goes something like this.
this works on a given date range . Both queries given below
select rt.business_date,
( select count(ename) from emp where trunc(hiredate) = trunc(rt.business_date) ) ename ,
( select count(empno) from emp where trunc(hiredate) = trunc(rt.business_date) ) empno ,
( select count(job) from emp where trunc(hiredate) = trunc(rt.business_date) ) job,
( select count(mgr) from emp where trunc(hiredate) = trunc(rt.business_date) ) mgr ,
( select count(deptno) from emp where trunc(hiredate) = trunc(rt.business_date) ) deptno
FROM (select ((TO_DATE(p_startdate,'mm/dd/yyyy')-1)+rnm) as business_date from (select rownum rnm from user_objects)) rt
WHERE TRUNC(rt.business_date) BETWEEN TO_DATE(p_startdate,'mm/dd/yyyy') AND TO_DATE(p_enddate,'mm/dd/yyyy')
SAMPLE OUTPUT FROM select statement has to be something like this :
empno ename job mgr HIREDATE SAL DEPTNO
7369 SMITH CLERK 7902 17-Dec-80 800 20
0 NULL NULL 0 14-Feb-81 0 0
0 NULL NULL 0 15-Feb-81 0 0
0 NULL NULL 0 16-Feb-81 0 0
0 NULL NULL 0 17-Feb-81 0 0
0 NULL NULL 0 18-Feb-81 0 0
0 NULL NULL 0 19-Feb-81 0 0
7499 ALLEN SALESMAN 7698 20-Feb-81 1600 30
7521 WARD SALESMAN 7698 22-Feb-81 1250 30
7566 JONES MANAGER 7839 2-Apr-81 2975 20
7698 BLAKE MANAGER 7839 1-May-81 2850 30
7782 CLARK MANAGER 7839 9-Jun-81 2450 10
7844 TURNER SALESMAN 7698 8-Sep-81 1500 30
7654 MARTIN SALESMAN 7698 28-Sep-81 1250 30
7839 KING PRESIDENT (null) 17-Nov-81 5000 10
7900 JAMES CLERK 7698 3-Dec-81 950 30
7902 FORD ANALYST 7566 3-Dec-81 3000 20
7934 MILLER CLERK 7782 23-Jan-82 1300 10
7788 SCOTT ANALYST 7566 19-Apr-87 3000 20
7876 ADAMS CLERK 7788 23-May-87 1100 20 Edited by: sri on Oct 19, 2011 8:36 AM
Edited by: sri on Oct 19, 2011 8:56 AMHi,
You changed your first message.
sri wrote:
hi,
i want the table data to be displayed as shown . in the quereis we are getting count of those records for that date. But i want something different . if we can see some dates there are no records but in the select statement we need to display the records in the given range of dates.
the out put can be cosnidered something like this:
THe select statment need to display hiredates data for 14 - 20 feb as shown below and this we do not have in our base table emp.
empno ename job mgr HIREDATE SAL DEPTNO
7369 SMITH CLERK 7902 17-Dec-80 800 20
0 NULL NULL 0 14-Feb-81 0 0
0 NULL NULL 0 15-Feb-81 0 0
0 NULL NULL 0 16-Feb-81 0 0
0 NULL NULL 0 17-Feb-81 0 0
0 NULL NULL 0 18-Feb-81 0 0
0 NULL NULL 0 19-Feb-81 0 0
7499 ALLEN SALESMAN 7698 20-Feb-81 1600 30
7521 WARD SALESMAN 7698 22-Feb-81 1250 30
7566 JONES MANAGER 7839 2-Apr-81 2975 20
7698 BLAKE MANAGER 7839 1-May-81 2850 30
7782 CLARK MANAGER 7839 9-Jun-81 2450 10
7844 TURNER SALESMAN 7698 8-Sep-81 1500 30
7654 MARTIN SALESMAN 7698 28-Sep-81 1250 30
7839 KING PRESIDENT (null) 17-Nov-81 5000 10
7900 JAMES CLERK 7698 3-Dec-81 950 30
7902 FORD ANALYST 7566 3-Dec-81 3000 20
7934 MILLER CLERK 7782 23-Jan-82 1300 10
7788 SCOTT ANALYST 7566 19-Apr-87 3000 20
7876 ADAMS CLERK 7788 23-May-87 1100 20
Use a FULL OUTER JOIN instead of LEFT OUTER JOIN, like this:
WITH all_dates AS
SELECT startdate + LEVEL - 1 AS dt
FROM (
SELECT TO_DATE ('02/14/1981', 'MM/DD/YYYY') AS startdate
, TO_DATE ('02/20/1981', 'MM/DD/YYYY') AS enddate
FROM dual
CONNECT BY LEVEL <= 1+ enddate - startdate
SELECT NVL (e.empno, 0) AS empno
, e.ename
, NVL (a.dt, e.hiredate) AS hiredate
-- add other columns
FROM all_dates a
FULL OUTER JOIN emp e ON a.dt = e.hiredate
ORDER BY NVL (a.dt, e.hiredate)
; -
Update only one select query field
hello
how i can update select query result field in original table.
update table1 set field_1 from(select field_1 from table 1,table2,table3,table4 where table1.field_1=table1.field_1 and table2.field_2=table3.field_2 and table4.field_3=table1.field_4)
like that.is it possible!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!can u please help me to rewrite query/
select query returns result like that from different tables
lets example field_1 field_2 field_3 field_4
TIGER 1 V A
TIGER 2 F B
TIGER 3 R C
I need to update 'TIGER' instead of 'LION' in original table.
THANKSMaybe something like
update table1
set beast = (select animal
from <table_list>
where <predicates>
where beast = 'LION'when your query returns a single row
or when multiple rows are returned
update (select t1.beast,t2.animal
from (select beast,
<join_columns_list>
from table1
where beast = 'LION'
) t1,
(select animal,
<join_columns_list>
from <table_list>
where <predicates>
) t2
where t1.<join_columns_list> = t2.<join_columns_list>
set beast = animalRegards
Etbin -
Query with results always needed...
Hi
Would you please help me to get this query? I noew with Oracle 9i...
What I need is to create a query Not empty or with rows always.
I have a list below where I need to get the count and the sum grouped by Source in a Date range.
- The fact is that if I change my date range (suppouse aprl/01/04 thru apr/30/04) the query will result with No rows, ok.
I need to create a row for every group (SAP, CAC), with Zeroes on the Count and on the Sum...
- If any group (SAP/CAC) have rows but the other one not also need to create a Zeroes row for the group that does not fall in the date range, suppose 03/03/2004...
Source Payment Code_Emp In_Date
SAP 100.00 001 01/01/2004
SAP 100.00 001 01/01/2004
SAP 100.00 001 02/02/2004
SAP 100.00 001 02/02/2004
SAP 100.00 001 03/03/2004
CAC 100.00 001 01/01/2004
CAC 100.00 001 01/01/2004
CAC 100.00 001 01/01/2004
CAC 100.00 001 01/01/2004
CAC 100.00 001 02/01/2004
CAC 100.00 001 02/01/2004
Total for date range from 01/01/2004 to 01/31/2004
Sum of Count
Payments
Totals for SAP 200.00 2
Totals for CAC 400.00 4
Difference 200.00 -2
I GOT SOMETHING LIKE THIS, BUT THIS WILL RETURN ME MORE THAN 2 ROWS, ONE FOR SAP OTHER FOR CACE AND OTHERS WITH NULLS....
SELECT Source,
NVL(Count(code_Emp),0) T_Payment_Req,
NVL(ROUND(Sum(payment),2),0.00) T_Payment_Amount
FROM ApDetail
WHERE Reconciliation_Id is Null
AND In_Date BETWEEN To_Date('01/01/2004','MM/DD/YYYY')
and To_Date('01/31/2004','MM/DD/YYYY')
GROUP by Source
union
SELECT Source, 0, 0
FROM ApDetail
WHERE Reconciliation_Id is Null
KIND REGARDS.SELECT
Count(SAP.code_Emp) SAP_T_Payment_Req,
Count(CAC.code_Emp) CAC_T_Payment_Req,
ROUND(NVL(Sum(SAP.payment),0),2) SAP_T_Payment_Amount,
ROUND(NVL(Sum(CAC.payment),0),2) CAC_T_Payment_Amount,
ROUND(NVL(Sum(CAC.payment),0),2) -
ROUND(NVL(Sum(SAP.payment),0),2) Difference
FROM ApDetail CAC, ApDetail SAP
WHERE
(SAP.Reconciliation_Id is Null
AND SAP.In_Date BETWEEN To_Date('01/01/2004','MM/DD/YYYY')
and To_Date('01/31/2004','MM/DD/YYYY')
AND SAP.SOURCE = 'SAP')
AND (CAC.Reconciliation_Id is Null
AND CAC.In_Date BETWEEN To_Date('01/01/2004','MM/DD/YYYY')
and To_Date('01/31/2004','MM/DD/YYYY')
AND CAC.SOURCE = 'CAC')
This Query ALWAYS return ONE record. -
SELECT query very slow, need suggestion.
Dear all,
Below stmt was coded in my report program.
It was taking around 14 seconds in development system. The days in s_datum was just 1 or 2 days max.
But when the same was transferred to test system, it is taking almost 10 minutes, though it we gave just 1 day.
SELECT * FROM likp INTO TABLE i_likp
WHERE erdat IN s_datum AND wadat_ist > '00000000'
AND lfart <> 'EL'
AND vstel not in s_vstel.
Some of you might suggest to make SELECT query with only s_datum, but i tried it in dev system, it was taking almost 22 secs with only s_datum. I thought it could be more worse in test system so, did not move that idea.
Can some one please suggest me why it is happening so.Hi,
The difference, as I suppose you know, happens because LIKP probably has much more records in production than in the development system.
You must think what is selective in your WHERE clause:
- erdat in s_datum is selective if you are are only using one day
- wadat_ist GE '00000000' is not selective (all deliveries with goods issue fulfill that condition)
- lfart NE 'EL' probably is not selective
- vsten not in s_vstel probably is not selective
So in the end only erdat is selective. There is no index in LIKP by ERDAT, so if you really want to make it faster you would need an index by ERDAT.
Still, if you are only making one SELECT (not inside a loop) I wouldn't expect that to take more than 10 minutes.
I would measure the program with SE30 to make sure it is really the SELECT that is taking so much time (post here the results), and if it really is the select post here the explain plan.
By the way, if you need to know all goods issues for the last day I would use change pointers instead.
Hope this helps,
Rui Dantas -
How to fit results of the select query into next REPLACE statement
Hello All,
example:--
select @DBName = Name from sys.sysdatabases WHERE dbid = DB_ID('DBA')
PRINT @DBName (Answer is DBA)
Now, I want to use this @DBName result in the following statement EVERYTIME:--
SET @NewDBName = SELECT REPLACE('DBA ' ,' DBA', 'DBANew') ----------i need help with this syntex...
HOW CAN I WRITE ABOVE REPLACE STATEMENT CORRECTLY, WHICH EVERYTIME USE THE RESULT OF THE FIRST SELECT QUERY?
Thank you in advance....Thank you for quick reply.
how about this situation:--
i want to replace 'Z' with '\\sqlserver\Z$', how can i do this?
DECLARE @OriginalBackupFile VARCHAR(100)
SET @OriginalBackupFile = 'Z'
DECLARE @cmd VARCHAR(100)
SET @cmd = (SELECT REPLACE (@OriginalBackupFile, @OriginalBackupFile,????????)
PRINT @cmd -
How to insert the select query result into table?
How to insert the select query result into table?
SELECT top 20 creation_time
,last_execution_time
,total_physical_reads
,total_logical_reads
,total_logical_writes
, execution_count
, total_worker_time
, total_elapsed_time
, total_elapsed_time / execution_count avg_elapsed_time
,SUBSTRING(st.text, (qs.statement_start_offset/2) + 1,
((CASE statement_end_offset
WHEN -1 THEN DATALENGTH(st.text)
ELSE qs.statement_end_offset END
- qs.statement_start_offset)/2) + 1) AS statement_text
FROM sys.dm_exec_query_stats AS qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) st
ORDER BY total_elapsed_time / execution_count DESC;
Thanks,
Tirumala1. SELECT INTO
Below method will create table when data is inserted from one table to another table. Its useful when you need exactly same datatype as source table.
Use AdventureWorks2008R2;
Go
---Insert data using SELECT INTO
SELECT AddressLine1, City
INTO BothellAddresses
FROM Person.Address
where City = 'Bothell';
GO
---VERIFY DATA
Select AddressLine1, City
FROM BothellAddresses
---DROP TABLE
DROP TABLE BothellAddresses
GO
2. INSERT INTO SELECT
Below method will need table to be created prior to inserting data. Its really useful when table is already created and you want insert data from
another table.
Use AdventureWorks2008R2;
Go
---Create Table
CREATE TABLE BothellAddresses (AddressLine1 NVARCHAR(60), City NVARCHAR(30))
---Insert into above table using SELECT
INSERT INTO BothellAddresses(AddressLine1, City)
SELECT AddressLine1, City
FROM Person.Address
where City = 'Bothell';
---VERIFY DATA
Select AddressLine1, City
FROM BothellAddresses
---DROP TABLE
DROP TABLE BothellAddresses
GO
Regards,
Vishal Patel
Blog: http://vspatel.co.uk
Site: http://lehrity.com -
Select Query resulting in Scientific Notation
Hello all,
I am running a Select query through a batch file that extracts data from an Oracle database. Several of the fields that I am extracting from contain numbers that are up to 38 digits long. When I extract the data, it converts the numbers into scientific notation and it is important for me to have the entire field. Is there something I can change to my query that will pull the data in its entire form? This is what I'm running now:
select * FROM ML.APPT where APPTDATE >= to_date('01/1/2010','mm/dd/yyyy'
I apologize in advance if this has been answered already.
Thanks!>
When the extractor finishes, it returns the data into a flat file.
don't quite understand the TO_CHAR function. Does this function mean I need to say something like this: select "TO_CHAR('column name', 99999999999999999999999999999999999999" FROM ML.APPT where APPTDATE >= to_date('01/1/2010','mm/dd/yyyy')
>
Yes- if the tool you use to extract the data (your 'extractor') is converting the numeric data to a string then it is responsible for creating the string in the proper format. If the number is an integer that can have as many digits as you have '9's in your sample format string then that is what you need to do.
Here is how sql*plus (Oracle's tool) will display the data using default settings
SQL> select 12345678901234567890123456789012345678 no_format,
2 to_char(12345678901234567890123456789012345678, '99999999999999999999999999
999999999999') with_format
3 from dual;
NO_FORMAT WITH_FORMAT
1.2346E+37 12345678901234567890123456789012345678
SQL>
----- TOAD will display something similiar but the default uses more decimal digits in the scientific notation data
NO_FORMAT,WITH_FORMAT
1.23456789012346E37, 12345678901234567890123456789012345678You can either format the numeric data in the query using TO_CHAR or the 'extractor' can do it when it converts the data to a string. -
Need help in writing a select query to pull required data from 3 tables.
Hi,
I have three tables EmpIDs,EmpRoles and LatestRoles. I need to write a select Query to get roles of all employees present in EmpIDs table by referring EmpRoles and LatestRoles.
The condition is first look into table EmpRoles and if it has more than one entry for a particular Employee ID than only need to get the Role from LatestRoles other wise consider
the role from EmpRoles .
Sample Script:
Create Table #EmpIDs
(EmplID int )
Create Table #EmpRoles
(EMPID int,Designation varchar(50))
Create Table #LatestRoles
EmpID int,
Designation varchar(50)
Insert into #EmpIDs values (1),(2),(3)
Insert into #EmpRoles values (1,'Role1'),(2,'Role1'),(2,'Role2'),(3,'Role1')
Insert into #LatestRoles values (2,'Role2')
Employee ID 2 is having two roles defined in EmpRoles so for EmpID 2 need to fetch Role from LatestRoles table and for
remaining ID's need to fetch from EmpRoles .
My Final Output of select query should be like below.
EmpID Role
1 Role1
2 Role2
3 Role1
Please help.
MohanMohan,
Can you check if this answers your requirement:
Create Table #EmpIDs
(EmplID int )
Create Table #EmpRoles
(EMPID int,Designation varchar(50))
Create Table #LatestRoles
EmpID int,
Designation varchar(50)
Insert into #EmpIDs values (1)
Insert into #EmpIDs values (2)
Insert into #EmpIDs values (3)
Insert into #EmpRoles values (1,'Role1')
Insert into #EmpRoles values (2,'Role2')
Insert into #EmpRoles values (2,'Role1')
Insert into #EmpRoles values (3,'Role1')
Insert into #LatestRoles values (2,'Role2')
--Method 1
select e.EmplID,MIN(ISNULL(l.Designation,r.Designation)) as Designation
from #empids e
left join #emproles r on e.emplID=r.EmpID
left join #latestRoles l on e.emplID=l.EmpID
group by e.EmplID
--Method 2
;with cte
as
select distinct e.EmplID,r.Designation,count(*) over(partition by e.emplID) cnt
from #empids e
left join #emproles r on e.emplID=r.EmpID
select emplID,Designation
from cte
where cnt=1
UNION ALL
select a.EmplID,l.Designation
from
(select distinct EmplID from cte where cnt>1) a
join #Latestroles l on a.EmplID=l.EmpID
order by emplID
Thanks,
Jay
<If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'> -
How to get result of select query from oracle in VC
Dear All ,
I have a application in oracle which insert the data in the oracle database table.
Now i want to show all the data that has been inserted into the database table in my VC application but i don't know how to handle select query in VC.
Regards
KrishanHi Goivndu
Thanks for your reply .
I know all those things.
I have created the system & alias for my backend oracle system.
I can also see all the stored procedure that are there in my oracle system.
I just want to know how to write a select query in a stored procedure .
you can insert data , Update data through oracle procedure but i don't think there is any way to get the result of select query in stored procedure .
If you know any way to do that please do let me know .
Regards
Krishan -
Needs help to retrive the last row in a select query without using rownum
Hi ,
i need to retrive the last row from the select sub query without using rownum.
is there any other way to retrive the last row other than the below query.
is that the ROWNUM=1 will always retrive the 1 row of the select query ?
select from*
*(select ename from employee where dept_id=5 order by desc) where rownum=1;*
Please advise.
thanks for your help advance,
regards,
Senthur957595 wrote:
Actually my problem is ithat while selecting the parents hiearchy of the child data using
CONNECT BY PRIOIR query
I need the immediate parent of my child data.
For example my connect BY query returns
AAA --- ROOT
BBB --PARENT -2
CCC --PARENT-1
DDD IS my input child to the connect by query
Immediate parent of my child data "DDD" ---> CCC(parent -1)
i want the data "CCC" from the select query,for that i am taking the last row of the query with rownum.
I got to hear that using ROWNUM to retrive the data will leads to some problem.It is a like a magic number.I am not sure what the problem will be.
So confusing with using this rownum in my query.
Please advice!!!It's not quite clear what you're wanting, but perhaps this may help?
you can select the PRIOR values to get the parent details if you want...
SQL> ed
Wrote file afiedt.buf
1 select empno, lpad(' ',(level-1)*2,' ')||ename as ename, prior empno as mgr
2 from emp
3 connect by mgr = prior empno
4* start with mgr is null
SQL> /
EMPNO ENAME MGR
7839 KING
7566 JONES 7839
7788 SCOTT 7566
7876 ADAMS 7788
7902 FORD 7566
7369 SMITH 7902
7698 BLAKE 7839
7499 ALLEN 7698
7521 WARD 7698
7654 MARTIN 7698
7844 TURNER 7698
7900 JAMES 7698
7782 CLARK 7839
7934 MILLER 7782
14 rows selected.(ok, not the best of examples as the mgr is already known for a row, but it demonstrates you can select prior data) -
Select query resulting in redo?
Hi All,
Does select query results in redo? In what cases this happens?
Regards,
Sphinxmtefft wrote:
Another possibility is that the SELECT query invokes a PL/SQL function that performs insert, update or delete.
This is a poor practice for a number of reasons but they are out there.
Disagree with that. Proof:
SQL> create table x(y number);
Table created.
SQL> create function f return number as
2 begin
3 insert into x values (2);
4 return 1;
5 end;
6 /
Function created.
SQL> select dummy, f() from dual;
select dummy, f() from dual
ERROR at line 1:
ORA-14551: cannot perform a DML operation inside a query
ORA-06512: at "HR.F", line 3 -
hi,
Need Select Query for this...
12. Check if the document category TVLK-VBTYP = 7 where TVLK-LFART = LIKP-LFART (Delivery Type) then this is and Inbound Delivery for a purchase order.
13. Check the value of field Shipment External ID#1 (VTTK-EXTI1) is not initial then check the BOL Data Format. If not VICSBOL then set the variable LI_INBVICS = N. and assign Shipment External ID#1 to Shipment External ID#2 i. e VTTK-EXTI2 = VTTK-EXTI1. and Check the TMS BOL Format. If VICSBOL then set LI_INBVICS = Y .Hi,
1)
IF TVLK-VBTYP = 7 and TVLK-LFART = LIKP-LFART.
Inbound Is for a Purchase order.
ELSE.
Inbound Is not for a Purchase order.
Endif.
2)
IF not VTTK-EXTI1 is initial.
IF BOL DATA <> VICSBOL.
LI_INBVICS = N.
VTTK-EXTI2 = VTTK-EXTI1
else if BOL DATA <> VICSBOL.
LI_INBVICS = Y
Endif.
endif.
endif. -
I need to know the proper syntax for my SELECT query, please.
Hello All,
Quick one for you:
Let's say that I have several columns in a table with names such as subject_1, subject_2, subject_3, etc. The table's name is subject_names.
The number in each of the three column name examples is also a value passed along a query string, the user can select choices, 1, 2 or 3. That query string's variable is $qs.
So, what I want is a SELECT query that uses the query string value as follows (KEEP IN MIND, I know this is not the proper syntax):
"SELECT subject_[$qs]
FROM subject_names";
I have tried all sorts of cominations of quotes (single and double), dots, brackets, braces and parenthesis. I just want to know how to include such a variable within this code.
Any and all help is sincerely appreciated!
Cheers,
wordmanWell, I did give you the syntax though.
$query = 'SELECT ' . $qs . ' FROM tbl_name';
I put spaces between the periods this time to make it more clear.
If you put the actual word 'subject' in there and just want your form to name it's options as the numbers available you could do this:
$query = 'SELECT subject_' . $qs . ' FROM tbl_name';
In PHP you can use either single or double quotes around your query string, I always just use single quotes. I see a lot of other use double quotes.
Double quotes would look like:
$query = "SELECT subject_' . $qs . ' FROM tbl_name";
Or when using double quotes you can actually just place the variable right in the string without having to concatenate multiple strings like above.
Since you mentioned that you are good with passing variables I probably don't have to mention that you need to set the value attribute of your option tags (if you are using a select) to the value you want them to pass.
Ex:
<select name="choices">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
If you have that part all figured out then you can use the syntax above for your query string.
Good luck.
Maybe you are looking for
-
Long running DBAdapter partnerlink activities (transactions)
Hello, I try to use nonBlockingInvoke = true for long running DBAdapter partnerlink activities, but i'm not succesfull. In BPELConsole the activity seems to be running, but there is an entry in Manual Recovery > Activity TAB and OraBPEL~OC4J_BPEL~def
-
New excel file cannot be opened with right click in any folder.
Usually I create a new file (.xlsx) by right click inside any folder of windows 7 . Recently I am observing that it is not being possible to create a new file (.xlsx) by right click when I am inside a folder. Whenever I right click in order to create
-
Can anyone help me please? Itunes will download an update to my iphone but will not install them due to an "unknown error" no code listed. It says it cannot back up my iphone . I have tried everything , searched the internet for help, including turn
-
Grid control agent for Solaris 10 x86-64
Are there any estimated release dates for a Solaris 10 x86-64 version of the grid control agent?
-
Where can I find cheep ram and...
I want to find a cheep single stick of 2GB ram. Also would it help with render intensive programs such as Final cut pro and Maya?