Populate & Retrieve in one Select - problems !!!
Hi There.
What I would like to be able to do is populate a row in a table (via a function) and retrieve that row all in one Select statement. Unfortunately I don't get any data returned from the Select. I have in mind something like the following:-
SELECT * FROM MY_TABLE
WHERE MY_TABLE.UNIQUEID = F_MY_FUNCTION('MY KEY INFO');
Where MY_TABLE is defined say like :-
CREATE TABLE MY_TABLE (
UNIQUEID NUMBER NOT NULL,
NUMB_FIELD NUMBER,
CHAR_FIELD VARCHAR2(100),
CHAR_FIELD2 VARCHAR2(100)
The function would look something like this :-
CREATE OR REPLACE Function F_MY_FUNCTION(sKeyInfo VarChar2)
RETURN Number IS
PRAGMA AUTONOMOUS_TRANSACTION;
nUniqueID Number := 0;
nNumb_field Number :=
sChar_field VarChar2(100) := '';
sChar_field2 VarChar2(100) := '';
begin
-- Retrieve Data via middleware (simulate)
nNumb_field := 2734;
sChar_field := 'The quick brown fox';
sChar_field2 := 'jumps over the lazy dog.';
-- Insert Data into Table
-- 1st get the unique id from the sequence
Select SEQ_SG.NextVal into nUniqueID from dual;
-- Now insert data into row in table
Insert Into MY_TABLE (
UniqueID, Numb_Field, Char_field, Char_field2)
Values (nUniqueID, nNumb_Field, sChar_field, sChar_field2);
Commit;
-- Return Row Id of Table to use in Select statement
Return nUniqueID;
end;
It appears to run out of sequence. Ie. The correct 'uniqueid' is being returned from the function but the results are not yet available for the 'Select' statement. When you look at what's in the table the function has populated the rows correctly, but for some reason the 'select' statement can't seem to see the results immediately.
Help - what am I doing wrong?
PS. Any help would be appreciated.
How about this approach?
SQL> CREATE TABLE at1 (col1 number primary key, col2 varchar2(30));
Table created.
SQL> CREATE SEQUENCE as1;
Sequence created.
SQL> CREATE OR REPLACE TRIGGER at1_bir BEFORE INSERT ON at1 fOR EACH ROW
2 DECLARE
3 ln number;
4 BEGIN
5 SELECT as1.nextval INTO ln
6 FROM dual;
7 :NEW.col1 := ln;
8 END;
9 /
Trigger created.
SQL> var x number
SQL> INSERT INTO at1 (col2) VALUES ('APC')
2 RETURNING col1 INTO :x
3 /
1 row created.
SQL> print x
X
1Cheers, APC
Similar Messages
-
Populate Text fields from Select List
I have a select list when selected should populate two text fields with values based on SQL Query
Eg. The select list is for empno and populates ename and sal in two different text fields.
I have looked at Denes' example http://htmldb.oracle.com/pls/otn/f?p=31517:42 It is very good but the only problem I am facing is how to populate more than one fields.
Any help will be appreciated.
ZRHHi
That would depend on where the SAL data is. If it's on your page, then you could probably do something with javascript. If not, you would have to do some Ajax to retrieve the value from the database. Have a look at: http://htmldb.oracle.com/pls/otn/f?p=31517:80
Your select list could include both the ENAME and SAL values and your existing javascript would then just split the data into two parts and insert them into the appropriate fields.
Andy -
Data retrieve from one table control to another table control
Hi all,
I had an requirement like to create Two table controls.
for first Table control i had an sel field defined as 'MARK'.
when i check the row in the first table control think it is header data for sales order .
all the item details have to retrieve in the second table control.
This is my requirement, i am not able to trigger when selecting the row in table control.
will anybody had an experience like this.
Regards,
MadhaviHi Madhavi,
If we need the case to display header and item as mentioned in 2 table controls....
we can display in table control 2/item only (the line items of the one selected in the table control 1 or the header )...so ,at a time we need to display line items for only 1 header ....
so ...first disable the selections/multiple selections to disable the row selector
We have already declared a field type C to capture the value for the field selector...so we can convert this field to a radio button and then assign a function code to the radio button at screen level
Whenever you click on the radio button ..immediately the function code is triggered..then in PAI ..we can check and find the header record with 'X' and populate the data for the table control 2
Hope it helps
Regards
Byju -
Hello,
i have a selection problem with JTable. I want to allow only single cell selection and additionally limit the selection to the first column.
I preffered the style from MS Outlook Express where you can select the email accounts to edit.
It is a table like this:
Account name | Type | ...
--------------|---------|---------------------
Hotmail | POP3 |
GMX | IMAP |The selection should be only avaibable at 'Hotmail' or 'GMX' - not at 'POP3', 'IMAP' or as complete row selection.
Please help me!
Thanks.
WarlockMaybe this will helpimport java.awt.*;
import javax.swing.*;
public class Test3 extends JFrame {
public Test3() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container content = getContentPane();
String[] head = {"One", "Two"};
String[][] data = {{"R1-C1", "R1-C2"}, {"R2-C1", "R2-C2"}};
JTable jt = new JTable(data, head);
jt.getColumnModel().setSelectionModel(new MyTableSelectionModel());
content.add(new JScrollPane(jt), BorderLayout.CENTER);
jt.setCellSelectionEnabled(true);
jt.setRowSelectionAllowed(false);
jt.setColumnSelectionAllowed(false);
setSize(300, 300);
setVisible(true);
public static void main(String[] arghs) { new Test3(); }
class MyTableSelectionModel extends DefaultListSelectionModel {
public void setSelectionInterval(int index0, int index1) {
super.setSelectionInterval(0, 0);
} -
How to get number of records in all user tables in one select
Please advise how to retrieve the number of records in all user tables in one select. I would likt to extract the data to excel file.
Many thanks,
AndrewYou could always analyze the tables:
declare
begin
for X in (select owner, table_name from all_tables
minus
select owner, table_name from all_external_tables) LOOP
dbms_stats.Gather_Table_Stats(X.Owner, X.Table_Name) ;
end loop;
end;
/Then: Select Owner, Table_Name, Num_Rows from All_Tables ; -
How to populate table rows with selected listbox items?
Hello,
I am trying to populate a table with selected listbox items. Each item should be a new row in the table. The picture below is the listbox and table I am using. I need to get the selected name to populate the Attendee column of the table when the user clicks the Add button. How do you do this with mutltiple attendees selected?
Thank you,
AngieSo you're considering the fact the if the user clicks the button twice, the name will appear twice and you don't want this, right?
Then you must check if any value is the same than the one you are about to add in the row..
for (var i = 0 ; i < ListBox1.length; i++){
if (ListBox1.getItemState(i) == true){
for (var x = 0 ; x < Table1._Row1.count; x++){
var boNewAttendee = true;
var strAttendee = Table1.resolveNode("Row1[" + x.toString() + "]").txtAttendee;
var newAttendee = ListBox1.getDisplayItem(i);
if (strAttendee.rawValue == newAttendee){
boNewAttendee = false;
break;
if (boNewAttendee){
txtAttendee.rawValue = ListBox1.getDisplayItem(i); -
More than one selects in a function
Hi All,
Is it that there can not be more than one selects in a function?What is the work around for this thing?
Regards,
Amit.Hi Krystian Zieja ,
Thanks for responding. I do not know what was going wrong but now it is working fine.
The problem is that I was not able to compile a function with two select statements in it. If I could comment one of the select statements it was getting compiled. But now it is getting compiled with both the selects.
Now since we are at it can you solve another of my problem. I want to see the output of my function. If I write DBMS_OUTPUT.PUT_LINE statements in it I am not able to see the output. Is there anyway that I can call my function and it can show the output on the screen.
I am using Benthic Golden 32 editor. Is there any way in it that I can call my function from it ?
Regards,
Amit. -
Add one Select-Options : LIKP-LGBZO into Shipment Transaction - VT02N
Hello,
Transaction - VT02N(Change Shipment) -- Now choose Select Deliveries(F6).
Now one Selection-Screen will come to Select Outbound Deliveries.
In this Screen I want to add one more Select-Options (LIKP-LGBZO)
How can I add this Select-Options into this Screen.
Please provide solution .
Edited by: Matt on Sep 22, 2010 10:04 AM - edit title - causing problems displaying in Firefox.Hi,
we can not modify SAP Standard screen with out access key.
If you want any field validation try this Exit:
Enhancement V56BMOD Transportation processing: Field modification
Thanks,
AMS -
How to populate LOV of one prompt based on other prompts w/o cascade
Hello All,
Scenario- There are three prompts in my report.
Source_Prompt1, Source_Prompt2 and Target_Prompt.
There is no direct reletion between Source_Prompt1 and Source_Prompt2.
And user wants Target_Prompt data on selection of these source_prompts.
Is there any way to populate target prompt on selection of source prompt.
Note- This can be implemented by applying cascading between all three prompts fields.
However user dosent want Cascading between source prompts.?
is there any other method except cascading prompt to populate LOV of one prompt based on selection of other prompt values?
Your insights are most welcome.
AmitI believe the only way to populate LOVs is directly from a database. E.g.; you can not populate it "manually". In your case, you may have to create your own prompt forms and use those.
- Ludek -
Retrieve only one type of phone number
Hi
In the following sample query I need to retrieve only one phone number. The preference is if Mobile available - mobile number if not Home number (Type - H1), else Work number (W1).
I have included the script and sample output what I am getting from the SQL
Thanks in advance
Regards
Sriram
select pp.ph_id
,papf.person_id
,pp.ph_type
,pp.ph_no
,pp.date_from
,pp.date_to
from per_phones pp
,per_all_people_f papf
,per_contact_relationships pcr
where papf.person_id = pp.parent_id
and pcr.person_id = papf.person_id
and trunc(sysdate) between trunc(nvl(pcr.date_start, sysdate-1))
and trunc(nvl(pcr.date_end, sysdate+1))
and papf.person_id in (146564, 514)
and pcr.primary_contact_flag = 'Y'
and trunc(sysdate) between papf.effective_start_date and papf.effective_end_date
and trunc(sysdate) between nvl(pp.date_from, sysdate-1) and nvl(pp.date_to, sysdate+1);output
PH_ID PERSON_ID PH_TYPE PH_NO DATE_FROM DATE_TO
3261 514 H1 987524879 13-Jun-04
117287 514 M 0403672797 11-May-05
141997 146564 H1 54789620 15-Feb-06 05-Mar-10
311028 146564 H2 235469 5-Dec-09
311029 146564 W1 8300054 15-Dec-09
311108 146564 M 04126872 12-Feb-10Not tested, but something like this might do the trick. What you need to do is assign a hierarchy to the phone type codes, then choose the top one for each parent id.
WITH phone_list
AS ( SELECT parent_id,
MIN( CASE ph_type
WHEN 'M' THEN 1
WHEN 'H1' THEN 2
WHEN 'W' THEN 3
ELSE 99
END ) AS phone_pref
FROM per_phones
GROUP
BY parent_id )
SELECT pp.ph_id,
papf.person_id,
pp.ph_type,
pp.ph_no,
pp.date_from,
pp.date_to
FROM per_phones pp,
per_all_people_f papf,
per_contact_relationships pcr,
phone_list lst
WHERE papf.person_id = pp.parent_id
AND pcr.person_id = papf.person_id
AND trunc(sysdate) between trunc(nvl(pcr.date_start, sysdate-1))
AND trunc(nvl(pcr.date_end, sysdate+1))
AND papf.person_id in (146564, 514)
AND CASE pp.ph_type
WHEN 'M' THEN 1
WHEN 'H1' THEN 2
WHEN 'W' THEN 3
ELSE 99
END = lst.phone_pref
AND pp.parent_id = lst.parent_id; -
How to join THREE different tables into internal table using one select statement .
How to join THREE different tables into internal table using one select statement .
Hi experts,
I would like to request your guidance in solving the problem of joining the data from three different database tables into one internal table
Scenario:
Database tables:
SPFLI
SFLIGHT
SBOOK.
Table Fields:
SPFLI - CARRID CONNID COUNTRYFR CITYFRM COUNTRYTO CITYTO
SFLIGHT - CARRID CONNID FLDATE SEATSMAX SEATSOCC SEATSMAX_C
SEATSOCC_C SEATSMAX_F SEATSOCC_F
SBOOK - CARRID CONNID CLASS
MY INTERNAL TABLE IS IT_XX.
Your help much appreciated.
Thanks in advance.
Pawan.Hi Pawan,
please check below codes. hope it can help you.
TYPES: BEGIN OF ty_xx,
carrid TYPE spfli-carrid ,
connid TYPE spfli-connid ,
countryfr TYPE spfli-countryfr,
cityfrom TYPE spfli-cityfrom ,
countryto TYPE spfli-countryto,
cityto TYPE spfli-cityto ,
fldate TYPE sflight-fldate ,
seatsmax TYPE sflight-seatsmax ,
seatsocc TYPE sflight-seatsocc ,
seatsmax_b TYPE sflight-seatsmax_b,
seatsocc_b TYPE sflight-seatsocc_b,
seatsmax_f TYPE sflight-seatsmax_f,
seatsocc_f TYPE sflight-seatsocc_f,
class TYPE sbook-class,
END OF ty_xx,
t_xx TYPE STANDARD TABLE OF ty_xx.
DATA: it_xx TYPE t_xx.
SELECT spfli~carrid
spfli~connid
spfli~countryfr
spfli~cityfrom
spfli~countryto
spfli~cityto
sflight~fldate
sflight~seatsmax
sflight~seatsocc
sflight~seatsmax_b
sflight~seatsocc_b
sflight~seatsmax_f
sflight~seatsocc_f
sbook~class
INTO TABLE it_xx
FROM spfli INNER JOIN sflight
ON spfli~carrid = sflight~carrid
AND spfli~connid = sflight~connid
INNER JOIN sbook
ON spfli~carrid = sbook~carrid
AND spfli~connid = sbook~connid.
Thanks,
Yawa -
Weird BGP path selection problem
Hi, all,
I am seeing a weird BGP path selection problem on 4948 switch running cat4500-entservicesk9-mz.122-46.SG.bin code, this switch has two uplinks to the same ISP's different edge router, one circuit is primary the other one is strict backup, only default route is accepted from ISP. I am setting both local preference and weight to the default route advertised over backup link, however neither one is taking effect, BGP still thinks the backup link is better, what could be wrong?
rtr#sh ip bgp 0.0.0.0/0
BGP routing table entry for 0.0.0.0/0, version 105
Paths: (3 available, best #2, table Default-IP-Routing-Table, not advertised to EBGP peer)
Not advertised to any peer
17675, (received & used)
203.169.8.37 from 203.169.8.37 (61.211.160.150)
Origin IGP, localpref 100, valid, external
Community: 65001:0 no-export
17675
203.169.8.45 from 203.169.8.45 (61.211.160.151)
Origin IGP, localpref 90, weight 90, valid, external, best <====
Community: 65001:0 no-export
17675, (received-only)
203.169.8.45 from 203.169.8.45 (61.211.160.151)
Origin IGP, localpref 100, valid, external
Community: 65001:0 no-export
ThanksHi,
On cisco routers , weight is having highest preference to decide best path. By default for received route, weight is 0 but you are setting weight 90 to backup path and that is why it is getting preferred (higher is better). Please remove weight and let local preference be 90 (lesser than route on primary path)
--Pls dont forget to rate helpful posts--
Regards,
Akash -
I'm having problems with JList selection - it's really wierd.
I have a Jlist and on different selections I want to do stuff - well, I do see the GUI line get highlighted but everytime my ListSelectionListener is called the selected index stays 0.
also, it always calls the ListSelectionListener twice for every selection I make.
here's how my code looks:
(typesList is my JList)
typesList.setSelectedIndex(0);
typesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
typesList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
int newSelection = typesList.getSelectedIndex(); //this returns always 0! ...
}Look at the line getValueIsAdjusting... (only one selection is processed. And, this code works and provides proper index.
* Method to load all Tables from Database user
public void loadTables() {
// run Database request
tableListModel = getListModelData("select object_name from user_objects where object_type = 'TABLE'");
// now plug List with Model
tableList = new JList(tableListModel);
tableList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
tableList.setSelectedIndex(0);
//tableList.addListSelectionListener(this);
tableList.addListSelectionListener(
new ListSelectionListener() {
public void valueChanged( ListSelectionEvent e )
if(e.getValueIsAdjusting()) return;
String tablename = tableList.getSelectedValue().toString();
showColumnData(tablename);
displayAllTableData(tablename); //intensive (reworking)
jScrollPane1.add(tableList);
jScrollPane1.setViewportView(tableList);
showColumnData(tableList.getSelectedValue().toString());
}PiratePete
http://www.piratepetesoftware.com -
Combo box or similar where more than one selection can be made
Hi. I need to create a combo box field or similar where more than one selection can be made. Does anyone know if this is possible? I know this can be done with the check box tool but the client wants a drop down box. Thanks in advance.
I don't quite understand some of this but of course you can bind more than one object into the RMI Registry. If you use different names the clients will use the object corresponding to whatever name they looked up. If you rebind different objects to the same name, the clients will use the object that was there at the time they did the lookup.
Clustering is a problem for RMI/JRMP because stubs are not location-transparent: they refer to the originating JVM. If you need this kind of functionality I would use RMI/IIOP and do some CORBA magic in the ORBs at both the clustered servers. CORBA references are location-transparent so a service can be logically 'moved' from one JVM to another. -
Certificate selection problem in Safari
Hi ,
I have certifcates A,B,C,D for the same site , whenever i use the Mozilla it is asking which one to select , but somehow i dont know why Safari is asking the same option.
It is forcing me to accept Certifcate A to that paricular site. How to solve this problem in safari.
Regards
VikranthHello. I feel your pain and frustration with the print selection problem in safari, especially in Snow Leopard. I have spent hours trawling help pages and forums etc. BUT YEE HAA (sorry got a bit excited, but it really was hours) I found the answer. So here goes.
Click on Safari
Scroll down to services then slide to right
Scroll down to services preferences and click
Scroll down to the Text section
If you Tick the Text box it will choose all options for you. Or if you don't want all options in the Text list, then untick Text box and tick options you do want.
BUT for your print selection problem make sure you tick NEW TEXT EDIT WINDOW CONTAINING SELECTION.
Then when you want to select something in a web page you want to print (including pictures etc) then highlight it, then Right click. And low and behold, in the list is NEW TEXT EDIT WINDOW CONTAINING SELECTION. Click that, Then press cmd+p and your printing.
I really hope that helps with your problem
I can now go to sleep.
Maybe you are looking for
-
Can't copy .dv movie to external HD
I have finished an iMovieHD6 40 minute project in widescreen using MAC OS X (10.4.11), exported to .dv, making a 9GB movie. I have two questions: 1. My widescreen settings convert to 4:3 ratio playback in the .dv export. 2. I try to copy the .dv file
-
Dynamic Forms (Data Dictionary) using CFForm (??)
Hi, The basic plan is to build the forms in my application dynamically using a data dictionary rather than basing them upon static tables and having statically coded forms to match. This would allow me to offer the ability for an administrator to add
-
Hi all, I've recently upgraded from a ALPB running Leopard to a MBP running Snow Leopard. I also have a TiPB being used as a desktop for backups and media storage. I have a large external drive connected to it that I'm sharing for this purpose. My qu
-
I have an audio file attached to a slide which, after it plays, I leave the slide, but come back to it later. But I don't want the audio file to play upon slide revisit. Is there any way to stop the audio once I come back to the slide?
-
Muse update not updating 2-13-15
muse won't update from creative cloud