How to avoid DISTINCT in OBIEE SQL
Hi...
For question i posted previously...
Problem with LONG datatype in Answers
I run the query in TOAD, and i was identified the error because of what this error is coming... because of DISTINCT...
I have taken care of avoiding that column in ORDER BY by putting the order by on another column..
Now my question is how to avoid the DISTINCT clause in SQL generated by OBIEE...
If the first column in criteria is measure then it avoids the DISTINCT... but if i use measure... group by will come.. and group by should not be used here...
If this is done... my problem will be resolved...
Ofcourse... i would be getting duplicate rows...
Still i want the answer how to avoid DISTINCT?
Expecting answer from you...
Thanks & Regards
Kishore Guggilla
Hi...
Thanks for reply...
Now another question.. if i want to do this for one report... how?/
If i do that change in Catalog properties.. that will be effected for all reports i think...
Instead of that if i want to do that for only one report.. which is effecting... then how to proceed??
I tried by writing case when 1=0 ... for first column in criteria.. but no luck...
Thanks & Regards
Kishore Guggilla
Similar Messages
-
How to avoid @ for running a sql query in sqlplus
Hi friends,
Is there a way to avoid typing @ for the execution of every sql script in the database. Maybe playing around with the login.sql or something.
I am bored of typing shift+@ every execution of running any of my scripts(i have nearly 3000 scripts) :(. May sound like a request from a lazy guy , but still can anyone please suggest some solution.??
like instead of
14:12:04 sa@TESTDB> @active
Client last
SID SER# LOGON_AT USERNAME OSUSER MACHINE PID MODULE PROGRAM SQL_ID call et
225 1 17-jun 07:00 oracle tkxti019 4543 oracle@tkxt 55h 11m 43s
224 1 17-jun 07:00 oracle tkxti019 4651 oracle@tkxt 55h 11m 43s
223 1 17-jun 07:00 oracle tkxti019 4708 oracle@tkxt 55h 11m 43ssomething like below is needed
14:12:05 sa@TESTDB> active
Client last
SID SER# LOGON_AT USERNAME OSUSER MACHINE PID MODULE PROGRAM SQL_ID call et
225 1 17-jun 07:00 oracle tkxti019 4543 oracle@tkxt 55h 11m 43s
224 1 17-jun 07:00 oracle tkxti019 4651 oracle@tkxt 55h 11m 43s
223 1 17-jun 07:00 oracle tkxti019 4708 oracle@tkxt 55h 11m 43sThanks,
KunwarKunwar wrote:
I am bored of typing shift+@ every execution of running any of my scripts(i have nearly 3000 scripts)If you're running several scripts in one go, why not put them into a script, so that you only have to call that script and the rest will run automatically?
eg:
main.sql:
Prompt Running script1
@script1
Prompt Running script2
@script2
Prompt Running script3000
@script3000
SQL> @main
Running script1
Running script2
Running script3000
... -
Hi..
How to avoid distinct operation in table view reports
In my database data are
id__Name__Salary
01_aaaaa__1000
01_aaaaa__1000
01_aaaaa__1000
02_aaaaa__1000
02_aaaaa__1000
My output
01_aaaaa__1000
02_aaaaa__1000
but I need
id__Name__Salary
01_aaaaa__1000
01_aaaaa__1000
01_aaaaa__1000
02_aaaaa__1000
02_aaaaa__1000This may help, see the answer:
Re: OBIEE using distinct
Have you got ID in the table that is unique?
Regards
Goran
http://108obiee.blogspot.com -
How to avoid performance problems in PL/SQL?
How to avoid performance problems in PL/SQL?
As per my knowledge, below some points to avoid performance proble in PL/SQL.
Is there other point to avoid performance problems?
1. Use FORALL instead of FOR, and use BULK COLLECT to avoid looping many times.
2. EXECUTE IMMEDIATE is faster than DBMS_SQL
3. Use NOCOPY for OUT and IN OUT if the original value need not be retained. Overhead of keeping a copy of OUT is avoided.Susil Kumar Nagarajan wrote:
1. Group no of functions or procedures into a PACKAGEPutting related functions and procedures into packages is useful from a code organization standpoint. It has nothing whatsoever to do with performance.
2. Good to use collections in place of cursors that do DML operations on large set of recordsBut using SQL is more efficient than using PL/SQL with bulk collects.
4. Optimize SQL statements if they need to
-> Avoid using IN, NOT IN conditions or those cause full table scans in queriesThat is not true.
-> See to queries they use Indexes properly , sometimes Leading index column is missed out that cause performance overheadAssuming "properly" implies that it is entirely possible that a table scan is more efficient than using an index.
5. use Oracle HINTS if query can't be further tuned and hints can considerably help youHints should be used only as a last resort. It is almost certainly the case that if you can use a hint that forces a particular plan to improve performance that there is some problem in the underlying statistics that should be fixed in order to resolve issues with many queries rather than just the one you're looking at.
Justin -
How to avoid unions in sql quries
Hi All,
I have an sql statement in which I am using unions to get the data from two tables with different conditions. how can avoid UNIONs in my query, which will increase performance. please suggest.
SQL Query is :
SELECT opt_url_path, locale
FROM urlregistry
WHERE master_assetid IN
(SELECT c.id FROM content_c c, content_cd cc
WHERE c.flextemplateid = cc.id AND cc.name = 'SoftwareDownload'
AND (c.PATH NOT LIKE '/auth%' AND c.PATH NOT LIKE '/gate%'))
UNION
SELECT opt_url_path, locale
FROM urlregistry
WHERE master_assetid IN
(SELECT c.id FROM content_c c, content_c_mungo cm
WHERE c.id = cm.cs_ownerid AND cm.cs_attrid =
(SELECT id FROM attribute WHERE name = 'Gated')
AND c.flextemplateid IN (SELECT id FROM content_cd WHERE name = 'Collateral')
AND cm.stringvalue = 'Yes'
AND (c.PATH NOT LIKE '/auth%'
AND c.PATH NOT LIKE '/gate%'))
UNION
SELECT PATH, locale
FROM bloburlregistry
WHERE master_assetid IN
(SELECT c.id FROM content_c c, content_c_mungo cm
WHERE c.id = cm.cs_ownerid AND cm.cs_attrid = (SELECT id FROM attribute WHERE name = 'Gated')
AND c.flextemplateid IN (SELECT id FROM content_cd WHERE name = 'Collateral')
AND cm.stringvalue = 'Yes'
AND (c.PATH NOT LIKE '/auth%'
AND c.PATH NOT LIKE '/gate%'))
Thank u.To increase performance you need to reduce the I/O. So when ever i tune a SQL the first thing i look for is that. If i have a table used multiple times i try to remove it and solve the required problem by just scanning the table once. But do to that we need to have good understanding of the data and there relation between tables. But we don't know anything about yours. Said that i came up with this.
select opt_url_path
, locale
from urlregistry
where master_assetid
IN
select c.id
from content_c c
left
join content_cd cc
on c.flextemplateid = cc.id
and (cc.name = 'SoftwareDownload' or cc.name = 'Collateral')
left
join content_c_mungo cm
on c.id = cm.cs_ownerid
and cm.cs_attrid =
SELECT id
FROM attribute
WHERE name = 'Gated'
and cm.stringvalue = 'Yes'
where c.PATH NOT LIKE '/auth%'
and c.PATH NOT LIKE '/gate%'
and (
cc.flextemplateid is not null or
cm.cs_owner_id is not null
union
select PATH
, locale
from bloburlregistry
where master_assetid IN
select c.id
from content_c c
, content_c_mungo cm
where c.id = cm.cs_ownerid
and cm.cs_attrid =
SELECT id
FROM attribute
WHERE name = 'Gated'
and c.flextemplateid IN
SELECT id
FROM content_cd
WHERE name = 'Collateral'
and cm.stringvalue = 'Yes'
and c.PATH NOT LIKE '/auth%'
and c.PATH NOT LIKE '/gate%'
This is a untested code. You can give this a try and see if it gives the expected output and also if the performance improves. -
HOw to avoid DeadLocks when you schedule a Sql Server Agent Job and calling SSIS packages
Hi All,
I have scheduled 2 packages in in Sql Server Agent jobs .
First job which is having Package 1 executing at 11 AM and where I am inserting the data in the table.
Second job which is having Package 2 executing at 12 AM and where I am updating the data in the table based on the first job inserted records.
When I am executing my first job it taking more time and executing till 12 AM and from 12 AM my job 2 also starting ,so getting deadlocks conflicts because inserting happening from job1 and updating happening from Job 2.
How to avoid deadlocks and fix the issue.
Please Suggest .
Thanks & Regards,
AnandHi Anand,
Here is another solution, you can set the Job 2 not to run based on a schedule, and create another SQL Server Agent Job which starts at 12 AM and run with a specified time interval to execute a SQL statement in which you do the following steps:
1. Get the status information of Job 1 using the statement:
DECLARE @i int;
EXEC @i = msdb.dbo.sp_help_job @job_name = ‘Job Name'
2. If the value of @i is 1 which means the status of job 1 is success and current time is, then start the job 2. So, the statement is as follows:
IF @I = 1
EXEC msdb.dbo.sp_start_job @job_name= ‘Job Name’
Regards,
Mike Yin
TechNet Community Support -
i have one database table called "sms1" that table is updated every day or on daily basis it has the following fields in it:
SQL> desc sms1;
Name Null? Type
MOBILE NUMBER
RCSTCNATCNATCNATCNAWTHER VARCHAR2(39 CHAR)
SNO NUMBER
INDATE DATE
From this table the is one column "RCSTCNATCNATCNATCNAWTHER VARCHAR2(39 CHAR)" . I am splitting it into different columns like :
SQL> desc smssplit;
Name Null? Type
R VARCHAR2(2 CHAR)
C VARCHAR2(2 CHAR)
S VARCHAR2(1 CHAR)
TC VARCHAR2(3 CHAR)
NA VARCHAR2(3 CHAR)
TC2 VARCHAR2(3 CHAR)
NA2 VARCHAR2(3 CHAR)
TC3 VARCHAR2(3 CHAR)
NA3 VARCHAR2(3 CHAR)
TC4 VARCHAR2(3 CHAR)
NA4 VARCHAR2(3 CHAR)
WTHER VARCHAR2(10 CHAR)
SNO NUMBER
INSERTDATA VARCHAR2(25 CHAR)
Now I am written a procedure to insert the data from "Sms1" table to smssplit table...
CREATE OR REPLACE PROCEDURE SPLITSMS
AS
BEGIN
INSERT INTO scott.SMSSPLIT ( R,C,S,TC,NA,TC2,NA2,TC3,NA3,TC4,NA4,WTHER,SNO)
SELECT SUBSTR(RCSTCNATCNATCNATCNAWTHER,1,2) R,
SUBSTR(RCSTCNATCNATCNATCNAWTHER,3,2) C,
SUBSTR(RCSTCNATCNATCNATCNAWTHER,5,1) S,
SUBSTR(RCSTCNATCNATCNATCNAWTHER,6,3) TC,
SUBSTR(RCSTCNATCNATCNATCNAWTHER,9,3) NA,
SUBSTR(RCSTCNATCNATCNATCNAWTHER,12,3) TC2,
SUBSTR(RCSTCNATCNATCNATCNAWTHER,15,3) NA2,
SUBSTR(RCSTCNATCNATCNATCNAWTHER,18,3) TC3,
SUBSTR(RCSTCNATCNATCNATCNAWTHER,21,3) NA3,
SUBSTR(RCSTCNATCNATCNATCNAWTHER,24,3) TC4,
SUBSTR(RCSTCNATCNATCNATCNAWTHER,27,3) NA4,
SUBSTR(RCSTCNATCNATCNATCNAWTHER,30,10) WTHER, SNO
FROM scott.SMS1 where SNO=(select MAX (sno) from SMS1);
END;
Now in order to update the second table with data from first table on regular basis I have written a job scheduler and I am using oracle 9.0. version...
DECLARE
X NUMBER;
JobNumber NUMBER;
BEGIN
SYS.DBMS_JOB.SUBMIT
job => X
,what => 'scott.SPLITSMS;'
,next_date => SYSDATE+1/1440
,interval => 'SYSDATE+1/1440 '
,no_parse => FALSE
:JobNumber := to_char(X);
END;
Now this job scheduler is working properly and updating the data for every one minute but it is taking or updating the duplicate values also ..like example:
R C S TC NA TC2 NA2 TC3 NA3 TC4 NA4 WTHER SNO
INSERTDATA
33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
06-SEP-2012 03:49:16
33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
06-SEP-2012 03:49:16
33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
06-SEP-2012 03:50:17
R C S TC NA TC2 NA2 TC3 NA3 TC4 NA4 WTHER SNO
INSERTDATA
33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
06-SEP-2012 03:50:17
33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
06-SEP-2012 03:51:19
33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
06-SEP-2012 03:51:19
R C S TC NA TC2 NA2 TC3 NA3 TC4 NA4 WTHER SNO
INSERTDATA
33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
06-SEP-2012 03:52:20
33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
06-SEP-2012 03:52:20
33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
06-SEP-2012 03:53:22
R C S TC NA TC2 NA2 TC3 NA3 TC4 NA4 WTHER SNO
INSERTDATA
33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
06-SEP-2012 03:53:22
33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
06-SEP-2012 03:54:45
33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
06-SEP-2012 03:54:45
Now I do not want the duplicate values to be updated ...and want them to ignore them.....
please I need a help on this query........How to avoid the duplicate values............Look at the posts closely:might not be needed if formatted ;)
create or replace procedure splitsms as
begin
insert into scott.smssplit (r,c,s,tc,na,tc2,na2,tc3,na3,tc4,na4,wther,sno)
select substr(rcstcnatcnatcnatcnawther,1,2) r,
substr(rcstcnatcnatcnatcnawther,3,2) c,
substr(rcstcnatcnatcnatcnawther,5,1) s,
substr(rcstcnatcnatcnatcnawther,6,3) tc,
substr(rcstcnatcnatcnatcnawther,9,3) na,
substr(rcstcnatcnatcnatcnawther,12,3) tc2,
substr(rcstcnatcnatcnatcnawther,15,3) na2,
substr(rcstcnatcnatcnatcnawther,18,3) tc3,
substr(rcstcnatcnatcnatcnawther,21,3) na3,
substr(rcstcnatcnatcnatcnawther,24,3) tc4,
substr(rcstcnatcnatcnatcnawther,27,3) na4,
substr(rcstcnatcnatcnatcnawther,30,10) wther,
sno
from scott.sms1 a
where sno = (select max(sno)
from sms1
where sno != a.sno
); ---------------> added where clause with table alias.
end;Regards
Etbin -
How to get Distinct Values from Answers
Hi,
How to get Distinct values from answers, i've tried to put some functions on it.
Thanks,
MalliMalli,
Are you trying to fetch data from Dimension Attr OR Fact Measures? Did you try the advance tab - > Advanced SQL Clauses - > Check this box to issue an explicit Select Distinct. -
How to avoid db file parallel read for nestloop?
After upgraded to 11gr2, one job took more than twice as long as before on 10g and 11gr1 with compatibility being 10.2.0.
Same hardware. (See AWR summary below). My analysis points to that Nestloop is doing index range scan for the inner table's index segment,
and then use db file parallel read to read data from the table segment, and for reasons that I don't know, the parallel read is very slow.
AVG wait is more than 300ms. How can I fluence optimier to choose db file sequential read to fetch data block from inner table by tweaking
parameters? Thanks. YD
Begin Snap: 13126 04-Mar-10 04:00:44 60 3.9
End Snap: 13127 04-Mar-10 05:00:01 60 2.8
Elapsed: 59.27 (mins)
DB Time: 916.63 (mins)
Report Summary
Cache Sizes
Begin End
Buffer Cache: 4,112M 4,112M Std Block Size: 8K
Shared Pool Size: 336M 336M Log Buffer: 37,808K
Load Profile
Per Second Per Transaction Per Exec Per Call
DB Time(s): 15.5 13.1 0.01 0.01
DB CPU(s): 3.8 3.2 0.00 0.00
Redo size: 153,976.4 130,664.3
Logical reads: 17,019.5 14,442.7
Block changes: 848.6 720.1
Physical reads: 4,149.0 3,520.9
Physical writes: 16.0 13.6
User calls: 1,544.7 1,310.9
Parses: 386.2 327.7
Hard parses: 0.1 0.1
W/A MB processed: 1.8 1.5
Logons: 0.0 0.0
Executes: 1,110.9 942.7
Rollbacks: 0.2 0.2
Transactions: 1.2
Instance Efficiency Percentages (Target 100%)
Buffer Nowait %: 99.99 Redo NoWait %: 100.00
Buffer Hit %: 75.62 In-memory Sort %: 100.00
Library Hit %: 99.99 Soft Parse %: 99.96
Execute to Parse %: 65.24 Latch Hit %: 99.95
Parse CPU to Parse Elapsd %: 91.15 % Non-Parse CPU: 99.10
Shared Pool Statistics
Begin End
Memory Usage %: 75.23 74.94
% SQL with executions>1: 67.02 67.85
% Memory for SQL w/exec>1: 71.13 72.64
Top 5 Timed Foreground Events
Event Waits Time(s) Avg wait (ms) % DB time Wait Class
db file parallel read 106,008 34,368 324 62.49 User I/O
DB CPU 13,558 24.65
db file sequential read 1,474,891 9,468 6 17.21 User I/O
log file sync 3,751 22 6 0.04 Commit
SQL*Net message to client 4,170,572 18 0 0.03 NetworkIts not possible to say anything just by looking at the events.You must understand that statspacks and AWR actualy aggergate the data and than show the results.There may be a very well possibility that some other areas also need to be looked at rather than just focussin on one event.
You have not mentioned any kind of other info about the wait event like their timings and all that.PLease provide that too.
And if I understood your question corretly,you said,
How to avoid these wait events?
What may be the cause?
I am afraid that its not possible to discuss each of these wait event here in complete details and also not about what to do when you see them.Please read teh Performance Tuning book which narrates these wait events and corresponding actions.
Please read and follow this link,
http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/instance_tune.htm#i18202
Aman.... -
How to put distinct in the query
Hi all,
How to put distinct in the query.I checked in RPD , Distinct supported is already available. I marked the distinct check box in advance option still then i'm not getting distinct in the query.
any idea , please help...In the RPD i have join between base table and view .i'm selecting 2 columns one from base table and other from view . which gives cartesian product . to avoid that i want to put distinct . I'm not using any measure . I'm taking direct columns.
I'm getting distinct keyword if i'm accessing the report directly . but when i'm accessing it from dashboard in the back end while preparing the query it's writing distinct but the actual query which is sending to db does not have distinct.
==================================================
RqList distinct
VW_SCNR_114000074_TA_DATA.Match Identifier as c1 GB,
VW_SCNR_114000074_TA_DATA.Tot Trans Amt as c2 GB,
VW_SCNR_114000074_TA_DATA.Tot Trans Ct as c3 GB,
case when VW_SCNR_114000074_TA_DATA.Alert Quality Code = '1' then 'Productive' when VW_SCNR_114000074_TA_DATA.Alert Quality Code = '2' then 'Non Productive' else 'Indeterminate' end as c4 GB,
VW_SCNR_114000074_TA_DATA.Batch Identifier as c5 GB
DetailFilter: Alert TA Data.Run Id > 0 and Alert Scenarios.Scenario Name = 'ScnroName' and Alert TA Data.Batch Id > 0
OrderBy: c4 desc
=================================================
-------------------- Sending query to database named KYC1.1DEV-179 (id: <<16315>>):
select T353.BATCH_ID as c1,
case when T353.QLTY_RTG_CD = '1' then 'Productive' when T353.QLTY_RTG_CD = '2' then 'Non Productive' else 'Indeterminate' end as c2,
T353.TOT_TRXN_CT as c3,
T353.TOT_TRXN_AM as c4,
T353.BREAK_ID as c5,
T117.SCNRO_NM as c6
from
KDD_SCNRO T117,
KDD_TA_DATA T130,
KDD_TSHLD_SET T171,
VW_SCNR_114000074_TA_DATA T353
where ( T117.SCNRO_ID = T130.SCNRO_ID and T117.SCNRO_ID = T171.SCNRO_ID and T130.SCNRO_ID = T171.SCNRO_ID and T130.SCNRO_ID = T353.SCNRO_ID and T130.TSHLD_SET_ID = T171.TSHLD_SET_ID and T171.SCNRO_ID = T353.SCNRO_ID and T171.TSHLD_SET_ID = T353.TSHLD_SET_ID and 0 < T130.BATCH_ID and 0 < T130.RUN_ID ) -
Please reply:how to avoid extra trailing spaces while using cursor sharing
i am using cursor sharing with FORCE or SIMILAR.
what is the solution to avoid extra trailing spaces without any java code change.
do we have any option in oracle to avoid extra trailing spaces during the query processing ?
I am using Oracle 10g
CURSOR SHARING is a feature in which multiple sql statements
which are same will have a shared cursor (in the library cache) for an oracle session,
i.e, the first three steps of the sql processing (hard parse, soft parse, optimization)
will be done only the first time that kind of statement is executed.
There are two ways in which similar SQL statements with different condition values can be made to "SHARE" cursor during execution:
1. Writing SQLs with Bind Variables: SQLs having no hard coded literals in them
For e.g., the query below
SELECT node.emp_name AS configid
FROM emp node
WHERE emp_no = :1
AND dept_no =
DECODE (SUBSTR (:2, 1, 3),
:3, :4,
(SELECT MAX (dept_no)
FROM emp
WHERE emp_no = :5 AND dept_no <= :6)
AND node.dept_type = :7
ORDER BY node.emp_name
Here all the variables are dynamically bound during the execution. The ":X" represents BIND Variable and the actual values are bound to the SQL only at the 4th step of the execution of the SQL.
In applications: The queries written with "?" as bind variables will be converted into ":X" and are sqls with Bind Variables.
2. The CURSOR_SHARING parameter: Only Useful for SQL statements containing literals:
For eg., the query below:
SELECT node.emp_name AS configid
FROM emp node
WHERE emp_no = 'H200'
AND dept_no =
DECODE (SUBSTR (:1, 1, 3),
'PLN', :2,
(SELECT MAX (dept_no)
FROM emp
WHERE emp_no = :3 AND dept_no <= :4)
AND node.dept_type = :5
ORDER BY node.emp_name
In the query above, there are two hard coded literals H200 , PLN. In this case when the same SQL executed with different values like (H2003 , PLN), oracle will create a new cursor for this statement and all the first three steps ( hard & soft parse and optimization plan) needs to be done again.
This can be avoided by changing the CURSOR_SHARING parameter which can be set to any of three values:
1. EXACT: Causes the mechanism not be used, i.e. no cursor sharing for statements with different literals. This is the default value.
2. FORCE: Causes unconditional sharing of SQL statements that only differ in literals.
3. SIMILAR: Causes cursor sharing to take place when this is known not to have any impact on optimization.
So, FORCE and SIMILAR values of the parameter will be helping in cursor sharing and improve the performance of the SQLs having literals.
But here the problem arises if we use the FORCE and SIMILAR other than EXACT.
alter session set cursor_sharing ='EXACT'
select 1 from dual;
'1'
1
alter session set curson_sharing='FORCE'
select 2 from dual;
'2'
2
alter session set curson_sharing='SIMILAR'
select 3 from dual;
'3'
3
So, this will give extra trailing spaces in when we retrieve from java method and any
further java processing based on the hardcoded literal values will fail. this needs lot of
effort in remodifying the existing millions of lines of code.
My question is i have to use cursor sharing with FORCE or SIMILAR and can't we do the trimming
from the oracle query processing level ?
please help me on this ?
Message was edited by:
Leeladhar
Message was edited by:
LeeladharPlease reply to this thread
How to avoid extr trailing spaces using Cursor sharing opton FORCE, SIMILAR -
How to avoid Flickaring When Adding data in Addon User Matrix
Experts,
I am Adding Query Result in User Matrix one by one. but there is lots of Flicker.
how to Avoid this Flickering.
Bomiitems = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
If Bomtyp = "U" And BomNo = "0" Then
BOMItem = "SELECT Distinct T0.[Code], T1.[ItemName] , ( 1 / Isnull(T2.[Qauntity],0))* Isnull((T0.[Quantity]),0),('" & Quanti & "'/ Isnull(T2.[Qauntity],0))* Isnull((T0.[Quantity]),0) as "
BOMItem = BOMItem + " 'Quanti',T1.[Excisable],'N' as U_Rec , T1.[InvntryUom],T0.[Warehouse] 'Warehouse',T0.[IssueMthd]'IssMthd' FROM ITT1 T0 INNER JOIN OITM T1 "
BOMItem = BOMItem + " ON T0.Code = T1.ItemCode INNER JOIN OITT T2 ON T0.Father = T2.Code "
BOMItem = BOMItem + " WHERE T0.[Father] ='" & Icode & "'"
Bomiitems.DoQuery(BOMItem)
ElseIf Bomtyp = "U" And BomNo <> "0" Then
'BOMItem = "SELECT T0.[Code], T1.[ItemName] , ((T0.[Quantity]/ T2.[Qauntity])*'" & Quanti & "') as 'Quanti',T1.[Excisable],'N' as U_Rec FROM ITT1 T0 INNER JOIN OITM T1 ON T0.Code = T1.ItemCode INNER JOIN OITT T2 ON T0.Father = T2.Code WHERE T0.[Father] ='" & Icode & "'"
BOMItem = "SELECT T1.[U_Icode], T1.[U_IName],(1 / Isnull(Cast( T0.[U_Bqty] as Float) ,0)) * Isnull(Cast(T1.[U_Quanti] As Float),0) ,('" & Quanti & "' / Isnull(Cast( T0.[U_Bqty] as Float) ,0)) * Isnull(Cast(T1.[U_Quanti] As Float),0) as 'Quanti',T2.[Excisable], T0.[U_Rec],T2.[InvntryUom] ,T1.[U_Whs] 'Warehouse','B' AS 'IssMthd' "
BOMItem = BOMItem + "FROM [dbo].[@OITTA] T0 inner join [dbo].[@ITTA1] "
BOMItem = BOMItem + "T1 on t0.cODE = t1.Code INNER JOIN OITM T2 ON T1.[U_Icode] = T2.[ItemCode]"
BOMItem = BOMItem + " WHERE T0.[U_Icode] = '" & Icode & "' AND T0.[U_AltBom] ='" & BomNo & "' AND T0.U_Btyp = 'U' "
Bomiitems.DoQuery(BOMItem)
ElseIf Bomtyp = "P" Then
BOMItem = "SELECT T1.[U_Icode], T1.[U_IName],(1 / Isnull(Cast( T0.[U_Bqty] as Float) ,0)) * Isnull(Cast(T1.[U_Quanti] As Float),0),('" & Quanti & "' / Isnull(Cast( T0.[U_Bqty] as Float) ,0)) * Isnull(Cast(T1.[U_Quanti] As Float),0) as 'Quanti',T2.[Excisable], T0.[U_Rec] ,T2.[InvntryUom],T1.[U_Whs] 'Warehouse','B' AS 'IssMthd' "
BOMItem = BOMItem + "FROM [dbo].[@OITTA] T0 inner join [dbo].[@ITTA1] "
BOMItem = BOMItem + "T1 on t0.cODE = t1.Code INNER JOIN OITM T2 ON T1.[U_Icode] = T2.[ItemCode]"
BOMItem = BOMItem + " WHERE T0.[U_Icode] = '" & Icode & "' AND T0.[U_AltBom] ='" & BomNo & "' AND T0.U_Btyp = 'P' "
Bomiitems.DoQuery(BOMItem)
End If
Bomiitems.DoQuery(BOMItem)
If Bomiitems.RecordCount > 0 Then
'RecCount1 = RecSet1.RecordCount
Bomiitems.MoveFirst()
i = 0
'osubForm .Freeze(True)
oMatrix = oForm.Items.Item("1000001").Specific
oMatrix.FlushToDataSource()
While Not (Bomiitems.EoF)
If i = 0 Then
oMatrix.AddRow()
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("LineId", 0, i + 1)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_ItemCode", 0, Bomiitems.Fields.Item(0).Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_ItemName", 0, Bomiitems.Fields.Item(1).Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_BaseQty", 0, Bomiitems.Fields.Item(2).Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_PlanQty", 0, Bomiitems.Fields.Item(3).Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_IssueQty", 0, Bomiitems.Fields.Item(3).Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_Whs", 0, Bomiitems.Fields.Item("Warehouse").Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_IsueType", 0, Bomiitems.Fields.Item("IssMthd").Value)
Dim orsWhsDetails As SAPbobsCOM.Recordset
Dim strWhsDetails As String
orsWhsDetails = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
strWhsDetails = "SELECT T0.[OnHand], T0.[IsCommited], T0.[OnOrder],T1.[OnHand] FROM OITW T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode WHERE T0.[ItemCode] ='" & Bomiitems.Fields.Item(0).Value & "' AND T0.[WhsCode] ='" & Bomiitems.Fields.Item("Warehouse").Value & "' "
orsWhsDetails.DoQuery(strWhsDetails)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_Whsestk", 0, orsWhsDetails.Fields.Item(0).Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_AVILSTK", 0, (orsWhsDetails.Fields.Item(0).Value - Bomiitems.Fields.Item(3).Value))
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_PLANTSTK", 0, orsWhsDetails.Fields.Item(3).Value)
oMatrix.LoadFromDataSource()
Else
oMatrix.FlushToDataSource()
oForm.DataSources.DBDataSources.Item("@TPROD1").InsertRecord(i)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("LineId", i, i + 1)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_ItemCode", i, Bomiitems.Fields.Item(0).Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_ItemName", i, Bomiitems.Fields.Item(1).Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_BaseQty", i, Bomiitems.Fields.Item(2).Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_PlanQty", i, Bomiitems.Fields.Item(3).Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_IssueQty", i, Bomiitems.Fields.Item(3).Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_Whs", i, Bomiitems.Fields.Item("Warehouse").Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_IsueType", i, Bomiitems.Fields.Item("IssMthd").Value)
Dim orsWhsDetails As SAPbobsCOM.Recordset
Dim strWhsDetails As String
orsWhsDetails = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
strWhsDetails = "SELECT T0.[OnHand], T0.[IsCommited], T0.[OnOrder],T1.[OnHand] FROM OITW T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode WHERE T0.[ItemCode] ='" & Bomiitems.Fields.Item(0).Value & "' AND T0.[WhsCode] ='" & Bomiitems.Fields.Item("Warehouse").Value & "' "
orsWhsDetails.DoQuery(strWhsDetails)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_Whsestk", i, orsWhsDetails.Fields.Item(0).Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_AVILSTK", i, (orsWhsDetails.Fields.Item(0).Value - Bomiitems.Fields.Item(3).Value))
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_PLANTSTK", i, orsWhsDetails.Fields.Item(3).Value)
oMatrix.LoadFromDataSource()
End If
i = i + 1
Bomiitems.MoveNext()
oMatrix.LoadFromDataSource()
End While
oMatrix.LoadFromDataSource()
End If
Regards,
Pravin Bajifollow steps
1) Execute query so we can get data set
2) Clear matrix and data source (omatrix.clear(), oDBS.Clear())
3) Open loop
4) Insert record to oDBS using oDBS.InsertRecords(oDBS.Offset)
5) Then set value using oDBS.Setvalue(u2026u2026
6) Move next record
7) Finally close the loop
8) Matrix load from record set using oMatrix.LoadfromData()
it will be work -
How to avoid spaces in csv file at the time of spooling
Hi all,
I am spooling 30 query results into one CSV file ,I am getting two empty rows for each query.
Can any one suggest me how to avoid these spaces.
Thanks & Regards,
P Prakash
this is the script i am using to generate csv file .
SET linesize 12000
SET pagesize 10000
SET pause off
SET termout off
SET feed off
SET head off
SPOOL c:\tes111.csv replace
SELECT 'ISA01,ISA02,ISA03,ISA04,ISA05,ISA06,ISA07,ISA08,ISA09,ISA11,ISA12,ISA13,ISA14,ISA15,ISA16,GS01,GS02,GS03,GS04,GS05,GS06,GS07,GS08,ST01,ST02,ST03,BHT01,BHT02,BHT03,BHT04,BHT06,trnsctn_segment_count,included_trnsctn_sets_count,included_fnctnl_groups_count,input_acknwldgmnt_sid'
FROM DUAL;
SELECT ptr.athrztn_infrmtn_qlfr
|| ','
|| ptr.athrztn_infrmtn
|| ','
|| ptr.scrty_infrmtn_qlfr
|| ','
|| ptr.scrty_infrmtn
|| ','
|| ptr.intrchng_sndr_idntfr_qlfr
|| ','
|| ptr.intrchng_sndr_idntfr
|| ','
|| ptr.intrchng_rcvr_idntfr_qlfr
|| ','
|| ptr.intrchng_rcvr_idntfr
|| ','
|| ptr.intrchng_date
|| ','
|| ptr.intrchng_cntrl_stndrds_idntfr
|| ','
|| ptr.intrchng_cntrl_vrsn_nmbr
|| ','
|| ptr.intrchng_cntrl_nmbr
|| ','
|| ptr.acknwldgmnt_rqstd_indctr
|| ','
|| ptr.usg_indctr
|| ','
|| ptr.cmpnt_elmnt_sprtr
|| ','
|| ptr.fnctnl_idntfr_code
|| ','
|| ptr.aplctn_sndr_code
|| ','
|| ptr.applctn_rcvr_code
|| ','
|| ptr.fnctnl_grp_crtn_date
|| ','
|| ptr.fnctnl_grp_crtn_date
|| ','
|| ptr.grp_cntrl_nmbr
|| ','
|| ptr.rspnsbl_agncy_code
|| ','
|| ptr.vrsn_rls_indstry_idntfr_code
|| ','
|| ptr.trnsctn_set_idntfr_code
|| ','
|| ptr.trnsctn_set_cntrl_nmbr
|| ','
|| ptr.implementation_guide_vrsn_name
|| ','
|| ptr.hierarchical_structure_code
|| ','
|| ptr.trnsctn_set_purpose_lkpcd
|| ','
|| ptr.sbmtr_trnsctn_idntfr
|| ','
|| ptr.trnsctn_set_creation_date
|| ','
|| ptr.trnsctn_type_code
|| ','
|| ptr.trnsctn_segment_count
|| ','
|| ptr.included_trnsctn_sets_count
|| ','
|| ptr.included_fnctnl_groups_count
|| ','
|| ia.input_acknwldgmnt_sid
|| ','
FROM pa_transaction_request ptr, input_acknwldgmnt ia, input_batch_file ibf
WHERE ptr.input_acknwldgmnt_sid = ia.input_acknwldgmnt_sid
AND ia.input_batch_file_sid = ibf.input_batch_file_sid
AND ibf.original_file_name =
'HIPAA.165760000.20110518I001.278_GC04-3.dat';
SELECT 'pa_rqst_sid,NM01,NM02,NM108,NM109'
FROM DUAL;
SELECT pr.pa_rqst_sid
|| ','
|| pr.entity_idntfr_lkpcd
|| ','
|| pr.entity_type_qlfr
|| ','
|| pr.payer_idntfctn_code_qlfr
|| ','
|| pr.payer_idntfctn_code
|| ','
FROM pa_request pr,
pa_transaction_request ptr,
input_acknwldgmnt ia,
input_batch_file ibf
WHERE pr.pa_trnsctn_rqst_sid = ptr.pa_trnsctn_rqst_sid
AND ptr.input_acknwldgmnt_sid = ia.input_acknwldgmnt_sid
AND ia.input_batch_file_sid = ibf.input_batch_file_sid
AND ibf.original_file_name =
'HIPAA.165760000.20110518I001.278_GC04-3.dat';
SELECT 'meta_data_cid,data_value,iteration_number,Created_by,modified_by'
FROM DUAL;
SELECT prs.meta_data_cid
|| ','
|| prs.data_value
|| ','
|| prs.iteration_number
|| ','
|| prs.created_by
|| ','
|| prs.modified_by
|| ','
FROM pa_request pr,
pa_transaction_request ptr,
input_acknwldgmnt ia,
input_batch_file ibf,
pa_request_situational prs
WHERE pr.pa_rqst_sid = prs.pa_rqst_sid
AND prs.stnl_target_table_cid = 100
AND prs.target_table_sid = pr.pa_rqst_sid
AND pr.pa_trnsctn_rqst_sid = ptr.pa_trnsctn_rqst_sid
AND ptr.input_acknwldgmnt_sid = ia.input_acknwldgmnt_sid
AND ia.input_batch_file_sid = ibf.input_batch_file_sid
AND ibf.original_file_name =
'HIPAA.165760000.20110518I001.278_GC04-3.dat';
SELECT 'NM101 ,NM103,NM104,NM105,NM108,NM109,PER02,PER04,PER05,PER06,PER07 ,PER08'
FROM DUAL;
SELECT pr.pa_rqst_sid
|| ','
|| prpl.pa_rqst_x_prvdr_lctn_sid
|| ','
|| prpl.rqstr_entity_idntfr_lkpcd
|| ','
|| prpl.last_name
|| ','
|| prpl.first_name
|| ','
|| prpl.middle_name
|| ','
|| prpl.idntfr_type_cid
|| ','
|| prpl.prvdr_lctn_iid
|| ','
|| prpl.rqstr_contact_name
|| ','
|| prpl.cmnctn_nmbr_1
|| ','
|| prpl.cmnctn_nmbr_2
|| ','
|| prpl.cmnctn_nmbr_type_lkpcd_1
|| ','
|| prpl.cmnctn_nmbr_type_lkpcd_2
|| ','
|| prpl.cmnctn_nmbr_type_lkpcd_3
FROM pa_request_x_provider_location prpl,
pa_request pr,
pa_transaction_request ptr,
input_acknwldgmnt ia,
input_batch_file ibf
WHERE prpl.pa_rqst_sid = pr.pa_rqst_sid
AND pr.pa_trnsctn_rqst_sid = ptr.pa_trnsctn_rqst_sid
AND ptr.input_acknwldgmnt_sid = ia.input_acknwldgmnt_sid
AND ia.input_batch_file_sid = ibf.input_batch_file_sid
AND ibf.original_file_name =
'HIPAA.165760000.20110518I001.278_GC04-3.dat'
AND prpl.pa_prvdr_type_lkpcd = 'RR';
SELECT 'meta_data_cid,data_value,iteration_number,Created_by,modified_by'
FROM DUAL;
SELECT prs.meta_data_cid
|| ','
|| prs.data_value
|| ','
|| prs.iteration_number
|| ','
|| prs.created_by
|| ','
|| prs.modified_by
|| ','
FROM pa_request_x_provider_location prpl,
pa_request pr,
pa_transaction_request ptr,
input_acknwldgmnt ia,
input_batch_file ibf,
pa_request_situational prs
WHERE prpl.pa_rqst_sid = prs.pa_rqst_sid
AND prs.stnl_target_table_cid = 102
AND prs.target_table_sid = prpl.pa_rqst_x_prvdr_lctn_sid
AND prpl.pa_rqst_sid = pr.pa_rqst_sid
AND pr.pa_trnsctn_rqst_sid = ptr.pa_trnsctn_rqst_sid
AND ptr.input_acknwldgmnt_sid = ia.input_acknwldgmnt_sid
AND ia.input_batch_file_sid = ibf.input_batch_file_sid
AND ibf.original_file_name =
'HIPAA.165760000.20110518I001.278_GC04-3.dat'
AND prpl.pa_prvdr_type_lkpcd = 'RR';
-- 4. Subscriber
NM103 Name Last or Organization Name
NM104 Name First
NM108 Identification Code Qualifier
NM109 Identification Code
DMG02 Date Time Period birth date
DMG03 Gender Code
SELECT ' NM103,NM104,NM108,NM109,DMG02,DMG03'
FROM DUAL;
SELECT prxm.last_name
|| ','
|| prxm.first_name
|| ','
|| prxm.idntfr_type_cid
|| ','
|| prxm.mbr_idntfr
|| ','
|| prxm.birth_date
|| ','
|| prxm.gender_lkpcd
|| ','
FROM pa_request_x_member prxm,
pa_request pr,
pa_transaction_request ptr,
input_acknwldgmnt ia,
input_batch_file ibf
WHERE prxm.pa_rqst_sid = pr.pa_rqst_sid
AND pr.pa_trnsctn_rqst_sid = ptr.pa_trnsctn_rqst_sid
AND ptr.input_acknwldgmnt_sid = ia.input_acknwldgmnt_sid
AND ia.input_batch_file_sid = ibf.input_batch_file_sid
AND ibf.original_file_name =
'HIPAA.165760000.20110518I001.278_GC04-3.dat';
-- 5. Subscriber Situational Info
NM102 Entity Type Qualifier
NM105 Name Middle
NM107 Name Suffix
REF01 Reference Identification Qualifier
REF02 Reference Identification
N301 Address Information
N302 Address Information
N401 City Name
N402 State or Province Code
N403 Postal Code
N407 Country Subdivision Code
SELECT 'meta_data_cid,data_value,iteration_number,Created_by,modified_by'
FROM DUAL;
SELECT prs.meta_data_cid
|| ','
|| prs.data_value
|| ','
|| prs.iteration_number
|| ','
|| prs.created_by
|| ','
|| prs.modified_by
|| ','
FROM pa_request_x_member prxm,
pa_request pr,
pa_transaction_request ptr,
input_acknwldgmnt ia,
input_batch_file ibf,
pa_request_situational prs
WHERE prxm.pa_rqst_sid = pr.pa_rqst_sid
AND pr.pa_trnsctn_rqst_sid = ptr.pa_trnsctn_rqst_sid
AND ptr.input_acknwldgmnt_sid = ia.input_acknwldgmnt_sid
AND ia.input_batch_file_sid = ibf.input_batch_file_sid
AND prs.stnl_target_table_cid = 101
AND prs.target_table_sid = prxm.pa_rqst_x_mbr_sid
AND ibf.original_file_name =
'HIPAA.165760000.20110518I001.278_GC04-3.dat';
-- 6. Patient Event Level
TRN02 Reference Identification
TRN03 Originating Company Identifier
TRN04 Reference Identification
UM01 Request Category Code
UM02 Certification Type Code
UM03 Service Type Code
UM04-1 Facility Code Value
UM04-2 Facility Code Qualifier
UM06 Level of Service Code
UM07 Current Health Condition Code
UM08 Prognosis Code
UM09 Release of Information Code
UM10 Delay Reason Code
SELECT 'TRN02,TRN03,TRN04,UMO1,UMO2,UM04_1,UM04_2,UM06,UM07,UM08,UM09,UM10,'
FROM DUAL;
SELECT prd.patient_event_tracking_number
|| ','
|| prd.orginating_company_identifier
|| ','
|| prd.trace_assigning_entity_idntfr
|| ','
|| prs.rqst_ctgry_lkpcd
|| ','
|| prs.rqst_crtfctn_type_lkpcd
|| ','
|| prs.x12_pa_srvc_type_code
|| ','
|| prs.facility_type_code
|| ','
|| prs.unfrm_blng_facility_type_code
|| ','
|| prs.srvc_rqd_lkpcd
|| ','
|| prs.current_health_cndtn_lkpcd
|| ','
|| prs.prognosis_lkpcd
|| ','
|| prs.rls_of_info_lkpcd
|| ','
|| prs.delay_reason_lkpcd
|| ','
FROM pa_request_service prs,
pa_request pr,
pa_transaction_request ptr,
input_acknwldgmnt ia,
input_batch_file ibf,
pa_request_detail prd
WHERE prs.pa_rqst_sid = pr.pa_rqst_sid
AND pr.pa_trnsctn_rqst_sid = ptr.pa_trnsctn_rqst_sid
AND ptr.input_acknwldgmnt_sid = ia.input_acknwldgmnt_sid
AND ia.input_batch_file_sid = ibf.input_batch_file_sid
AND pr.pa_rqst_sid = prd.pa_rqst_sid
AND ibf.original_file_name =
'HIPAA.165760000.20110518I001.278_GC04-3.dat';
--Patient Event Level situational information
SELECT 'meta_data_cid,data_value,iteration_number,Created_by,modified_by'
FROM DUAL;
SELECT prs.meta_data_cid
|| ','
|| prs.data_value
|| ','
|| prs.iteration_number
|| ','
|| prs.created_by
|| ','
|| prs.modified_by
|| ','
FROM pa_request_service prsv,
pa_request pr,
pa_transaction_request ptr,
input_acknwldgmnt ia,
input_batch_file ibf,
pa_request_situational prs
WHERE prsv.pa_rqst_sid = pr.pa_rqst_sid
AND pr.pa_trnsctn_rqst_sid = ptr.pa_trnsctn_rqst_sid
AND ptr.input_acknwldgmnt_sid = ia.input_acknwldgmnt_sid
AND ia.input_batch_file_sid = ibf.input_batch_file_sid
AND prs.stnl_target_table_cid = 103
AND prs.target_table_sid = prsv.pa_rqst_srvc_sid
AND ibf.original_file_name =
'HIPAA.165760000.20110518I001.278_GC04-3.dat';
---Diagnosis
HI01 Health Care Code Information
HI01-1 Code List Qualifier Code
HI01-2 Industry Code
HI01-3 Date Time Period Format Qualifier
HI01-4 Date Time Period
SELECT 'HI01_1,HI01_2,HI01_3'
FROM DUAL;
SELECT prd.pa_diagnosis_type_lkpcd
|| ','
|| prd.diagnosis_iid
|| ','
|| prd.from_date
|| ','
FROM pa_request_x_diagnosis prd,
pa_request pr,
pa_transaction_request ptr,
input_acknwldgmnt ia,
input_batch_file ibf
WHERE prd.pa_rqst_sid = pr.pa_rqst_sid
AND pr.pa_trnsctn_rqst_sid = ptr.pa_trnsctn_rqst_sid
AND ptr.input_acknwldgmnt_sid = ia.input_acknwldgmnt_sid
AND ia.input_batch_file_sid = ibf.input_batch_file_sid
AND ibf.original_file_name =
'HIPAA.165760000.20110518I001.278_GC04-3.dat';
-- Request detail
TRN02 Reference Identification
TRN03 Originating Company Identifier
TRN04 Reference Identification
SELECT 'TRN02,TRN03,TRN04'
FROM DUAL;
SELECT prd.patient_event_tracking_number
|| ','
|| prd.orginating_company_identifier
|| ','
|| prd.trace_assigning_entity_idntfr
|| ','
FROM pa_request_detail prd,
pa_request pr,
pa_transaction_request ptr,
input_acknwldgmnt ia,
input_batch_file ibf
WHERE prd.pa_rqst_sid = pr.pa_rqst_sid
AND pr.pa_trnsctn_rqst_sid = ptr.pa_trnsctn_rqst_sid
AND ptr.input_acknwldgmnt_sid = ia.input_acknwldgmnt_sid
AND ia.input_batch_file_sid = ibf.input_batch_file_sid
AND ibf.original_file_name =
'HIPAA.165760000.20110518I001.278_GC04-3.dat';
-- ambulance Transaportation
CR101 Unit or Basis for Measurement Code
CR102 Weight
CR103 Ambulance Transport Code
CR104 Ambulance Transport Reason Code
CR105 Unit or Basis for Measurement Code
CR106 Quantity
CR109 Description
CR110 Description
SELECT 'CR101,CR102,CR103,CR104,CR105,CR106,CR109,CR110'
FROM DUAL;
SELECT pat.weight_uom_code
|| ','
|| pat.patient_weight
|| ','
|| pat.amblnc_transport_type_lkpcd
|| ','
|| pat.amblnc_transport_rsn_lkpcd
|| ','
|| pat.distance_uom_code
|| ','
|| pat.trnsprtn_distance
|| ','
|| pat.round_trip_purpose_desc
|| ','
|| pat.stretcher_purpose_desc
|| ','
FROM pa_request_ambulance_transport pat,
pa_request pr,
pa_transaction_request ptr,
input_acknwldgmnt ia,
input_batch_file ibf
WHERE pat.pa_rqst_sid = pr.pa_rqst_sid
AND pr.pa_trnsctn_rqst_sid = ptr.pa_trnsctn_rqst_sid
AND ptr.input_acknwldgmnt_sid = ia.input_acknwldgmnt_sid
AND ia.input_batch_file_sid = ibf.input_batch_file_sid
AND ibf.original_file_name =
'HIPAA.165760000.20110518I001.278_GC04-3.dat';
-- 2000F SV1
SV101-1 Product/Service ID Qualifier Change values
SV101-2 Product/Service ID Need to change label to Procedure Code.
SV101-3 Procedure Modifier No change required to PA screen
SV101-4 Procedure Modifier No change required to PA screen
SV101-5 Procedure Modifier No change required to PA screen
SV101-6 Procedure Modifier No change required to PA screen
SV101-7 Description No change required to PA screen. Will map to the Remarks field on the Screen
SV102 Monetary Amount
SV103 Unit or Basis for Measurement Code
SV104 Quantity
SV107 Composite Diagnosis Code Pointer
SV107-1 Diagnosis Code Pointer
SV107-2 Diagnosis Code Pointer
SV107-3 Diagnosis Code Pointer
SV107-4 Diagnosis Code Pointer
SV111 Yes/No Condition or Response Code
SV120 Level of Care Code
SELECT 'TRN_Reference_Identif,TRN_Originating_CMP_Identif,TRN_Reference_IdentiReference Identiff,Reference_Identif,Reference_Identification,Reference_Identif,Product/Service_ID_Qualifier,Product/Service_ID,Procedure_Modifier,Procedure_Modifier,Procedure_Modifier,Procedure_Modifier,Description'
FROM DUAL;
SELECT prp.srvc_trace_nmbr_1
|| ','
|| prp.trace_asgn_enty_adtnl_idntfr_1
|| ','
|| prp.trace_asgn_enty_adtnl_idntfr_1
|| ','
|| prp.trace_asgn_enty_adtnl_idntfr_2
|| ','
|| prp.prvs_rvw_athrztn_nmbr
|| ','
|| prp.prvs_administrative_rfrnc_nmbr
|| ','
|| prp.x12_code_list_qlfr_lkpcd
|| ','
|| prp.procedure_iid
|| ','
|| prp.mdfr_code
|| ','
|| prp.mdfr2_code
|| ','
|| prp.mdfr3_code
|| ','
|| prp.mdfr4_code
|| ','
|| prp.drug_desc
|| ','
FROM pa_request_procedure prp,
pa_request_service prs,
pa_request pr,
pa_transaction_request ptr,
input_acknwldgmnt ia,
input_batch_file ibf
WHERE prp.pa_rqst_srvc_sid = prs.pa_rqst_srvc_sid
AND prs.pa_rqst_sid = pr.pa_rqst_sid
AND pr.pa_trnsctn_rqst_sid = ptr.pa_trnsctn_rqst_sid
AND ptr.input_acknwldgmnt_sid = ia.input_acknwldgmnt_sid
AND ia.input_batch_file_sid = ibf.input_batch_file_sid
AND ibf.original_file_name =
'HHIPAA.165760000.20110518I001.278_GC04-3.dat';
SV2 SV201 Product/Service ID
SV2 SV202 Composite Medical Procedure Identifier
SV2 SV202-1 Product/Service ID Qualifier
SV2 SV202-2 Product/Service ID
SV2 SV202-3 Procedure Modifier
SV2 202-4 Procedure Modifier
SV2 SV202-5 Procedure Modifier
SV2 SV202-6 Procedure Modifier
SV2 SV202-7 Description
SV2 SV202-8 Product/Service ID
SV2 SV203 Monetary Amount
SV2 SV204 Unit or Basis for Measurement Code
SV2 SV205 Quantity
SV2 SV206 Unit Rate
SV2 SV209 Nursing Home Residential Status Code
SELECT 'Product/Service ID,Product/Service ID Qual,Product/Service ID,Product Modifier,Product Modifier,Product Modifier,Product Modifier,Description,Unit Rate,'
FROM DUAL;
SELECT prp.revenue_iid ||','||
prp.x12_code_list_qlfr_lkpcd ||','||
prp.procedure_iid ||','||
prp.mdfr_code ||','||
prp.mdfr2_code ||','||
prp.mdfr3_code ||','||
prp.mdfr4_code ||','|| prp.drug_desc ||','||
prp.srvc_line_rate ||','
FROM pa_request_procedure prp,
pa_request_service prs,
pa_request pr,
pa_transaction_request ptr,
input_acknwldgmnt ia,
input_batch_file ibf
WHERE prp.pa_rqst_srvc_sid = prs.pa_rqst_srvc_sid
AND prs.pa_rqst_sid = pr.pa_rqst_sid
AND pr.pa_trnsctn_rqst_sid = ptr.pa_trnsctn_rqst_sid
AND ptr.input_acknwldgmnt_sid = ia.input_acknwldgmnt_sid
AND ia.input_batch_file_sid = ibf.input_batch_file_sid
AND ibf.original_file_name =
'HIPAA.165760000.20110518I001.278_GC04-3.dat';
-- 2000F SV3
SV301 Composite Medical Procedure Identifier
SV301-1 Product/Service ID Qualifier
SV301-2 Product/Service ID
SV301-3 Procedure Modifier
SV301-4 Procedure Modifier
SV301-5 Procedure Modifier
SV301-6 Procedure Modifier
SV301-7 Description
SV301-8 Product/Service ID
SV302 Monetary Amount
SV304 Oral Cavity Designation
SV304-1 Oral Cavity Designation Code
SV304-2 Oral Cavity Designation Code
SV304-3 Oral Cavity Designation Code
SV304-4 Oral Cavity Designation Code
SV304-5 Oral Cavity Designation Code
SV305 Prosthesis, Crown or Inlay Code
SV306 Quantity
SV307 Description
select 'Product/Service ID Qual,Product/Service ID,Procedure Modifier,Procedure Modifier,Procedure Modifier,Procedure Modifier,Description,Oral Cavity Designation Code,Oral Cavity Designation Code,Oral Cavity Designation Code,Oral Cavity Designation Code,ProsthesisCrown Inlay Code,Description' from dual;
SELECT prp.x12_code_list_qlfr_lkpcd
|| ','
|| prp.procedure_iid
|| ','
|| prp.mdfr_code
|| ','
|| prp.mdfr2_code
|| ','
|| prp.mdfr3_code
|| ','
|| prp.mdfr4_code
|| ','
|| prp.drug_desc
|| ','
|| prp.oral_cavity_dsgntn2_cid
|| ','
|| prp.oral_cavity_dsgntn3_cid
|| ','
|| prp.oral_cavity_dsgntn4_cid
|| ','
|| prp.oral_cavity_dsgntn5_cid
|| ','
|| prp.prosthesis_crown_inlay_code
|| ','
|| prp.remark
|| ','
FROM pa_request_procedure prp,
pa_request_service prs,
pa_request pr,
pa_transaction_request ptr,
input_acknwldgmnt ia,
input_batch_file ibf
WHERE prp.pa_rqst_srvc_sid = prs.pa_rqst_srvc_sid
AND prs.pa_rqst_sid = pr.pa_rqst_sid
AND pr.pa_trnsctn_rqst_sid = ptr.pa_trnsctn_rqst_sid
AND ptr.input_acknwldgmnt_sid = ia.input_acknwldgmnt_sid
AND ia.input_batch_file_sid = ibf.input_batch_file_sid
AND ibf.original_file_name =
'HIPAA.165760000.20110518I001.278_GC04-3.dat';
-- 2000F TOO pending Prakash to Write
--Tooth Information
SELECT 'Industry Code,Tooth Surface,TOO03-1_Tooth Surface Code,TOO03-2_Tooth Surface Code,TOO03-3_Tooth Surface Code,TOO03-4_Tooth Surface Code,'
FROM DUAL;
SELECT prp.tooth_number_cid
|| ','
|| prp.tooth_surface_cid
|| ','
|| prp.tooth_surface2_cid
|| ','
|| prp.tooth_surface3_cid
|| ','
|| prp.tooth_surface4_cid
|| ','
|| prp.tooth_surface5_cid
|| ','
FROM pa_request_procedure prp,
pa_request_service prs,
pa_request pr,
pa_transaction_request ptr,
input_acknwldgmnt ia,
input_batch_file ibf
WHERE prp.pa_rqst_srvc_sid = prs.pa_rqst_srvc_sid
AND prs.pa_rqst_sid = pr.pa_rqst_sid
AND pr.pa_trnsctn_rqst_sid = ptr.pa_trnsctn_rqst_sid
AND ptr.input_acknwldgmnt_sid = ia.input_acknwldgmnt_sid
AND ia.input_batch_file_sid = ibf.input_batch_file_sid
AND ibf.original_file_name =
'HIPAA.165760000.20110518I001.278_GC04-3.dat';
--tooth SItuational Information
select 'Monetary Amount,Quantity' from dual;
SELECT prpt.rqst_prcdr_amt||','|| prpt.rqst_prcdr_units||','
FROM pa_rqst_prcdr_transaction prpt,
pa_request_procedure prp,
pa_request_service prs,
pa_request pr,
pa_transaction_request ptr,
input_acknwldgmnt ia,
input_batch_file ibf
WHERE prpt.pa_rqst_prcdr_sid = prp.pa_rqst_prcdr_sid
AND prp.pa_rqst_srvc_sid = prs.pa_rqst_srvc_sid
AND prs.pa_rqst_sid = pr.pa_rqst_sid
AND pr.pa_trnsctn_rqst_sid = ptr.pa_trnsctn_rqst_sid
AND ptr.input_acknwldgmnt_sid = ia.input_acknwldgmnt_sid
AND ia.input_batch_file_sid = ibf.input_batch_file_sid
AND ibf.original_file_name =
'HIPAA.165760000.20110518I001.278_GC04-3.dat';
-- pa_rqst_prcdr_x_prvdr_lctn
select 'pa_rqst_prcdr_sid,pa_rqst_x_prvdr_lctn_sid' from dual;
SELECT prppl.pa_rqst_prcdr_sid||','|| prppl.pa_rqst_x_prvdr_lctn_sid||','
FROM pa_rqst_prcdr_x_prvdr_lctn prppl,
pa_request_procedure prp,
pa_request_service prs,
pa_request pr,
pa_transaction_request ptr,
input_acknwldgmnt ia,
input_batch_file ibf
WHERE prppl.pa_rqst_prcdr_sid = prp.pa_rqst_prcdr_sid
AND prp.pa_rqst_srvc_sid = prs.pa_rqst_srvc_sid
AND prs.pa_rqst_sid = pr.pa_rqst_sid
AND pr.pa_trnsctn_rqst_sid = ptr.pa_trnsctn_rqst_sid
AND ptr.input_acknwldgmnt_sid = ia.input_acknwldgmnt_sid
AND ia.input_batch_file_sid = ibf.input_batch_file_sid
AND ibf.original_file_name =
'HIPAA.165760000.20110518I001.278_GC04-3.dat';
-- error Details
--Header level error details
SELECT 'pa_rqst_sid,pa_error_nmbr,pa_error_sid,reject_reason_lkpcd,follow_up_action_lkpcd,aaa_segment_loop_nmbr,run_nmbr,'
FROM DUAL;
SELECT prre.pa_rqst_sid
|| ','
|| pe.pa_error_nmbr
|| ','
|| pe.pa_error_sid
|| ','
|| ped.reject_reason_lkpcd
|| ','
|| ped.follow_up_action_lkpcd
|| ','
|| ped.aaa_segment_loop_nmbr
|| ','
|| prre.run_nmbr
|| ','
FROM pa_request pr,
pa_transaction_request ptr,
input_acknwldgmnt ia,
input_batch_file ibf,
pa_request_run_error prre,
pa_error pe,
pa_error_detail ped
WHERE pr.pa_trnsctn_rqst_sid = ptr.pa_trnsctn_rqst_sid
AND ptr.input_acknwldgmnt_sid = ia.input_acknwldgmnt_sid
AND ia.input_batch_file_sid = ibf.input_batch_file_sid
AND pr.pa_rqst_sid = prre.pa_rqst_sid
AND prre.pa_error_sid = pe.pa_error_sid
AND pe.pa_error_sid = ped.pa_error_sid
AND ibf.original_file_name =
'HIPAA.165760000.20110518I001.278_GC04-3.dat';
---Line Level Error Details
SELECT 'pa_rqst_sid,pa_error_nmbr,pa_error_sid,reject_reason_lkpcd,follow_up_action_lkpcd,aaa_segment_loop_nmbr'
FROM DUAL;
SELECT pr.pa_rqst_sid
|| ','
|| pe.pa_error_nmbr
|| ','
|| pe.pa_error_sid
|| ','
|| ped.reject_reason_lkpcd
|| ','
|| ped.follow_up_action_lkpcd
|| ','
|| ped.aaa_segment_loop_nmbr
|| ','
FROM pa_request pr,
pa_transaction_request ptr,
input_acknwldgmnt ia,
input_batch_file ibf,
pa_request_service prs,
pa_request_procedure prp,
pa_request_procedure_run_error prpre,
pa_error pe,
pa_error_detail ped
WHERE pr.pa_trnsctn_rqst_sid = ptr.pa_trnsctn_rqst_sid
AND ptr.input_acknwldgmnt_sid = ia.input_acknwldgmnt_sid
AND ia.input_batch_file_sid = ibf.input_batch_file_sid
AND pr.pa_rqst_sid = prs.pa_rqst_sid
AND prs.pa_rqst_srvc_sid = prp.pa_rqst_srvc_sid
AND prp.pa_rqst_prcdr_sid = prpre.pa_rqst_prcdr_sid
AND prpre.pa_error_sid = pe.pa_error_sid
AND pe.pa_error_sid = ped.pa_error_sid
AND ibf.original_file_name =
'HIPAA.165760000.20110518I001.278_GC04-3.dat';
SPOOL off
SET head on
SET feed on
SET termout on
SET pause on833560 wrote:
Hi all,
I am spooling 30 query results into one CSV file ,I am getting two empty rows for each query.
Can any one suggest me how to avoid these spaces.
Thanks & Regards,
P Prakash
this is the script i am using to generate csv file .
SET linesize 12000
SET pagesize 10000
SET pause off
SET termout off
SET feed off
SET head off
SPOOL c:\tes111.csv replace
SELECT 'ISA01,ISA02,ISA03,ISA04,ISA05,ISA06,ISA07,ISA08,ISA09,ISA11,ISA12,ISA13,ISA14,ISA15,ISA16,GS01,GS02,GS03,GS04,GS05,GS06,GS07,GS08,ST01,ST02,ST03,BHT01,BHT02,BHT03,BHT04,BHT06,trnsctn_segment_count,included_trnsctn_sets_count,included_fnctnl_groups_count,input_acknwldgmnt_sid'
FROM DUAL;
SELECT ptr.athrztn_infrmtn_qlfr
|| ','
|| ptr.athrztn_infrmtn
|| ','
|| ptr.scrty_infrmtn_qlfr
|| ','
|| ptr.scrty_infrmtn
|| ','
|| ptr.intrchng_sndr_idntfr_qlfr
|| ','
|| ptr.intrchng_sndr_idntfr
|| ','
|| ptr.intrchng_rcvr_idntfr_qlfr
|| ','
|| ptr.intrchng_rcvr_idntfr
|| ','
|| ptr.intrchng_date
|| ','
|| ptr.intrchng_cntrl_stndrds_idntfr
|| ','
|| ptr.intrchng_cntrl_vrsn_nmbr
|| ','
|| ptr.intrchng_cntrl_nmbr
|| ','
|| ptr.acknwldgmnt_rqstd_indctr
|| ','
|| ptr.usg_indctr
|| ','
|| ptr.cmpnt_elmnt_sprtr
|| ','
|| ptr.fnctnl_idntfr_code
|| ','
|| ptr.aplctn_sndr_code
|| ','
|| ptr.applctn_rcvr_code
|| ','
|| ptr.fnctnl_grp_crtn_date
|| ','
|| ptr.fnctnl_grp_crtn_date
|| ','
|| ptr.grp_cntrl_nmbr
|| ','
|| ptr.rspnsbl_agncy_code
|| ','
|| ptr.vrsn_rls_indstry_idntfr_code
|| ','
|| ptr.trnsctn_set_idntfr_code
|| ','
|| ptr.trnsctn_set_cntrl_nmbr
|| ','
|| ptr.implementation_guide_vrsn_name
|| ','
|| ptr.hierarchical_structure_code
|| ','
|| ptr.trnsctn_set_purpose_lkpcd
|| ','
|| ptr.sbmtr_trnsctn_idntfr
|| ','
|| ptr.trnsctn_set_creation_date
|| ','
|| ptr.trnsctn_type_code
|| ','
|| ptr.trnsctn_segment_count
|| ','
|| ptr.included_trnsctn_sets_count
|| ','
|| ptr.included_fnctnl_groups_count
|| ','
|| ia.input_acknwldgmnt_sid
|| ','
FROM pa_transaction_request ptr, input_acknwldgmnt ia, input_batch_file ibf
WHERE ptr.input_acknwldgmnt_sid = ia.input_acknwldgmnt_sid
AND ia.input_batch_file_sid = ibf.input_batch_file_sid
AND ibf.original_file_name =
'HIPAA.165760000.20110518I001.278_GC04-3.dat';
SELECT 'pa_rqst_sid,NM01,NM02,NM108,NM109'
FROM DUAL;
Hi ,
Save your query in a file and execute that file
SQL>@a.aqlHope this helps
Regards,
Achyut -
Avoid distinct clause in the query
hi i have a query from a single table using distinct clause and has columns (a,b,c,d,e,f,g,h,i)
eg: select distinct a,b ,c,d from table
where a<>0 and b<>0 and c<>0 and d<>0 and e=o and f=0 and g=0 and h=0 and i=0 ;
when i see the execution plan with out distinct... it performs a bit faster.
how do i remove distinct clause and make the query perform better
this particular query is used as inline view in my vieiw . it is used in from clause .
please suggest
second question.... iam getting bitmap index to rowid conversion ...is this good? does it hamper performance . how to avoid this?
regards
raj
Edited by: raj_fresher on Jul 17, 2009 7:48 AMHi Raj
what is e in the query ?It is the column name you provided yourself in your own unformatted example.
After 400+ posts I thought you would understand that it's not that hard to put this exact tag => (yes, 6 characters, 4 letters between 2 curly brackets) before and after your code examples or sample data or explain plans.
That way you maintain formatting and improve readability for us poor readers by magnitudes.
But, I'm sure you'll succeed as well as all the others who can.
I always look on the bright side.
Example:
Earlier this week another Raj also finally got enlightened about it, and his life has since then changed forever!
+He drives a Bentley now, you know+ ;) -
Hi all,
I want to know how to implement algebraic sets in PL/SQl.
I mean for example if there is a table R(A,B) where A is aprimary key having the data :-
{(1,2),(2,1),(2,3),(3,1)}
i want to have a data type that represents sets of data corresponding to attribute B.
i.e the data type should have the value {1,2,3}
Thanks.Not sure that I understand correctly.. and how you want to fit PL/SQL into this.
Sets are best handles as Oracle tables. The best language to deal with sets are SQL. So to get the results you want should be a simple:
SELECT DISTINCT b FROM table_r ORDER BY 1
The results of this can be a cursor that needs to be stepped (fetch) through.
The results can be bulk collected into a dynamic array, e.g.
create or replace type TArray is table of number;
And then in PL/SQL:declare
array TArray;
begin
SELECT DISTINCT b BULK COLLECT INTO array FROM table_r ORDER BY 1;
end;The array object will now contain TArray(1,2,3).
Maybe you are looking for
-
How do I Recover BIOS No Diplay After Failed Bios Update?
Compaq Presario F768WM Bios before 30EAF05 Was updating to 30EAF0A I've tryed to do a boot with HP-Tools recovery UEFI USB but am not sure what to put in which folder to try to get it fixed. Is there any detaied instructions on how to prepare your b
-
Is it possible to make my serial numbers same as the project automatically
I would like configure SAP B1 so that when I choose the serial numbers, that serial number also becomes the value of my projct. Is this possible? Thanks! Riza
-
Hi, I have been given the task of creating a film in imovie using clips of avi files shot on a creative vado (non HD). I have quicktime pro version 7.6.4 (518.35). When I attempt to open the avi files to convert to work in imovie I get a message sayi
-
Dear all In tcs certificate we want change the full name-xyz designation-xyz then we have go to the se71 then j_1iewt_cert then change the name and desgination show the change but when we taken a tdc print out shows a old one how we can change please
-
Trigger a WF when a Z table a record is INS/DEL/UPD.
Hi Everyone, I have a requirememt where I want the Workflow to be triggered when ever a Record is Inserted/ Deleted /Modified. Can any one suggest me how should I achieve this task. Regasrds, Deepak.