Value of the column used as a column in the join
We have three tablesProduct table
Pno Pname Htype1 Htype2
101 ABC Ltype1
Loc Table
LocId LocName Ltype1 Ltype2
TransportTable
Tid Ttype LocId
I need to create the query like thisbegin
select Ltype1 into v_type
from Product
where Product = 101;
for x in (select t.Tid,t.Lid
from Loc l,Transport t
where l.locid = T.locid
and t.ttype = 'l.'|| v_type ) --- Getting Problem when the column
which is set in Htype1 in Product table to be used to join here
loop
Can you pls suggest/help me how to use the colum that is located in Htype1 in the Product tableto be used in the cursor?
Thank you very much
Published by: user12093849 on August 2, 2010 06:32
Published by: user12093849 on August 2, 2010 06:32
Hello
As Sven said, the paintings were not designed for a relational database. The longer term solution wouold be redisgn the tables of a relational database.
The fundamental problem is that identifiers (such as column names) should be hardcoded in the query when compiling. You cannot use variables.
You can use variables in the Dynamic SQL statements , where the application is not compiled until the time of execution. I find this easier to do in SQL * more, using the substitutuion variables, but you can do dynamic SQL in PL/SQL, too.
Depending on the data types involved, something like that can work for you as well:
SELECT t.tid
, l.lid
FROM loc l
, transport t
, product p
WHERE p.product = 101
AND l.locid = t.locid
AND t.ttype = CASE p.htype1
WHEN 'Ltype1' THEN lytpe1
WHEN 'Ltype2' THEN lytpe2
END
;
This is likely to be less effective than other alternatives.
Tags: Database
Similar Questions
-
Join does not work for NULL values on the join condition
Hello
I have the following problem.
SQL > select * from a;
X Y
---------- --------------------
1
2
3
4
SQL > select * from b;
A:
---------- --------------------
1
2
SQL > select f.x, f.y, s.b in f, s b
2 where f.x = s.b (+);
X Y B
---------- -------------------- ----------
1 1
2 2
4
3
SQL > select f.x, f.y, s.b in f, s b
2 where f.x = s.b (+)
3 and f.y = s.y;
no selected line
So now if I include a join condition more where null = null situation arises, it's working now.
Just tell her not to treat (1 and null) (1 and null) are the same.
What is the solution. This is an expected behavior.
Thank you
Pramod GarrePramod salvation,
Another way to use the outer join is,
Select f.x, f.y, s.b
of a, f, s b
where f.x = s.b (+)
and nvl(f.y,0) = nvl (s.y (+), 0);Hope this will help you.
Thank you
Amit -
Using the value of the column of the report in view state
Hi all
I have a little trouble as long as you report column. Here's the problem I have face.
I have a classic report in apex5 (universal theme). Please find the page here https://apex.oracle.com/pls/apex/f?p=62495:5:
I want to have a condition that SAL column should appear only if DEPTNO! = 10. For this, I put a conditional display for SAL column that "point value / expression 1 column! Expression 2 ="and #DEPTNO # expression1 and expression2 10. But this doesn't seem to work. Can someone help me understand the issue.
Note: I want to view only the column of the report, not the page item in the condition.
Thank you
Stephanie.
Kalesh Ravi-Oracle wrote:
I want to have a condition that SAL column should appear only if DEPTNO! = 10. For this, I put a conditional display for SAL column that "point value / expression 1 column! Expression 2 ="and #DEPTNO # expression1 and expression2 10. But this doesn't seem to work. Can someone help me understand the issue.
It is not possible to report baseline values in the State of the reference column. It would be unwise to do so: how APEX can determine if the column should be included or not until all rows are retrieved?
Note: I want to view only the column of the report, not the page item in the condition.
Why? In the example given, this is the correct (and more effective) approach. If the condition must be based on the expected query results, then use a Exists (SQL query returns at least one row) or NOT Exists (SQL query returns no line) condition.
-
How to use the values in the columns of an interactive report (Apex 5)
Hello
I have an interactive report and a link column and I click to set the value of four fields in a subregion with the value of four columns of the report.
This without submitting the page every time so I think using javascript.
But what is the right way to do this in 5 Apex?
How to have a reference to the column of a report (customer.name to the customer or customer.city, for example)?
Concerning
Gianpaolo
Hi gianpagi,
gianpagi wrote:
I can't run your code as well, on apex.oracle.com, I have re-product the situation with the emp table and the columns ename, sal and the fields p1_ename, p1_job, p1_sal
Can you help me.
https://Apex.Oracle.com/pls/Apex/f?p=4550:1:103040501310506:
https://Apex.Oracle.com/pls/Apex/f?p=102726:LOGIN_DESKTOP:104044067688962:
user and developer demo/demo (TR1 workspace)
Check the application now. I've done the column 'Empno' as link and execution of your dynamic action on click on the link.
Here are the changes:
- Edited the "Empno" column attributes and perform the following settings in the properties of 'column link:
Text link: #EMPNO #.
Link attributes: class = 'empdetails '.
Target: URL
URL: javascript:void (0);
NOTE: The link does nothing but on the onclick for the event of link DA no real logic.
- Edited the dynamic action 'assign values' and set the following properties:
Selection type: jQuery Selector
jQuery Selector: a.empdetails
Kind regards
Kiran
-
request to retrieve the value of the column and use in the other rows of the table
Hi all
I have a table where I maintain pairs name / value of a particular job. Now, I would like to see some of the values of the rows passed to other rows in a table for example
create job_name_value
(
VARCHAR2 (100) job_name,.
name varchar2 (100),
value varchar2 (100)
);
job_name name value TRGJOB % FPATH / USR/LOCAL/TRGJOB TRGJOB % FDATE CALDATE + 1 TRGJOB $FNAME1% %FPATH.mywatchfile1.%FDATE TRGJOB FNAME2% %FPATH.mywathcfile2.%FDATE TRGJOB % FNAME3 %FPATH.mywatchfile3.%FDATE can we write a sql query to produce output as below the objective is to use the value of fdate and fpath in the remaining lines. If there is no fdate and fpath then value should return such what or we need to use the stored procedure to achieve
/ usr/local/trgjob/mywatchfile1. CALDATE + 1
/ usr/local/trgjob/mywatchfile2. CALDATE + 1
/ usr/local/trgjob/mywatchfile3. CALDATE + 1
Hello
Since it cannot be '% FDATTE' or '% FPATH' (or both) then you need to replace each of them separately. If the other does not, there 'replacement' will do nothing, but this will not affect the result of the other.
Here's a way to do it:
SELECT REPLACE (REPLACE (n.value
'% FPATH.'
p.value | '/'
)
, '% FDATE '.
d.value
) AS output_value
OF job_name_value n
LEFT OUTER JOIN job_name_value p ON p.name = '% f '.
LEFT OUTER JOIN job_name_value d ON p.name = '% FDATE '.
WHERE n.name AS '\%FNAME%' ESCAPE ' \'
;
I hope that answers your question.
If this isn't the case, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
Report when the above query is to give erroneous results and explain, using specific examples, how to get the correct results of data provided in these places. If you change the query at all, your postal code.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum: https://forums.oracle.com/message/9362002#9362002
-
Two tables provided, how you retrieve the values in two columns using values in a column (the pass get values. If col. A is not null values and get the pass. B if col. A is null)?
Guessing
Select nvl (x.col_a, y.col_b) the_column
from table_1 x,.
table_2 y
where x.pk = y.pk
Concerning
Etbin
-
concatenation error - when I use the value of the column of text in which the condition.
Hello
I'm creating Materialized view using a few columns from two tables and by obligation, I need to prepare a select statement with a where condition in another column. (new heading)
I tried like below...
create a materialized view HAND
force refresh on demand
as
Select
a.table_name,
a.column_name,
b.trial_name,
' Select * from ' | '. a.table_name |' where ' | a.column_name | ' = '|| b.trial_name | « ; » "QUERY".
Of
exp_csv_tB has,
b exp_csv_tr;
the value of name a.table is: monitoring_table
a.column_name value is: study
b.trial_name = fty777
Materialized view created with an extra column, but it is not added "(codes) to the value of the text in which the condition.
output I got is:
Select * from monitoring_table where study = fty777;
but
I need output like
Select * from monitoring_table where to study = "fty777";
value of fty777 must be in the codes like "fty777". I read a few articles, but did not get this example.
Help, please.You need to escape your quotes (double upward on quote)
create materialized view MAIN refresh force on demand as select a.table_name, a.column_name, b.trial_name, 'select * from '||a.table_name||' where '||a.column_name|| ' = '''|| b.trial_name||''';' "QUERY" from exp_csv_tB a, exp_csv_tr b;
-
How to upgrade a table column using the values in the Oracle collection
On the "BOLD" line, I don't know how I should move the values of the collection of name I said without which are set all the values in the table supplier_16 = 'Saral.create or replace procedure test_coll IS CURSOR upd IS SELECT CONTACT_NAME FROM Supplier_16; TYPE dept IS TABLE OF upd%rowtype; cur_var dept; Type List Is table Of varchar2(20); Name List:= List('Shilpi','Sunil','Shreyas','Saral'); BEGIN OPEN upd; LOOP FETCH upd BULK COLLECT INTO cur_var; -- EXIT WHEN upd%NOTFOUND; FORALL i IN cur_var.FIRST..cur_var.LAST UPDATE supplier_16 ** SET Contact_name= name(i); *** COMMIT; END LOOP; CLOSE upd; END;
Help, please.Aashish S. wrote:
Thank you very much...Yes, I slide collections and was trying to reach somwthing on similar lines to which you provided the code example...
My essay is equipped to take a collection: initialized with values of say 3-4...
Take other tables... A column... and update the column in the table (not PK, FK anything) using the values of the initialized collection...
However, I am stuck between the two on how the UPDATE clause should be...
OK, if it's just because you want to practice with collections, you might do something like this...
SQL> set serverout on SQL> create table supplier_16 as 2 select 'Frederick' as contact_name from dual union all 3 select 'Robert' from dual union all 4 select 'Jeremy' from dual union all 5 select 'Simon' from dual 6 / Table created. SQL> create or replace procedure test_coll is 2 CURSOR upd IS 3 SELECT CONTACT_NAME 4 FROM Supplier_16 5 FOR UPDATE; 6 Type List Is table Of varchar2(20); 7 Name List := List('Shilpi','Sunil','Shreyas','Saral'); 8 v_contact_name varchar2(30); 9 v_idx number := 1; 10 BEGIN 11 OPEN upd; 12 LOOP 13 FETCH upd INTO v_contact_name; 14 EXIT WHEN upd%NOTFOUND; 15 UPDATE supplier_16 16 SET contact_name = name(v_idx) 17 WHERE CURRENT OF upd; 18 DBMS_OUTPUT.PUT_LINE(v_contact_name||' update to '||name(v_idx)); 19 v_idx := v_idx + 1; 20 END LOOP; 21 CLOSE upd; 22 COMMIT; 23 END; 24 / Procedure created. SQL> exec test_coll; Frederick update to Shilpi Robert update to Sunil Jeremy update to Shreyas Simon update to Saral PL/SQL procedure successfully completed. SQL> select * from supplier_16; CONTACT_N --------- Shilpi Sunil Shreyas Saral
Of course, there is treatment rank by rank and is not best for performance, but it allows you to access your collection that you created names.
-
Use the value of the inline column in a subquery
How can I use a value from a column of a row finds in a subquery in column_name, here's my problem:
SELECT scr_error.err_tab_severity
OF scr_error.
(SELECT column_name
Of user_tab_columns
WHERE table_name = 'SUPP_OUTPUT_ADDRESS' AND column_name LIKE '% ERR')
table__16
WHERE (scr_error.err_tab_code in (SELECT table__16.column_name
OF supp_output_address
where))
PS. the product within which im trying to imitate this request can't stand not pl/sqlWhich DB version are you running?
What is the SQL code you want to run?
set serveroutput on declare l_Str varchar2(4000); begin l_Str := 'select scr_error.err_tab_severity from scr_error where scr_error.err_tab_code '; for r in (select column_name cn from user_tab_columns where table_name = 'SUPP_OUTPUT_ADDRESS' and column_name like 'ERR%') loop l_Str := l_Str || ' = ' || r.cn || ' and '; end loop; dbms_output.put_line(substr(l_Str, 1, length(l_Str)-4); end; /
-
How to use the value of the column in the old testament even another column in the report
I have a report based on a query like this
SELECT
"AAA."
'BBB '.
FROM TABLE2
and AAA is a NUMBER related to the TABLE1 table. I try in the column attributes writing a correct LOV. In this LOV I have to use a current value of the a.
Fe SELECT CCC | » '|| DDD FROM TABLE1 WHERE EEE = #AAA #.
The question is how to get the value of AAA to this query (#AAA # dosent work)?
the second way to fix this problem I thought changed the first request:
SELECT
"AAA."
"BBB."
APEX_ITEM. SELECT_LIST_FROM_QUERY
(2, NULL,'SELECT CCC |) » ''|| DDD FROM TABLE1 WHERE EEE = 'AAA' ') "FFF".
FROM TABLE2
but problem is the same... You have a solution?
THX in advanced for any helpHello
OK, try this
X_ITEM. SELECT_LIST_FROM_QUERY (1, (SELECT CCC |)) » '|| DDD FROM TABLE1 WHERE EEE = AAA),'SELECT CCC | » ''|| DDD, CCC | » ''|| DDD FROM TABLE1 WHERE EEE =' | AAA, ","NO")"FFF ".
Concerning
Paul
-
How to use the default value of a column in a table in insert or upda
Hello
I try to use the values by default so that the user should not have to enter data, but when I select default type and a default, I see an error message if I try to add a new line.
How can I use a default value to a column in a tabular presentation?
Gouri
Published by: user1046395 on April 3, 2009 09:58Gouri,
You can change simply to attribute each report column. For example,.
To set the default date.
Default type: PL/SQL Expression of function
Default: sysdateTo set the default text,
Default type: PL/SQL Expression of function
Default: * "CLERK."If you still get an error, what is the error message?
Tarraf -
Navigation using the value of the column
Hello
I have a question about navigation in BI dashboard reports. If I understand correctly, I can implement the interaction of value to navigate to another report and use the original query as a filter. But I need to use the exact value that the user has clicked as a filter: I have a report that shows a list of the countries and summaries. Then, by clicking on the name of the country, I will navigate to a report target with a detailed analysis for that specific country.
Can someone help me with this?To do this, in the source report, go to the country column-> properties-> tab Format of the column column-> in the option value interaction select Browse and select the target report. In the report target activate option "" is bringing"on the Country column. This will pass the value when the user clicks on a particular value on the source report.
Arjun -
Get the value of the second column used for the formatting of the break
Hello
I have a report that uses breaks on the first and second columns. Breaks are displayed as headers repeat on break and I am able to display the value of the first column to break using #COLUMN_VALUE # section rehearsal breaks use this format, use #COLUMN_VALUE # subs. I would like to know if there are somewhat similar to refer to the value in the second column of the break.
Looked at some other threads on this topic and it seems that this was not possible in versions 3.x pre of the Apex. Would like to know if there is a way to achieve Apex version 3.1.0.00.32.
Kind regards
RupeshIn the new version, interactive reports can break on / up to 6 columns. In previous versions, I just join together the two columns that had to be broken off on so you can have a column in the report settings available.
I hope this helps.
Mike
-
How to use the prompt value in the column of the report
Hello
I have a quick report column which is 'Adj Type' that contains values 10,20,30, and when the user selects Adj Type = 10, this value should be passed on to the column of the report.
For example. Value in column 1 is 10 and this should multiple with the prompt value and production is expected to be 10 * 10.
Ideas how to capture the prompt values in the column of the report for the calculation.Hi hsekar,
(1) declare a presentation online in the section variable set Variable--> Variable--> P_var presentation
(2) in Fx Table_name. Your_column * @{P_Var}
@{P_var} {20} (20 is the default, it replaces when a user selects the value in the command prompt
Thank you
Saichand.v -
How to highlight the minimum value in a column?
I need to highlight the lowest value in each column in my spreadsheet. I try to use the conditional nail, but I can't find a function to work as I need.
One way would be to calculate the minutes in a cell of a footer row, select the cells in the body of the column and apply conditional highlighting like this:
You must click on the chip address first, and then select the comparison cell, A8 here, then be sure to keep the row and column.
The A8 from the example formula is = MIN (A).
The result is a bold 2 (not shown in the screenshots).
SG
-
How do the average of the last 5 values of a column as new values automatically entered?
If the issue is not clear for you, here's a site I found that teaches you how do it on excel. ml https://www.extendoffice.com/documents/Excel/2533-Excel-average-last-5-values.HT I can't find the corresponding method on the good numbers. Thank you for your response in advance :-)
Hi Z_J,
This number approach pulls the last 5 (low) values of table 1 in another table where the average can be calculated.
Step 1. Add line numbers in column A of table 1. This gives a way for table 1-1 to extract the last 5 values.
Formula in A2 (and fill down
= ROW()
Step 2.
In table 1-1, the formula in A6 estimated the maximum line in table 1
= MAX (Table 1::A)
The formula in A5 (and filling up)
= A6−1
Formula in B2 of table 1-1 (and fill down) using VLOOKUP to find a match for each line number in table 1-1 and get the value out of this line in table 1.
= VLOOKUP(A2,Table 1::A:B,2,FALSE)
Step 3.
Now add another row (and insert a new value) to the lower part of table 1
Lines 3 to 7 are now drawn.
Ranger by hiding some columns
Kind regards
Ian.
Maybe you are looking for
-
Import csv postal codes without losing 0 to
I found some older instructions in the support community for the creation of a custom setting in my zip code column that suggests a "custom" cell pulldown then the menu drop-down formatting with text and numbers. This option is not available in my ve
-
Satellite L300 07R - need the Windows XP drivers
My boss gave me a L300 - 07R (model # is PSLB0C-07R08C) for work because I had no machine XP and unfortunately it comes preinstalled with Vista. This is useless for programming because of the way Vista handles file types. I intend to install XP with
-
Backflip: pls help! restoration of applications on display
Hello, im new here, not sure if this problem has been discussed before. earlier, my parents wanted to try the backflip and I have no idea what they pressed and the app facebook from the home screen has been removed. I mean the application that displa
-
How to stream data in series for a user specified using LabVIEW?
Hi all I need to send data continuously using serial communication to the microcontroller for a user specified time... Any suggestions please?
-
Transfer data to external hard drive from XP to Vista
How would I be able to transfer data from a XP hard drive (which is in an external case) on my new laptop with Windows Vista? Please let me know. Thank you very much. original title: I have a XP hard drive in an external case, and I would like to tra