Join String to Column in Query
Hi
I have a column in a query I would like to join a string so that the value from the column always has a descriptor at the end like this:
1.5 "Yards"
2.5 "Yards"
I don't mean:
column AS "Yards"
The value in the column changes length so I want to try and have this descriptor so that when I put it in a report the changing value length does not overwrite a seperate text field in the report.
the column is a float value and I want to join the string to it.
Thanks for any input on how to do this
Hi
Sorry I think we have wires crossed
so say I have this:
select columnA
from table A
and It returns this:
columnA
======
123
456
789
.What I want is for it to show this:
columnA
======
123 Yards
456 Yards
789 Yards
. Yards
. Yards
. Yards
. Yards
. YardsSo for ever value returned I want to have the string value "Yards" on the end; column A is a float.
Thanks
Similar Messages
-
How to use outer join condition in my below query.
Hi All,
How to use outer join condition in my below query.
In the table APPS_JP.GEDIS_OFFER_HEADER goh I have more records
in the table APPS_JP.GEDIS_ORDER_BUILDS gob I have less number of records.
I want all the records from APPS_JP.GEDIS_OFFER_HEADER goh
including other conditions.
I have tried goh.OFFER_NO=gob.OFFER_NO(+) but same result.
[code]SELECT GOH.ORIG_SYSTEM,
gsp.USER_NAME,
goh.ORDER_NO,
goh.OMEGA_ORDER_NUMBER,
goh.ORDER_TYPE,
gc.CUSTOMER_ID,
gc.OMEGA_CUSTOMER_NUMBER,
CASE WHEN gc.PRIVATE = 'N' THEN gc.CUSTOMER_NAME ELSE '' END
AS COMPANY_NAME,
goh.ORDER_STATUS,
goh.TOTAL_SELLING_PRICE,
goh.TOTAL_MARGIN,
ga1.ADDRESS1
|| ','
|| ga1.ADDRESS2
|| ','
|| ga1.ADDRESS3
|| ','
|| ga1.POSTAL_CODE
|| ','
|| ga1.CITY
AS SHIPPING_ADDRESS,
ga2.ADDRESS1
|| ','
|| ga2.ADDRESS2
|| ','
|| ga2.ADDRESS3
|| ','
|| ga2.POSTAL_CODE
|| ','
|| ga2.CITY
AS BILLING_ADDRESS,
ga.ADDRESS_ID,
gol.DESCRIPTION,
APPS_JP.TZ.to_local_date (goh.OFFER_DATE, goh.OFFER_DATE_UTC)
AS OFFER_DATE,
gc.LEVEL_8,
goh.NO_OF_BUILDS,
gob.SFDC_ID,
goh.PURCHASE_ORDER_NO AS PO,
gc1.CUSTOMER_NAME AS END_USAGE,
gol.LOB,
goh.TOTAL_MARGIN_PCT,
goh.TOTAL_DISCOUNT,
goh.TOTAL_DISCOUNT_PCT
FROM APPS_JP.GEDIS_OFFER_HEADER goh,
APPS_JP.GEDIS_ORDER_BUILDS gob,
APPS_JP.GEDIS_ORDER_LINES gol,
APPS_JP.GEDIS_OFFER_RELATED_CUSTOMER gorc,
APPS_JP.GEDIS_OFFER_RELATED_CUSTOMER ship,
APPS_JP.GEDIS_OFFER_RELATED_CUSTOMER bill,
APPS_JP.GEDIS_CUSTOMER gc,
APPS_JP.GEDIS_CUSTOMER gc1,
APPS_JP.GEDIS_CONTACT gct,
APPS_JP.GEDIS_ADDRESS ga,
APPS_JP.GEDIS_ADDRESS_NORM ga1,
APPS_JP.GEDIS_ADDRESS_NORM ga2,
(SELECT DISTINCT SALESPERSON_ID, USER_NAME
FROM APPS_JP.GEDIS_SALESPERSON
WHERE SALESPERSON_ID IN
(SELECT TO_NUMBER (COLUMN_VALUE) AS SALESPERSON_ID
FROM TABLE (APPS_GLOBAL.SplitString ('337309'))))
gsp
WHERE goh.ORDER_NO <> 0
AND goh.OFFER_NO <> 0
AND goh.OFFER_NO=gol.OFFER_NO
AND gol.BUILD_NO = 1
AND gol.LINE_NO = 1
AND goh.OFFER_NO=gob.OFFER_NO
AND gob.BUILD_NO = 1
AND goh.OFFER_NO = gorc.OFFER_NO
AND gct.CONTACT_ID = gorc.CONTACT_ID
AND ga.CUSTOMER_ID = gc.CUSTOMER_ID
AND ga.PRIMARY = 'Y'
AND goh.LEAD_SALESPERSON=gsp.SALESPERSON_ID
AND goh.OFFER_NO = ship.OFFER_NO
AND ship.RELATION_TYPE = 'SHIP'
AND ga1.ADDRESS_ID = ship.ADDRESS_ID
AND ga1.CUSTOMER_ID = gc1.CUSTOMER_ID
AND goh.OFFER_NO = bill.OFFER_NO
AND bill.RELATION_TYPE = 'BILL'
AND ga2.ADDRESS_ID = bill.ADDRESS_ID
AND goh.OFFER_DATE BETWEEN APPS_JP.TZ.LOCAL_TO_DB_DATE (
SYSDATE - 30
AND APPS_JP.TZ.LOCAL_TO_DB_DATE (SYSDATE)
AND gorc.RELATION_TYPE = 'BASE'
AND gorc.CUSTOMER_ID = gc.CUSTOMER_ID
AND goh.SALES_CHANNEL = gc.SALES_CHANNEL
AND gc.SALES_CHANNEL = 'SMB'
AND goh.LEAD_SALESPERSON IN (goh.CREATED_BY, goh.LEAD_SALESPERSON)
ORDER BY goh.OFFER_NO;[/code]
Please help me how to use this outer join condition.
Thanks in advance.Hi,
If you want all the rows from goh, then you don't want any conditions like goh.OFFER_NO <> 0.
Make all the joins to goh outer joins, and make all conditions that apply to any tables joined to goh (or to tables joined to them) part of the join condition, like this:
FROM APPS_JP.GEDIS_OFFER_HEADER goh
LEFT OUTER JOIN APPS_JP.GEDIS_ORDER_BUILDS gob ON gob.OFFER_NO = goh.OFFER_NO
AND gob.BUILD_NO = 1
LEFT OUTER JOIN APPS_JP.GEDIS_ORDER_LINES gol ON gol.OFFER_NO = goh.OFFER_NO
AND gol.BUILD_NO = 1
AND gol.LINE_NO = 1
LEFT OUTER JOIN APPS_JP.GEDIS_OFFER_RELATED_CUSTOMER
gorc ...
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
Simplify the problem as much as possible. For example, do you really need all those tables to show what the problem is? Of course, you need them in tyour real query, but if you understand a solution that only involves 4 or 5 tables, you'll know how to apply it to any number of tables.
Explain, using specific examples, how you get those results from that data.Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
See the forum FAQ https://forums.oracle.com/message/9362002#9362002 -
The issue with using the multiple columns sub-query in WHERE clause
Hi All,
my database version is 10.2.
the problem i am trying to deal with is that when I use multiple column sub-query in the WHERE clause of the SELECT statement, the actual row number returned from the sub-query is different from the whole statement.
And what I found is that, whenever there is NULL in any of those columns returned from the SUB-QUERY, the outer query will just return NULL for that whole row.
Here is an example:
select empno, ename, job, mgr, hiredate, sal, deptno from EMP
intersect
select empno, ename, job, mgr, hiredate, sal, deptno from t;
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7839 KING PRESIDENT NULL 17-NOV-81 5000 10
7934 MILLER CLERK 7782 23-JAN-82 1300 10
select * from EMP where (EMPNO, ENAME, job, MGR, HIREDATE, SAL, DEPTNO) in (
select empno, ename, job, mgr, hiredate, sal, deptno from EMP
intersect
select empno, ename, job, mgr, hiredate, sal, deptno from t);
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7934 MILLER CLERK 7782 23-JAN-82 1300 10 If I specifically deal with the NULL situations for the columns which might return NULL, I can get the result right.
select * from EMP where (EMPNO, ENAME, job, NVL(MGR,-1), HIREDATE, SAL, DEPTNO) in (
select empno, ename, job, nvl(mgr,-1), hiredate, sal, deptno from EMP
intersect
select empno, ename, job, nvl(mgr,-1), hiredate, sal, deptno from t);
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7839 KING PRESIDENT null 17-NOV-81 5000 10
7934 MILLER CLERK 7782 23-JAN-82 1300 10 the problem is that, I feel this is a very lame way of handling it.
So, I wonder or am asking if there is any better or standard way to do it?
any help would be highly appreciated.
ThanksHi,
As you discovered, INTERSECT treats NULL as a value, but IN does not.
What you did with NVL is one way to handle the situation. If there was a chance that any of the columns could be NULL, then you might prefer something like this:
select *
from EMP
where ( EMPNO || '~' ||
ENAME || '~' ||
job || '~' ||
MGR || '~' ||
TO_CHAR (HIREDATE, 'DD-MON-YYYY HH24:MI:SS')
|| '~' ||
SAL || '~' ||
DEPTNO
) in (
select EMPNO || '~' ||
ENAME || '~' ||
job || '~' ||
MGR || '~' ||
TO_CHAR (HIREDATE, 'DD-MON-YYYY HH24:MI:SS')
|| '~' ||
SAL || '~' ||
DEPTNO
from emp
intersect
select EMPNO || '~' ||
ENAME || '~' ||
job || '~' ||
MGR || '~' ||
TO_CHAR (HIREDATE, 'DD-MON-YYYY HH24:MI:SS')
|| '~' ||
SAL || '~' ||
DEPTNO
from t
);This assumes that you can identify some string (I used '~') that never occurs in the strings in these tables.
This is implicitly converting the NUMBERs. That's usually not a good thing to do. but explicitly converting them would make this even more tedious.
You should explicitly convert any DATEs to strings, however. Depending on your default format, and your data, you might get away with implicit conversions even for DATEs, but don't bet on it.
If you had to do this often, you might consider writing a user-defined function:
delimited_string (empno, ename, job, mgr, hiredate, sal, deptno) would return a string like
'7839~KING~PRESIDENT~~17-NOV-1981~5000~10'
This will make the coding easier, but beware: it will make the execution slower. -
Hi There
Please advice me how to create a blank column in Query?
Thanks in advance..
Regards,
Chandu.Hi
I don't have any IO's regarding that.I just need create a column with some description then user can fill with data.
How can i run that?
Thanks in advance.
Regards,
Chandu. -
Using FK: 0balance
I need to create a Column in Query to return the following
Full Year Forecast
Forecast to the end of the financial year, variable dependent on plan selected (Q1,2,3 or 4). If select Q2,3, or 4 then use Actual figures for months until the start of the plan. Eg if select Q2 then full year forecast will be Actual for April, May and June plus Forecast for July to March.
Anyone have any ideas please?
thanksHi Smith,
You can follow following approach.
1. Create 2 KF's (KF1 & KF2) one for actual & other for Forcast (using restriction - Plan/Actual & for Quarter / Month).
2. Use variables , say VAr1 & VAR2 (with Customer Exits) to populate values for Month/Quarter (for characteristic used in restriction in step 1) .
3. Value for variables in step 1 will be populated based on value entered for variable VAR3 (this is for user entry Q1,2,3,4).
4. Create KF3 as KF1+KF2.
Regards
SS -
Java.sql.SQLException: Invalid column index Query: while using ROWNUM
hi ,
i am getting the invalid column index query error while executing following query .i m able to run it properly without using rownum but when i append rownum i m getting error.i m using apache queryrunner for execution of query.
java.sql.SQLException: Invalid column index Query: select * from (
SELECT
TO_CHAR(A.REQ_FOR_RATING_ID) RFQID,
TO_CHAR(F.COV_PLAN_ID) COVPLANID,
B.FIRM_NAME FIRMNAME,
B.PRIMARY_ZIP_CD ZIP,
A.PRODUCR_CD PRODUCERCD,
A.PRODUCR_NAME PRODUCER,
H.COV_NAME COVDESP,
C.SALE_OFFC_CD SALEOFFCCD,
C.USR_OFFC_NAME USROFFC,
C.USR_NAME USR,
C.USR_REP_CD USRREPCD,
to_char((SELECT TO_CHAR(COUNT(EMP_NBR)) COUNT FROM ROSTR_DATA WHERE ROSTR_ID = F.ROSTR_ID)) AS count,
TO_CHAR(B.SIC_CD) SICCD,
F.INDSTRY_TYPE_IND INDTYPEIND,
TO_CHAR(F.MANL_SIC_FCTR_NBR) MANSICFACTOR,
TO_CHAR(F.UW_OVERD_SIC_FCTR_NBR) UWOVERDSICFACTOR,
TO_CHAR(G.AREA_FCTR_NBR) STRAREAFACTOR,
G.COV_ID COVID,
F.PLAN_APPRVL_STATUS_CD PLANAPPRVLCD,
F.PLAN_PROGRS_STATUS_CD PLANPROGRESSSTATUSCD ,
F.PLAN_SALE_ASSMNT_CD PLANSALEASSMTCD,
F.CREATD_DT CREATEDDT,
NVL(to_char(F.PLAN_RELSED_DT),' ') PLANRELSEDDT,
TO_CHAR(F.PLAN_RELSED_BY_ID) PLANRELSEDBYID,
TO_CHAR(F.PROPOSD_EFF_DT) PROPOSDEFFECTIVEDT,
TO_CHAR(A.GRACE_PERIOD_NBR) GRACEPERIOD,
A.RNWL_15_MONTH_IND FIFTEENMONTHRNWLIND ,
I.CO_DESC_TXT COMPANYNAME ,
NVL(to_char(F.PLAN_APPRVL_DT),' ') approvedDt,
(Select U.USR_NAME from USR_DETL U WHERE U.USR_ID = F.PLAN_RELSED_BY_ID) as planRelsedByName,
(Select U.USR_NAME from USR_DETL U WHERE U.USR_ID = F.PLAN_APPRVR_ID) as approvedByName,
'' createdByName,
ROWNUM rnum
FROM
REQ_FOR_RATING A,
FIRM B,
USR_DETL C,
SALE_OFFICE D,
QUOTE_SCENRIO E,
QUOTE_COV G,
COV_PLAN F,
COV_LKUP H,
CO_LKUP I
WHERE
A.FIRM_ID = B.FIRM_ID AND
A.SALE_REP_ID = C.USR_ID AND
C.SALE_OFFC_CD = D.SALE_OFFC_CD AND
A.REQ_FOR_RATING_ID=E.REQ_FOR_RATING_ID AND
E.QUOTE_SCENRIO_ID=G.QUOTE_SCENRIO_ID AND
G.QUOTE_COV_ID=F.QUOTE_COV_ID AND
G.COV_ID=H.COV_ID AND
I.CO_CD = F.CO_CD AND
TO_CHAR(F.CREATD_DT,'YYYYMMDD') > TO_CHAR(TO_DATE('07/16/2007', 'MM/DD/YYYY HH24:MI:SS'),'YYYYMMDD') AND
TO_CHAR(F.CREATD_DT,'YYYYMMDD') < TO_CHAR(TO_DATE('10/16/2007', 'MM/DD/YYYY HH24:MI:SS'),'YYYYMMDD')
and rownum <=?) where rnum >=? Parameters: [07/15/2007 00:00:00, 10/15/2007 23:59:59, 1117, 1]That's a SQL fault, not a JDBC/Java fault.
-
Foreign Key join between two columns in a dimension to one column in Fact
Hi,
I have a requirement to join two columns in a Dimension to the same column in the fact.
My reports contains columns from this dimension and will need to use both the joins to get the correct values. So I am not sure if I create an alias to join the second column, if that will be output incorrect values.
How can we achieve this so that I can still use columns from the dimension and still run both the joins in my SQL eventually.
Dimension
Column 1
Column2
Fact
Column 3
Need to map Column1--->Column 3 and Column2 -----> Column 3
ThanksI put it in Dimension and dimension extension scenario with a fact
The possible scenarios are:
1) Column1--->Column 3 and Column2 -----> Column 3
Both Column1 and Column2 have their own logical tables in BMM
2)
Column1--->Column 3
Column1--->Column2
In this case You have Logical table with 2 different sources Column1 and Column2 using column mapping.
you can go for multiple logical sources in this case, based on column selection tables in the join condition -
40357-invalid string in example record query not issued
hello experts,
i am using forms 10g.in query mode i face that error 40357-invalid string in example record query not issued.
i used these code in key-next-item trigger
PROCEDURE KN_FOR_QUERY IS
BEGIN
IF :global.navigation = 'D' AND :global.mode = 'M'
THEN
IF NAME_IN(:SYSTEM.CURSOR_ITEM) IS NOT NULL
THEN
:global.temp_div_code:= :po_m.po_div_code;
:global.temp_po_num := :po_m.po_num;
:global.temp_po_ex_work := :PUR_DELV_D.DELV_EX_WORK;
:global.temp_modi_num:= :po_m.po_modi_num;
IF GET_BLOCK_PROPERTY(:SYSTEM.CURSOR_BLOCK,QUERY_HITS)=0
THEN
-- message('1---'||:SYSTEM.CURSOR_BLOCK);
-- message('2---'||:SYSTEM.CURSOR_BLOCK);
GO_BLOCK(:SYSTEM.CURSOR_BLOCK);
CLEAR_BLOCK(no_validate);
EXECUTE_QUERY;
-- ELSE
-- NEXT_ITEM;
END IF;
-- ELSE
-- mess(GET_ITEM_PROPERTY(:SYSTEM.CURSOR_ITEM,PROMPT_TEXT)||' Must Be Entered For Query...');
END IF;
ELSIF :global.navigation = 'D' and :global.mode = 'Q'
THEN
IF NAME_IN(:SYSTEM.CURSOR_ITEM) IS NOT NULL
THEN
MESS('Press Execute query button');
go_item('tools.execute_query');
ELSE
mess(GET_ITEM_PROPERTY(:SYSTEM.CURSOR_ITEM,PROMPT_TEXT)||' Must Be Entered For Query...');
END IF;
ELSIF :global.navigation = 'D' and :global.mode = 'A'
THEN
IF NAME_IN(:SYSTEM.CURSOR_ITEM) IS NOT NULL
THEN
NEXT_ITEM;
ELSE
mess(GET_ITEM_PROPERTY(:SYSTEM.CURSOR_ITEM,PROMPT_TEXT)||' Must Be Entered...');
END IF;
END IF;
END;
Thanks
RaviHi Ravi
u may need to debug to find out where and when the error exist pls note the following
Error Message: FRM-40357: Invalid string in example record. Query not issued.Error Cause:In query mode, you entered an invalid ALPHA or CHAR value in the example record.
Action:Correct the entry and retry the query. Level: >25
Type: Errorpls verifying that u r entering 1 char for global variable to be assigned so any number between 2single coat is considered a character not s number .
Amatu Allah -
Please guide to improve the performance of XML column reading query.
Hi Experts,
The below query is taking 45 seconds to return 170 records.
Due to selecting XMLTYPE column in query.
select *
from RANGE where WSNO = 3
order by PREFERENCE desc;
The total number of records in the table is 1060.
Even it's a very small table why it's taking 45 seconds.
Can anybody please help me on how to get the output in 2 to 3 seconds.
I want all the columns from the table.
The problem only with REST column XMLTYPE.
If I am not selecting this column I am getting output in 1 to 2 seconds.
I am posting the execution plan and DDL for table and index.
PLAN_TABLE_OUTPUT
Plan hash value: 3593186720
| SNO | Operation | EMPNAME | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 31 | 23281 | 21 (5)| 00:00:01 |
| 1 | SORT ORDER BY | | 31 | 23281 | 21 (5)| 00:00:01 |
| 2 | TABLE ACCESS BY INDEX ROWID | RANGE | 31 | 23281 | 20 (0)| 00:00:01 |
|* 3 | INDEX RANGE SCAN | INDX_WSNO | 31 | | 1 (0)| 00:00:01 |
Predicate Information (SNOentified by operation SNO):
3 - access("WSNO"=3)
CREATE TABLE RANGE
SNO NUMBER,
BUSNO NUMBER,
EMPNAME NVARCHAR2(64),
PREFERENCE NUMBER,
TSNO NUMBER,
MEMBER CHAR(1 CHAR) ,
EQU CHAR(1 CHAR) ,
REMAIL CHAR(1 CHAR) ,
SSR CHAR(1 CHAR) ,
SUB CHAR(1 CHAR) ,
SPN CHAR(1 CHAR) ,
SEMPNAME NVARCHAR2(128),
FVL NUMBER(32),
TVL NUMBER(32),
ISD CHAR(1 CHAR),
CHANGED NVARCHAR2(64),
CDATE TIMESTAMP(6) ,
UDBY NVARCHAR2(64),
UDATE TIMESTAMP(6),
LSTU CLOB,
WSNO NUMBER,
ASTN CHAR(1 CHAR),
ASTNPL CHAR(1 CHAR),
AVAF CHAR(1 CHAR),
REST SYS.XMLTYPE
TABLESPACE USERS
PCTUSED 0
PCTFREE 10
INITRANS 11
MAXTRANS 255
STORAGE (
INITIAL 64K
NEXT 1M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
XMLTYPE REST STORE AS CLOB
( TABLESPACE USERS
ENABLE STORAGE IN ROW
CHUNK 8192
PCTVERSION 10
NOCACHE
INDEX (
TABLESPACE USERS
STORAGE (
INITIAL 64K
NEXT 1
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
STORAGE (
INITIAL 64K
NEXT 1M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
LOB (LSTU) STORE AS
( TABLESPACE USERS
ENABLE STORAGE IN ROW
CHUNK 8192
RETENTION
NOCACHE
INDEX (
TABLESPACE USERS
STORAGE (
INITIAL 64K
NEXT 1
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
STORAGE (
INITIAL 64K
NEXT 1M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
NOCACHE
NOPARALLEL
MONITORING;
CREATE INDEX INDX_WSNO ON RANGE(WSNO);
CREATE UNIQUE INDEX RULE_EMPNAME ON RANGE(BUSNO, EMPNAME);
Please help me how to improve the performance of this query.
Thanks.Can you try something like this and check if its faster? (this is just my guess as I dont have your data )
SELECT SNO,
BUSNO,
EMPNAME,
PREFERENCE,
TSNO,
MEMBER,
EQU,
REMAIL,
SSR,
SUB,
SPN,
SEMPNAME,
FVL,
TVL,
ISD,
CHANGED,
CDATE,
UDBY,
UDATE,
LSTU,
WSNO,
ASTN,
ASTNPL,
AVAF,
xmltype.getclobval (rest) rest
FROM RANGE
WHERE wsno = 3
order by PREFERENCE desc;
Cheers,
Manik. -
Does Coloring Of Rows and Column in Query effect the Performance of Query
Hi to all,
Does Coloring of Rows and Column in Query via WAD or Report designer , will effect the performance of query.
If yes, then how.
What are the key factor should we consider while design of query in regards of Query performance.
I shall ne thankful to you for this.
Regards
Pavneet RanaThere will not be any significance perofrmance issue for Colouring the rows or columns...
But there are various performance parameters which should be looked into while designing a query...
Hope this PPT helps you.
http://www.comeritinc.com/UserFiles/file/tips%20tricks%20to%20speed%20%20NW%20BI%20%202009.ppt
rgds, Ghuru -
If we are having two projections with different analytic views , can we create caluclated column in one of it and join with other projection ?
Hi Ravi,
There seems to be a bug when i try to create join between caluclated column and original colum its getting joined with multiple columns during visibilty.
Once views get activated its joining correctly -
INNER JOIN, MX 7, column name error
I am running or attempting to run the att'd query in CF MX
7.0 and getting an error because I then run:
<CFOUTPUT QUERY="getNutes" group="NUTR_NO">
<CFSET VALUE = 0>
<CFOUTPUT>
<CFIF Day EQ "T">
<CFSET VALUE = VALUE + (getNutes.Total_WT *
getNutes.NUTR_VAL/100) / getDays.RecordCount>
<CFELSE>
<CFSET VALUE = VALUE + (getNutes.Total_WT *
getNutes.NUTR_VAL/100)>
</CFIF>
</CFOUTPUT>
To sum the nutrient contents...
This worked fine under CF 5... but I am getting a 'NUTR_NO
does not specify a column name in the query'.
Any thoughts???
Query follows:> Yep... it's worse... it appears that MX does not support
the sql inner join or
> outer join... sigh...
Don't be ridiculous. You're showing a fundamental lack of
understanding of
how CF handles database interaction. When you use
<cfquery> to "create" a
recordset, all CF does is resolve any embedded CF (tags,
functions,
variables, etc), and passes the resulting string to the DB.
The DB then
processes it and returns a recordset. So CF doesn't "support"
any sort of
SQL syntax. Now does it claim to; nor does it try to; nor is
it
appropriate for it to.
If you're having problems with your returned recordset, the
first thing you
should do is <cfdump> it (or part of it) and check that
you're getting back
what you're *assuming* you're getting back.
The second thing you should do is lose the SELECT *. Specify
the columns
you want back. This is nothing to do with CF, it's just
standard SELECT
query advice. When you're joining tables, you hardly ever
want ALL the
columns back, and if it's one of those rare occasions you DO
want all of
them, you should still specify a SELECT clause so you can
distinguish
between same-named columns (which seems to be your problem
here).
Adam -
Pl sql join and selecting columns from join."t"."c": invalid at debug time
I noticed the error at cc.Country that is shown because cc is not yet there at compile time (got that
from searching this forum).
Isnt that a bit weak of oracle sql developer that it doesnt compile from the outside to the inside /core but
rather form top to bottom?
Am I right with my conclusion? If so, how to do it otherwise i.e. specifying that cc.country is
a column from countrycodes joined with table6 ?
SELECT DISTINCT 0,
2,
SUBSTR('metable', 0, 1) || '_ABC',
'ABC_' || 'metable',
'ABC ' ||cc.Country ,
'+'
FROM table6
LEFT JOIN COUNTRYCODE cc
ON cc.Code = metable
WHERE metable IS NOT NULL
AND metable <> ''metalray wrote:
hi Boneist
thanks for your reply
its in a plsql procedure (10g). well as you see cc is the alias
of the table COUNTRYCODE. which does exists. the error is at 'ABC ' ||cc.Country'
telling me"PL/SQL: ORA-01747: invalid user.table.column,..."
when I put COUNTRYCODE next to table6 in the FROM it works but thats not what I want
since I want to join both tables not just select from both.Can you give us your exact code and exact error message.
I'm not finding any problem with using alias names in the query..
SQL> select d.dname
2 ,'EMPNAME : '||e.ename
3 from dept d LEFT JOIN emp e ON e.deptno = d.deptno;
DNAME 'EMPNAME:'||E.ENAME
RESEARCH EMPNAME : SMITH
SALES EMPNAME : ALLEN
SALES EMPNAME : WARD
RESEARCH EMPNAME : JONES
SALES EMPNAME : MARTIN
SALES EMPNAME : BLAKE
ACCOUNTING EMPNAME : CLARK
RESEARCH EMPNAME : SCOTT
ACCOUNTING EMPNAME : KING
SALES EMPNAME : TURNER
RESEARCH EMPNAME : ADAMS
SALES EMPNAME : JAMES
RESEARCH EMPNAME : FORD
ACCOUNTING EMPNAME : MILLER
OPERATIONS EMPNAME :
15 rows selected.
SQL> -
Substitution strings in chart sql query
Hi Guys,
I am creating line charts and bar charts based on a query in HTML DB 1.5. I am using substitution strings in the query. Though I can use substitution strings in the line chart, I cannot do it in the bar chart. I am using almost the same sql query in both line and bar charts.
The sql query in line chart is
SELECT null, TO_CHAR(t1.extract_date, 'W-MON-YYYY') extractdate,
MIN_OF_AVERAGES(AVG(&P40_METRICS.),:P40_REGION_LIST,:P40_SUBREGION_LIST,NULL,:P40_METRICS,'ind') orgid
FROM ind t1,geography t2
WHERE t1.country_id = t2.country_id(+)
AND t2.region_name like
DECODE(:P40_REGION_LIST,'ALL REGIONS','%',:P40_REGION_LIST)
AND t2.subregion_name like
NVL(:P40_SUBREGION_LIST,'%')
GROUP BY TO_CHAR(extract_date, 'W-MON-YYYY')
order by to_date(extractdate,'DD-MON-YY')
The sql query in bar chart is
SELECT null, TO_CHAR(t1.extract_date, 'W-MON-YYYY') extractdate,AVG(&P40_METRICS.) orgid
FROM ind t1,geography t2
WHERE t1.country_id = t2.country_id(+)
AND t2.region_name like
DECODE(:P40_REGION_LIST,'ALL REGIONS','%',:P40_REGION_LIST)
AND t2.subregion_name like
NVL(:P40_SUBREGION_LIST,'%')
GROUP BY TO_CHAR(extract_date, 'W-MON-YYYY')
order by to_date(extractdate,'DD-MON-YY')
The min_of_averages function in the line chart query is some function I am calling. Even if I cut-paste the line chart query in the bar chart I get the error.
The substitution string which is giving the problem is "&P40_METRICS."
The error I am getting is
Query cannot be parsed, please check the syntax of your query. (ORA-00909: invalid number of arguments)
The only difference I see is that line chart query is inside a series and bar chart is not, does this make a difference??? Or is it because I am using the substitution string in choosing the column??? Please help!!!!
Thanks,
SwaroopSwaroop,
You might be using an HTML bar chart and an SVG line chart, I can't tell, but their implementations differ. You won't be able to use a substitution string to replace a column name in the query in the situation you found, you'd have to figure out a way to construct the query string before it gets executed and I'm not sure the chart pages will let you do that.
Scott -
Join hint ignored - very bad query plan results
I'm trying to get a query that's being generated by SSAS to perform acceptably. Because this query is (at least partially) generated by SSAS, I don't have complete control over the query text.
The problem - The query looks roughly like this:
select
-- a bunch of columns
from
T1 -- table with ~40,000,000 rows
inner loop join T2 on T2.t2id = T1.t2id -- table with ~16,000 rows
inner loop join T3 on T3.t3id = T1.t3id -- table with ~200,000 rows inner loop join T4 on T4.t4id = T1.t4id -- table with ~200,000 rows
left loop join T5 on T5.t3id = T1.t3id and T5.t6id = T4.t6id -- table with 0 rows
where
-- some uninteresting conditions
T1 is a Fact (or Measure) table, T2, T3 and T4 are Dimension tables, T5 and T6 are involved in the filtering of the query. Every row of T1 WILL match exactly one row in each of T1, T2 and T3.
You'll note that I've hinted all of the joins - according to the documentation, using join hints forces join order (which is consistent with the plan that's produced). There's no mention that join hints can be transparently ignored by the optimizer,
but that seems to be precisely what's happening.
In the plan that results, the join to T4 is done as a hash join, with T1*T2*T3 (40,000,000 rows) on the "top", so it ends up trying to build a hash table with 40,000,000 rows, resulting in very high tempdb activity and very poor performance (I
don't know how poor - I've never let it finish).
I can see part of the reason why it's making this join choice - the estimate of T1*T2*T3 is only 35,000 rows, even though T1 has 40,000,000 rows and the join will hit on every row.
Questions:
1. What can I do to the query or the database to improve the estimate on the join to T3?
2. What can I do to the query to force the optimizer to use a loop join like I asked?
Version is SQL Server 2008 R2 SP2 Developer Edition X64.
OS is Windows 2008 R2
Machine is dual-quad-hyper-threaded CPU with 96Gb of RAM and several Tb of disk spread over 8 spindles and SSDs.
I've seen this query perform well before - I've been tuning this query for going on 7 years now and I've never seen it perform this badly that I can recall. Not sure if it's something that's changed in SP2, or something about the distribution
of data in this particular database that's changed, but something's sure changed.
-cd Mark the best replies as answers!That would indicate that there are no foreign-key constraints, or if they, they are not trusted. (Assuming here that there WHERE clause includes no filter on T1.)
That, or the statistics on T1 are giving a completely wrong estimates for the number of NULL values in t2id and t3id.
Erland Sommarskog, SQL Server MVP, [email protected]
Thanks, Erland.
There are foreign key constraints, but they're NOCHECK. I've tried creating and updating statistics on various columns of the tables involved - I'll re-check that I've got up to date statistics on all of the columns involved in these joins.
What about the join-hint being ignored? Is there anything I can do, or has something changed here recently? Interestingly, when I run this query from SSMS, I get loop-joins all around, but when SSAS runs the query, the one join always comes out
a hash join. Before I added the hints, all joins were hash joins - the hints worked on all joins but the one.
-cd Mark the best replies as answers!
Maybe you are looking for
-
Can I recover photos no longer in my photo stream
I was recently travelling in the USA and my iPad was showing a lack of storage space despite there being plenty, I went to the Apple store in downtown SAN FRANCISCO and it was decided we could reset it which would wipe everything but the photos I had
-
Mail to achieve a contact for support to get my Serial Number caCare Apple Protection Plan?
Mail to achieve a contact for support to get my Serial Number caCare Apple Protection Plan?
-
hi, is anybody worked for creating invoice with Hold status by using BAPI i have tried with BAPI_INCOMINGINVOICE_SAVE & BAPI_INCOMINGINVOICE_CREATE Actually i am creating Invoice with this BAPI, but i required hold status for created invoice. how to
-
Having Purchased Music on two Computers?
****, I have a Toshiba laptop, running WinXP, I use for work and a Dell XPS desktop, running WinXP, I use at home. All of my purchased music is on the desktop. Is there an easy way to export my library to the laptop? I would like both computers to ha
-
How do i upload font files into photoshop?
How do i upload fonts from websites into photoshop cs2? Heres the fgont im trying to get in there. http://www.fontreactor.com/download/en/pc/disintegration