The column is to summarize all the lines and display the same value in all the lines.
HelloPlease see the query below. I have a problem in this query to retrieve the abs_qty when the P:item ie setting) msib.segment1 is not given as an input parameter. His warning just to the top of the total quantity for all items. With the passage of P:item ie) msib.segment1 as an input parameter, it gets the exact value for abs_qty. kindly help me to solve this problem.
Note only: manufacturing plant, start date and end Date are Mandatory parameters (required). Others such as code point, Base model and Scheduler are optional.
SELECT mmt.transaction_date date_produced, msib.segment1 point,
CIC.cost_type_id, msib.description item_description,
MC.segment6 base_model, mc.segment7 trade_brand,
MMT.subinventory_code subinventory,
mil. Segment1 | '.' || mil. Segment2 | '.' || mil.segment3 ELECTROLUX,
OOD.organization_code
|| '-'
|| OOD.organization_name manufacturing_plant,
MMT.transaction_quantity quantity_produced,
MTT.transaction_type_name transaction_type, msib.inventory_item_id,.
MSIB.organization_id, cic.material_cost, COST,
CIC.material_overhead_cost transport, csc.standard_cost,.
* (check (NVL ((SELECT SUM (mmt.transaction_quantity) total_NET_qty *))))
OF mtl_material_transactions mmt.
mtl_system_items_b msib,
mtl_transaction_types mtt,
org_organization_definitions ood,
mtl_txn_source_types mts
WHERE mmt.organization_id = msib.organization_id
AND msib.inventory_item_id = mmt.inventory_item_id
AND mmt.transaction_type_id = mtt.transaction_type_id
AND mmt.organization_id = ood.organization_id
AND mtt.transaction_type_name = "Completion of work in PROGRESS"
AND mts.transaction_source_type_name = 'job or schedule. "
AND msib.segment1 = NVL (: p_item, msib.segment1)
AND ood.organization_code =: p_manufacturing_plant
AND BETWEEN TRUNC (mmt.transaction_date): p_start_date
AND: p_end_date), 0)
-
* (NVL ((SELECT SUM (mmt.transaction_quantity) total_NET_qty *)))
OF mtl_material_transactions mmt.
mtl_system_items_b msib,
mtl_transaction_types mtt,
org_organization_definitions ood,
mtl_txn_source_types mts
WHERE mmt.organization_id = msib.organization_id
AND msib.inventory_item_id = mmt.inventory_item_id
AND mmt.transaction_type_id = mtt.transaction_type_id
AND mmt.organization_id = ood.organization_id
AND mtt.transaction_type_name = "Ongoing work exit"
AND mts.transaction_source_type_name = 'job or schedule. "
AND msib.segment1 = NVL (: p_item, msib.segment1)
AND ood.organization_code =: p_manufacturing_plant
AND BETWEEN TRUNC (mmt.transaction_date): p_start_date
AND: p_end_date
*), 0))) abs_qty of the double) AS ABS_qtyy, * (select (NVL ((SELECT SUM (mmt.transaction_quantity) total_NET_qty
OF mtl_material_transactions mmt.
mtl_system_items_b msib,
mtl_transaction_types mtt,
org_organization_definitions ood,
mtl_txn_source_types mts
WHERE mmt.organization_id = msib.organization_id
AND msib.inventory_item_id = mmt.inventory_item_id
AND mmt.transaction_type_id = mtt.transaction_type_id
AND mmt.organization_id = ood.organization_id
AND mtt.transaction_type_name = "Completion of work in PROGRESS"
AND mts.transaction_source_type_name = 'job or schedule. "
AND msib.segment1 = NVL (: p_item, msib.segment1)
AND ood.organization_code =: p_manufacturing_plant
AND BETWEEN TRUNC (mmt.transaction_date): p_start_date
AND: p_end_date), 0)
-
(((SELECT SUM (mmt.transaction_quantity) total_NET_qty NVL
OF mtl_material_transactions mmt.
mtl_system_items_b msib,
mtl_transaction_types mtt,
org_organization_definitions ood,
mtl_txn_source_types mts
WHERE mmt.organization_id = msib.organization_id
AND msib.inventory_item_id = mmt.inventory_item_id
AND mmt.transaction_type_id = mtt.transaction_type_id
AND mmt.organization_id = ood.organization_id
AND mtt.transaction_type_name = "Ongoing work exit"
AND mts.transaction_source_type_name = 'job or schedule. "
AND msib.segment1 = NVL (: p_item, msib.segment1)
AND ood.organization_code =: p_manufacturing_plant
AND BETWEEN TRUNC (mmt.transaction_date): p_start_date
AND: p_end_date
(), 0))) abs_qty of dual) * csc.standard_cost AS abs_val
OF mtl_material_transactions mmt.
mtl_system_items_b msib,
mil mtl_item_locations
mtl_transaction_types mtt,
org_organization_definitions ood,
mtl_txn_source_types mts,
MC mtl_categories,
mtl_item_categories mic,
MCS mtl_category_sets,
cst_item_costs cic,
cst_standard_costs csc,
cst_cost_types ct,
mfg_lookups OLM
WHERE mmt.organization_id = msib.organization_id
AND msib.inventory_item_id = mmt.inventory_item_id
AND mmt.locator_id = mil.inventory_location_id
AND mil.organization_id = msib.organization_id
AND mil.subinventory_code = mmt.subinventory_code
AND mmt.transaction_type_id = mtt.transaction_type_id
AND msib.organization_id = ood.organization_id
AND mic.category_set_id = mcs.category_set_id
AND mc.category_id = mic.category_id
AND mc.structure_id = mcs.structure_id
AND mic.inventory_item_id = msib.inventory_item_id
AND mic.organization_id = msib.organization_id
AND mcs.category_set_id = 52487965
AND msib.inventory_item_id = cic.inventory_item_id
AND msib.organization_id = cic.organization_id
AND ct.cost_type_id = cic.cost_type_id
AND cic.organization_id = ood.organization_id
AND mil.inventory_location_id = mmt.locator_id
AND mmt.transaction_source_type_id = mtt.transaction_source_type_id
AND mmt.transaction_action_id = mtt.transaction_action_id
AND mmt.transaction_source_type_id = mts.transaction_source_type_id
AND mmt.transaction_action_id = mlo.lookup_code
AND mmt.inventory_item_id = csc.inventory_item_id
AND mmt.organization_id = csc.organization_id
AND csc.last_update_date > =.
(SELECT MAX (csc1.last_update_date)
OF cst_standard_costs csc1
WHERE csc1.inventory_item_id = mmt.inventory_item_id
AND csc1.organization_id = mmt.organization_id)
AND msib.segment1 = NVL (: p_item, msib.segment1)
AND NVL (mc.segment6, 'X') = NVL (: p_base_model, NVL (mc.segment6, 'X'))
AND = NVL (msib.planner_code, 'Y')
NVL (: p_planner_code, NVL (msib.planner_code, 'Y'))
AND SUPERIOR (mlo.meaning) = "COMPLETION of the ASSEMBLY.
AND mtt.transaction_type_name = "Completion of work in PROGRESS"
AND ct.cost_type = 'Frozen '.
AND mts.transaction_source_type_name = 'job or schedule. "
AND ood.organization_code =: p_manufacturing_plant
AND BETWEEN TRUNC (mmt.transaction_date): p_start_date AND: p_end_date
If abs_qty and, accordingly, abs_val must not be the same for all rows returned, you will need to rewrite your query so that the abs_qty will not be calculated (separately) in isolation without interaction with the data in the main table list.
Your query is treated the same as below (note the changed table alias by adding numbers to the original of yours)
SELECT mmt.transaction_date date_produced,
msib.segment1 item,
cic.cost_type_id,
msib.description item_description,
mc.segment6 base_model,
mc.segment7 trade_brand,
mmt.subinventory_code subinventory,
mil.segment1 || '.' || mil.segment2 || '.' || mil.segment3 LOCATOR,
ood.organization_code || '-' || ood.organization_name manufacturing_plant,
mmt.transaction_quantity quantity_produced,
mtt.transaction_type_name transaction_type,
msib.inventory_item_id,
msib.organization_id,
cic.material_cost COST,
cic.material_overhead_cost freight,
csc.standard_cost,
(select (NVL(
(SELECT SUM (mmt1.transaction_quantity) total_NET_qty
FROM mtl_material_transactions mmt1,
mtl_system_items_b msib1,
mtl_transaction_types mtt1,
org_organization_definitions ood1,
mtl_txn_source_types mts1
WHERE mmt1.organization_id = msib1.organization_id
AND msib1.inventory_item_id = mmt1.inventory_item_id
AND mmt1.transaction_type_id = mtt1.transaction_type_id
AND mmt1.organization_id = ood1.organization_id
AND mtt1.transaction_type_name = 'WIP Completion'
AND mts1.transaction_source_type_name = 'Job or Schedule'
AND msib1.segment1 = NVL (:p_item, msib1.segment1)
AND ood1.organization_code = :p_manufacturing_plant
AND TRUNC (mmt1.transaction_date) BETWEEN :p_start_date AND :p_end_date
),0
) - NVL(
(SELECT SUM (mmt2.transaction_quantity) total_NET_qty
FROM mtl_material_transactions mmt2,
mtl_system_items_b msib2,
mtl_transaction_types mtt2,
org_organization_definitions ood2,
mtl_txn_source_types mts2
WHERE mmt2.organization_id = msib2.organization_id
AND msib2.inventory_item_id = mmt2.inventory_item_id
AND mmt2.transaction_type_id = mtt2.transaction_type_id
AND mmt2.organization_id = ood.2organization_id
AND mtt2.transaction_type_name = 'WIP Issue'
AND mts2.transaction_source_type_name = 'Job or Schedule'
AND msib2.segment1 = NVL (:p_item, msib2.segment1)
AND ood2.organization_code = :p_manufacturing_plant
AND TRUNC (mmt.2transaction_date) BETWEEN :p_start_date AND :p_end_date
),0
)
) abs_qty
from dual
) AS ABS_qtyy,
(select (NVL(
(SELECT SUM (mmt3.transaction_quantity) total_NET_qty
FROM mtl_material_transactions mmt3,
mtl_system_items_b msib3,
mtl_transaction_types mtt3,
org_organization_definitions ood3,
mtl_txn_source_types mts3
WHERE mmt3.organization_id = msib3.organization_id
AND msib3.inventory_item_id = mmt3.inventory_item_id
AND mmt3.transaction_type_id = mtt3.transaction_type_id
AND mmt3.organization_id = ood3.organization_id
AND mtt3.transaction_type_name = 'WIP Completion'
AND mts3.transaction_source_type_name = 'Job or Schedule'
AND msib3.segment1 = NVL (:p_item, msib3.segment1)
AND ood3.organization_code = :p_manufacturing_plant
AND TRUNC (mmt3.transaction_date) BETWEEN :p_start_date AND :p_end_date
),0
) - NVL(
(SELECT SUM (mmt4.transaction_quantity) total_NET_qty
FROM mtl_material_transactions mmt4,
mtl_system_items_b msib4,
mtl_transaction_types mtt4,
org_organization_definitions ood4,
mtl_txn_source_types mts4
WHERE mmt4.organization_id = msib4.organization_id
AND msib4.inventory_item_id = mmt4.inventory_item_id
AND mmt4.transaction_type_id = mtt4.transaction_type_id
AND mmt4.organization_id = ood4.organization_id
AND mtt4.transaction_type_name = 'WIP Issue'
AND mts4.transaction_source_type_name = 'Job or Schedule'
AND msib4.segment1 = NVL (:p_item, msib4.segment1)
AND ood4.organization_code = :p_manufacturing_plant
AND TRUNC (mmt4.transaction_date) BETWEEN :p_start_date AND :p_end_date
),0
)
) abs_qty
from dual
) * csc.standard_cost AS abs_val
FROM mtl_material_transactions mmt,
mtl_system_items_b msib,
mtl_item_locations mil,
mtl_transaction_types mtt,
org_organization_definitions ood,
mtl_txn_source_types mts,
mtl_categories mc,
mtl_item_categories mic,
mtl_category_sets mcs,
cst_item_costs cic,
cst_standard_costs csc,
cst_cost_types ct,
mfg_lookups mlo
WHERE mmt.organization_id = msib.organization_id
AND msib.inventory_item_id = mmt.inventory_item_id
AND mmt.locator_id = mil.inventory_location_id
AND mil.organization_id = msib.organization_id
AND mil.subinventory_code = mmt.subinventory_code
AND mmt.transaction_type_id = mtt.transaction_type_id
AND msib.organization_id = ood.organization_id
AND mic.category_set_id = mcs.category_set_id
AND mc.category_id = mic.category_id
AND mc.structure_id = mcs.structure_id
AND mic.inventory_item_id = msib.inventory_item_id
AND mic.organization_id = msib.organization_id
AND mcs.category_set_id = 52487965
AND msib.inventory_item_id = cic.inventory_item_id
AND msib.organization_id = cic.organization_id
AND ct.cost_type_id = cic.cost_type_id
AND cic.organization_id = ood.organization_id
AND mil.inventory_location_id = mmt.locator_id
AND mmt.transaction_source_type_id = mtt.transaction_source_type_id
AND mmt.transaction_action_id = mtt.transaction_action_id
AND mmt.transaction_source_type_id = mts.transaction_source_type_id
AND mmt.transaction_action_id = mlo.lookup_code
AND mmt.inventory_item_id = csc.inventory_item_id
AND mmt.organization_id = csc.organization_id
AND csc.last_update_date >= (SELECT MAX (csc1.last_update_date)
FROM cst_standard_costs csc1
WHERE csc1.inventory_item_id = mmt.inventory_item_id
AND csc1.organization_id = mmt.organization_id
)
AND msib.segment1 = NVL (:p_item, msib.segment1)
AND NVL (mc.segment6, 'X') = NVL (:p_base_model, NVL (mc.segment6, 'X'))
AND NVL (msib.planner_code, 'Y') = NVL (:p_planner_code, NVL (msib.planner_code, 'Y'))
AND UPPER (mlo.meaning) = 'ASSEMBLY COMPLETION'
AND mtt.transaction_type_name = 'WIP Completion'
AND ct.cost_type = 'Frozen'
AND mts.transaction_source_type_name = 'Job or Schedule'
AND ood.organization_code = :p_manufacturing_plant
AND TRUNC (mmt.transaction_date) BETWEEN :p_start_date AND :p_end_date
Concerning
Etbin
Tags: Database
Similar Questions
-
Find the same value in different columns
Hello
I'm trying to figure out how I would get the same value in the same row but in different columns. For example, in the table sometimes report the name is the same as the description. I would like to find all the lines where this is the case.
Thank you
Name of the report Description Date Time Report 1 Report 1 Delalande TTTT Report 2 Billing report Delalande TTTT Report 3 Report 3 Delalande TTTT Hello
Is that what you want?
SELECT *- or whatever the columns that you want to
FROM table_x
WHERE description = report_name
;
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
Explain, using specific examples, how you get these results from these data.
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
-
Search for a similar string in the 2D array and displays the result with another column
Hello
One who can help, I have a chart 2D of txt file that have as many lines and 5 columns and I want to do a search and display the other results of the column.
For example.
Column 0 1 2 3 4
12345 qwer asdf 12qwe tjhrtyert
werr 23568 wef fgertge fsefff
If I manage to find 12345 and I want to display 12qwe, what should I do in labview? Help, please!
-
Try to install purchased box. Alls well until the last window when this message appears. INCONSISTENCY IN THE DATABASE OF THE INSTALLER. RESTART YOUR COMPUTER AND INSTALL IT AGAIN. Fact as stated several times and redisplays but same message?
Run the cleanup tool and manually delete the caps.db file.
Important directories | Error postal codes of Mylenium
Use the CC cleaning tool to resolve installation problems. CC, CS3 - CS6
When you reinstall, make sure that you run with user privileges sufficient and external tools like virus scanners do not interfere. This is why you have the question in the first place.
Mylenium
-
spend multiple lines of the same query in params/variables and display
Hi guys :)
I can really use your help in something so that I can not find a solution.
I need to write a procedure that displays the number of lines by an object any and it will display.
I can write the sql query, but I can't find a way to do it in the pl/sql procedure.
I need to pass these results in params or variables and display in dbms.output.
SYS > select count (par_res_id), election_master.results par_res_id
2 the par_res_id group;
COUNT (PAR_RES_ID) PAR_RES_ID
----------------- ----------
24 1
40 2
54 4
5 of 23
59 3
could u please help.
Thanks in advance
Published by: 915417 on March 3, 2012 06:49
-
An update on an index column with the same value generates an index to the top
An update on an index column with the same value generates an update of the index?
Thank youIn addition to my previous answer, see also
http://orainternals.WordPress.com/2010/11/04/does-an-update-statement-modify-the-row-if-the-update-modifies-the-column-to-same-value/
Riyaj Shamsudeen has this to say:
"+ We have an index on this column v1 and we update this column indexed too." Oracle was updating the indexed column? N ° if the values match the level of the indexed column, then the code of RDBMS isn't up-to-date index, a feature for optimization again. Only the row of table is updated, and the index is not updated. + "Hemant K Collette
-
All channels to HAVE it have the same value
I use the example for a multichannel AI aiex2.cpp read with mseries NI6280 devices.
This example works for a lane, but other chains have the same value
For example: I put 5 Volt on the first string, and then the other channel are 5 Volt too.
What should I consider in the configuration?
Hello Beilei,
I think that you run in theghost of the question. The other strings that you use are connected to the earth when you connect the first channel to 5V? If the other channels are floating, they will read the same value as the first string... 5V.
Steven T.
-
All channels to HAVE it have the same value - NI PCI-6221 and NI PCI-6229
Hello
I use the aiex1.cpp example for a multi-channel read with the devices mseries 6221 and 6229.
This example works for a lane, but other chains have the same value (difference of +-0.001 Volt).
For example: I put 5 Volt on the first string, and then the other channel are 5 Volt too.
What should I consider in the configuration?
Heiko Hello!
your description looks like the effect you are having 'ghosts '.
For more information about ghost images and how to get rid of, check out these links:
http://digital.NI.com/public.nsf/allkb/73CB0FB296814E2286256FFD00028DDF?OpenDocument
and
http://digital.NI.com/public.nsf/allkb/C6C7DE575301A379862572DD00480A01?OpenDocument
Best regards
Moritz M.
-
Need to show the same values in all jspx pages
Hello.
I use jdeveloper 11.1.1.5
I had created a jspx pages such as dept.jspx and emp.jspx
I've been using this in my jspx page
The bindings.return.inputValue will return the value of the code below<af:outputText value="#{bindings.return.inputValue}" binding="#{pageFlowScope.backing_dept.ot1}" id="ot1"/>
My scenario is that I need to display the same value in emp.jspxpublic String checkLoginCredentials1(String p_user,String p_pwd) { System.out.println(p_user + " " + p_pwd); ApplUsersVOImpl vo = (ApplUsersVOImpl)this.getApplUsers1(); /*set the bind variable value*/ vo.setNamedWhereClauseParam("p_user",p_user.toUpperCase()); vo.setNamedWhereClauseParam("p_pwd",p_pwd.toUpperCase()); vo.executeQuery(); int rowCount=vo.getEstimatedRangePageCount(); System.out.println("rowCount="+rowCount); if(rowCount==0) { throw new JboException("Password doesn't match"); } return "Welcome"+ " " + p_user.toUpperCase(); }
I had created a task flow frm dept.jspx to emp.jspx and emp.jspx to dept.jspx
I tried the same XML file in my emp.jspx
But while I m browsing frm emp.jspx to dept.jspx there are doesnot.,.<af:outputText value="#{bindings.return.inputValue}" binding="#{pageFlowScope.backing_emp.ot1}" id="ot1"/>
This means that for the faces-config. XML (the standard JSF configuration file), there is no scope spanning application except for the scope of the session. This does not mean that you should not use extended session if you use faces - config.Xml.
However, you have been advised to use the workflow and no faces - config.Xml.
-
Use the listbox control to select several channels and display on the chart
Hello everyone!
I have a problem using the ListBox selection mode 1 or mode items. I have 6 channels of data, and I have a 2D chart. I am able to reterieve the signal names in the list box, but I want to be able to choose one or more signals to display on the chart. I used the table to index my 2D data are connected and then the output of the index table is connected to the graph. I had to use the listbox control as an index for the table to index and display the data in the index selected for display on the chart. I used lisbox as the value property nodes, the line active and all but not able to display signals on the graph. I have attached a code example to show you what exactly I'm looking.
Any suggestions will help a lot.
-
Hello
My send UUT to my computer via serial port of printable and non-printable ascii characters. The question is:
(1) how to display all characters in a text box.
(2) how can I display all these characters in hexadecimal format and display it in a text box?
Thank you.
Robert
Text boxes can actually receive channels with printable and non-printable characters: nonprinting characters will be represented with a small square. For example, consider this code:
tank has [512], msg [512];
Create a string with embedded unprintable characters
sprintf (one, "Hello: %c %c %c %c % c: World!", 1, 2, 3, 4, 5);
Pass the string to the text box "such what."
ResetTextBox (bH [1], b1_n, a);
Format a hexadecimal representation of the string and add it to the text box
FMT (msg, '\n%*d[zb1r16w2p0j1]', strlen (a), a);
SetCtrlVal (Bosnia and Herzegovina [1], b1_n, msg);The result is as follows: the first line is the string passed "such what", what follows is the hexadecimal representation.
-
Play video and display an image at the same time
Hi all
I'm new to JavaFX and I would like to know if it is possible to read a video simultaneously and display an image above him in the same scene.
In particular, I want the image to display in a fixed position.
I tried to use a StackPane layout, but I get an error in the following line:
sp.getChildren().add(mediaPlayer);
because the mediaPlayer object cannot be considered to be a parameter and a node object is necessary
I also tried to add the video and the image in the same scene as seen below, without success (the video is playing, but the image is not displayed)
root.getChildren().add(imageView);
Is what I'm trying to do possible? And if so, what methods should I use?
Thanks in advance for any answer!
I tried to use a StackPane layout, but I get an error in the following line:
- sp.getChildren () .add (mediaPlayer);
because the mediaPlayer object cannot be considered to be a parameter and a node object is necessary
Wrap the mediaPlayer in a MediaView and add the media view to the container. Do not use a group as the component root as in the code example in the example, though.
I also tried to add the video and the image in the same scene as seen below, without success (the video is playing, but the image is not displayed)
I think it is because you are using a StackPane, that stacks on top of the other nodes (in the Z-order); so if you add the video first it will be hidden by the image. Use a different presentation pane: VBox is the simplest. The tutorial has a summary of all the components of integrated layout .
If you are going to do something like this:
public void start(Stage primaryStage) { Media media = new Media(...); MediaPlayer player = new MediaPlayer(media); MediaView mediaView = new MediaView(player); Image image = new Image(...); ImageView imageView = new ImageView(image); VBox root = new VBox(5); root.getChildren().add(mediaView); root.getChildren().add(imageView); Scene scene = new Scene(root); primaryStage.setScene(scene); primaryStage.show(); }
-
How to restrict the user to enter not same value in a table
Greetings!
I m asking a second time the upfront because I did not answer preivously, so please don't mind if it's a double.
It was: I have created a table, as shown in the example.
I want to validate the user name that you see in my example to restrict the user to enter the same value in the user name field before submitting page.
for example when the user enters data as u see test in user name in the first row, when it goes to the second row and type same username as test "message will appear or restrict the user who has already typed or in use"...
http://Apex.Oracle.com/pls/Apex/f?p=45296:1:22797340776918:
It's all done on typing submit prior to registration.
Please driversHello
I m asking a second time the upfront because I did not answer preivously, so please don't mind if it's a double.
It was: I have created a table, as shown in the example.
I want to validate the user name that you see in my example to restrict the user to enter the same value in the user name field before submitting page.
for example when the user enters data as u see test in user name in the first row, when it goes to the second row and type same username as test "message will appear or restrict the user who has already typed or in use"...
http://Apex.Oracle.com/pls/Apex/f?p=45296:1:22797340776918:
It's all done on typing submit prior to registration. >
Stick the code below into the Page header > Javascript > run when loading the Page field.
$('[input[name="f03"]').blur(function(){ if ($('input[name="f03"][id!="'+$(this).attr('id')+'"]').val() == $(this).val()) { alert('Duplicate Entry.'); var x = $(this).attr('id'); setTimeout("(function(p){$('#'+p).focus();})('"+x+"')",100); } })
Note:
a.F03 is the 'name' of your column of username in the form of tables.
b. This only valid values. If your tabular presentation has multiple pages then all of the rows are not currently displayed will be ignored.See you soon,.
-
Retrieve and display a result set using the dynamic sql?
Hi all
How would display a result set in Oracle using the dynamic SQL? Reason being, the table where I'd retrieve and display the result set is a GLOBAL TEMP TABLE created in a stored procedure. If I try to use the loop as usual, the compiler complains that the table does not exist. This makes sense because the compiler does not recognize the table because it is created dynamically. Here is an example:
create or replace PROCEDURE maketemptab IS
sql_stmt VARCHAR2 (500);
OutputString VARCHAR2 (50);
BEGIN
-create temporary table
sql_stmt: = ' CREATE of TABLE TEMPORARY GLOBAL globtemptab (id NUMBER, col1 VARCHAR2 (50))';
EXECUTE IMMEDIATE sql_stmt;
dbms_output.put_line ('... created table ');
-Insert a row into the temporary table
sql_stmt: = "INSERT INTO globtemptab values (1, 'some data of a test')';"
EXECUTE IMMEDIATE sql_stmt;
dbms_output.put_line ('... inserted row ');
-Insert a row into the temporary table
sql_stmt: = ' INSERT INTO globtemptab values (2, "some more test data");
EXECUTE IMMEDIATE sql_stmt;
dbms_output.put_line ('... inserted row ');
-Select the row on temporary table
sql_stmt: = 'SELECT col1 FROM globtemptab WHERE id = 1';
EXECUTE IMMEDIATE sql_stmt INTO outputstring;
dbms_output.put_line ('... selected line: ' | outputstring);
-drop temporary table
sql_stmt: = 'DROP TABLE globtemptab;
EXECUTE IMMEDIATE sql_stmt;
dbms_output.put_line ('... moved table ');
-display the result set
for tabdata loop (select col1 from globtemptab)
dbms_output.put_line ('... test of recovered data are' | tabdata.col1)
end loop;
end;
In short, how to rewrite the SQL below the comment "to display the result set" using the dynamic sql?
Thank you
Amedeo.Hello
Try this:
CREATE OR REPLACE PROCEDURE maketemptab IS sql_stmt VARCHAR2(500); outputstring VARCHAR2(50); v_cursor SYS_REFCURSOR; v_col1 VARCHAR2(30); BEGIN -- create temp table sql_stmt := 'CREATE GLOBAL TEMPORARY TABLE globtemptab(id NUMBER, col1 VARCHAR2(50))'; EXECUTE IMMEDIATE sql_stmt; dbms_output.put_line('...table created'); -- insert row into temp table sql_stmt := 'INSERT INTO globtemptab values (1, ''some test data'')'; EXECUTE IMMEDIATE sql_stmt; dbms_output.put_line('...row inserted'); -- insert row into temp table sql_stmt := 'INSERT INTO globtemptab values (2, ''some more test data'')'; EXECUTE IMMEDIATE sql_stmt; dbms_output.put_line('...row inserted'); -- select row from temp table sql_stmt := 'SELECT col1 FROM globtemptab WHERE id=1'; EXECUTE IMMEDIATE sql_stmt INTO outputstring; dbms_output.put_line('...row selected: ' || outputstring); OPEN v_cursor FOR 'SELECT col1 FROM globtemptab'; LOOP FETCH v_cursor INTO v_col1; EXIT WHEN v_cursor%NOTFOUND; dbms_output.put_line('...test data retrieved is' || v_col1); END LOOP; CLOSE v_cursor; -- drop temp table sql_stmt := 'DROP TABLE globtemptab'; EXECUTE IMMEDIATE sql_stmt; dbms_output.put_line('...table dropped'); END; /
Kind regards
-
Hello
I have this request:
Select b.db_name, a.handle from bp a, dbinc b where a.db_key = b.db_key;
By request I see the lines where the handle columns have the same values?
Thank you.Hello
First thing is that your question is very abstract, we can not know which data table you is central to the present moment.
Select b.db_name, a.handle from bp a, dbinc b where a.db_key = b.db_key;
By request I see the lines where the handle columns have the same values?What you mean you 'same' values with what data need to be compared to 'the same '.
Fact it is same or some values.-Pavan Kumar N
Maybe you are looking for
-
I have a desktop Dell running Windows XP Pro. When I installed a webcam, (a Microsoft LifeCam VX-5000) and plugged into a powered USB hub half lower part of the image that is displayed by the Webcam flickered. None of the webcam settings corrected th
-
Problems to unzip the file in Notepad
I am trying to unzip a registered ebook which opens in Notepad, but the notebook is full of symbols and signs that make no sense? Can you advise?
-
==================================================Dump file: 122315-15568 - 01.dmpCrash time: 23/12/2015-13:00:03Bug Check String: PAGE_FAULT_IN_NONPAGED_AREABug check Code: 0 x 00000050Parameter 1: fffff820'049e93d8Parameter 2: 00000000'00000001Para
-
Disable the right click on the mouse
Hello I use Windows 7 Professional and want to disable the right click on a Standard user account - is it possible? Kind regards Colin
-
is it possible to control the file on the clients offline sync errors?
We have several customers (80 years) who use the offline folder feature. Sometimes, a client computer has a sync error but remains unnoticed by the user. It resulted in los data to one of the users. We would like to see the errors of synchronization