PL/SQL scenario for looking different dbs data and update in db.

Hello world
I have a scenario and I need your comments how to handle this in pl/sql:
I have two tables: MEX and MSG
MEX has three columns: (t_id, db_id, t_msg) in main DB
db_id t_msg t_id
_____________________
D1 111
222 D2
D1 112
444 D3

(db_id is link to different dbs. db link db and db names are the same.)

Table of MSG (t_id, d_msg) is found in all the dbs (D1, D2, D3) having the same structure below:
Table e.g. MSG in D1
t_id d_msg
_______________
MSG1 111
MSG22 112


I need to select t_id and table MEX db_id and need to update t_msg to the respective t_id, we take MSG table column d_msg glancing in respective db for t_id with db_id as db_link for db.
Ex: For t_id 111, we db_link D1, then look in the table of MSG of D1 and d_msg for t_id 111 (MSG1) and then update column t_msg for t_id 111 as MSG1.
In real time, we have thousands of lines in the table of MEX, so we must ensure that our statement search t_id given in the table of MSG in db mentioned in column db_id and get d_msg since this database and update in the main DB MEX table in the t_msg column.

Please help me in this scenario. I think we do it dynamically selects d_msg in respective db for t_id we get main DB.

I'd really appreciate your answers and comments.

Thank you very much.

Thus, you will probably have to write a function that uses the dynamic SQL language to retrieve the text of the message you want, like this untested:

CREATE OR REPLACE FUNCTION get_msg(p_db IN VARCHAR2,
                                   p_id IN NUMBER)
   RETURN VARCHAR2
IS
   msg_txt  VARCHAR2(4000);
BEGIN
   -- make sure p_db is a valid database link ...
   EXECUTE IMMEDIATE 'SELECT d_msg FROM msg@' || p_db || ' WHERE t_id = :id' INTO msg_txt USING p_id;

   RETURN msg_txt;
EXCEPTION
   WHEN NO_DATA_FOUND THEN
      RETURN NULL;
END get_msg;
/

You can update as

UPDATE mex
   SET t_msg = get_msg(db_id, t_id);

HTH, Urs

Tags: Database

Similar Questions

  • SQL query for the set of data rows not values

    Hello!

    I use Oracle 10 g (10.2.0.1.0) and I need help to solve this difficult task. I have a huge table with more than 145000 records and I shows you only a sample of it:

    ID TEAMNAME_EN DT TEAMNAME_EN HPROB AM APROB FT
    324813 31/8 / 2012 DEN HAAG GRONINGEN 1.90 3.30 3.10 2
    324823 31/8 / 2012 MAINZ GREUTHER FÜRTH 1.75 3.25 3.65 2
    324805 31/8 / 2012 GAZELEC DIJON 1.60 3.15 4.75 1
    324810 31/8 / 2012 ÖREBRO DJURGÅRDEN 2.80 3.25 2 2.05
    324795 31/8 / 2012 FC KÖLN COTTBUS 1.85 3.20 3.35 2
    324837 31/8 / 2012 PORTLAND WOOD COLORADO RAPIDS 2,00 3.20 2.95 1
    324828 31/8 / 2012 DROGHEDA UNITED, DUNDALK 1.45 3.65 5.25 1
    324827 31/8 / 2012 CORK CITY SHAMROCK ROVERS 3,30 3,80 1.70 2
    324833 31/8 / 2012 BARUERI ASA 2.45 3.20 1-2.30
    324798 31/8 / 2012 GENÇLERBIRLIGI ORDUSPOR'A 2.00 3,10 X 3.00
    324814 31/8 / 2012 ALMERE CITY FC OSS 1,80 3,50 3,20 2
    324830 31/8 / 2012 CRICIÚMA BRAGANTINO 1.25 4.35 1 8.00
    324820 31/8 / 2012 VOLENDAM FC EINDHOVEN 1.80 3.25 3.45 1
    324818 31/8 / 2012 MVV MAASTRICHT TELSTAR 1.40 4.00 X 5.25
    324819 31/8 / 2012 DORDRECHT VEENDAM 1.80 3.25 3.45 1
    324834 31/8 / 2012 CEARÁ GUARATINGUETÁ 1.40 3.85 X 5.50

    If this table consists of
    dates
    teams (hometeam, awayteam)
    numbers for homewin, shoot, awaywin probability
    and the final result as 1, X, 2

    What I want is a sql query that returns to me for each hometeam, awayteam and (if possible in a single line)
    all documents of the hometeam which had the same number of prior probability. For example:
    CEARÁ (last line), I would like to the sql to show me all the records of CEARA who had _1.40 3.85 or 5.50_ in each of the three issues of probability, BUT the problem is that I do want separate lines... I can do so far is to calculate a sum of House probability, probability of drawing, close probability for each team but the same records are calculated again in each game of probability!

    This means if CEARÁ has 1.40-3.85-5.50 in the past it will return me this line only once, and not 3 times (one for each set of probability)

    I hope that I've done my duty,
    Thank you for your time and lights
    N. Saridakis

    Is that what you are looking for:

    select hometeam,
           awayteam,
           hw,
           hd,
           hl
    from  (select hometeam,
                  awayteam,
                  ft,
                  SUM(CASE ft
                      WHEN '1' THEN 1
                      ELSE 0
                      END) OVER (PARTITION BY hometeam) hw,
                  SUM(CASE ft
                      WHEN 'X' THEN 1
                      ELSE 0
                      END) OVER (PARTITION BY hometeam) hd,
                  SUM(CASE ft
                      WHEN '2' THEN 1
                      ELSE 0
                      END) OVER (PARTITION BY hometeam) hl
           from   plays)
    where ft is null
    
  • request to help build a vi to acquire a signal of pc6251 for the acquisition of data and perform fft it can u people please help me? Thanks in advance

    Hi all... I learn LabVIEW since few days.i want to acquire a signal of pc6251 of acquisition of data and perform fft it can u people please help me? Thanks in advance

    If you do only use LabVIEW for a few days, you should get familiar with it first by looking at some of the resources available here. After that, you can watch heredata acquisition.

    After reviewing these documents, you can post back with any specific questions.

  • Footage looks different in SpeedGrade and when rendering

    Hello

    I'm having some trouble to know what my file look like really.

    Is there still a bug of QuickTime that cause QuickTime show an offbeat image gamma or otherwise-screwy?

    5dMkII h.264 .mov files

    The same file in QuickTime and VLC seems different. VLC version is darker and more red.

    This file in SG seems even darker and a little more red.

    Rendering outside of SpeedGrade at ProRes422 (automatic setting of the colors on the SG switch) happens almost SpeedGrade display, but a few points more red and a little darker.

    Made from SpeedGrade at ProRes422 (automatic color adjustment turn off in SG) much lighter and paler than SpeedGrade display.

    Same results with ProRes444.

    Why these look different?

    Later MacPro Tower

    Latest OS X

    64 GB OF RAM

    AMD over-pants D700 6144 MB

    2 x LaCie 321, calibrated monitors with Spyder3 Elite

    QuickTime 7 Pro or QuickTime Player comes with OS

    All the read files on the same screen

    Thanks in advance for any help.

    In general, it depends.

    You are not user & manager of any other computer in the world... even if sometimes they try and make you so. The best anyone can do is run a calibrated ' shop' and know that you deliver good technical content. Test it on others systems calibrated and more monitors broadcast if such are available somewhere you know. For clients with specific needs, TEST. Send a test above and let them check... for the most TV use is crucial. To say adds on the screens of movie theater shows, arrange to take a sample before you 'open' for the day and played on their equipment on the screen... see what he looks like, adjust & retest if necessary.

    For web use... it is a total crapshoot to off the mark. The best you can do is once again, see that your system is calibrated as accurately as possible. Set preferences for video players on your computer to use the calibration of your system rather than their interior, which will ALWAYS do something weird to the signals. But not only unpredictable... odd to a computer. If your system is fully calibrated, your work on the web if all goes well on average pretty decent.

    For web-delivery, even when... initial customers to check that they are happy with the results that you give them. If they want on their computer, it is more blue and... you know it means it'll really be BLUE on many machines... perhaps by showing them on your laptop as it looks good as-is on a different system or some sort of instant customer education will have to arrive. I heard a lot of complaints that the customer required someone do something too dark... and then complained to them because they got from the comments of others that the material was too dark. Love it, huh? Customer demanded that they change more dark even if they say it would be too dark for most computers... and then groused to them that it was too dark. Right. Oh frabjous joy.

    More in the video lounge here and on a few other sites... the discussions on stupid customer requests sometimes were a riot, and sometimes something almost cry on. As a portraitist 30 stills photographer, we had the same thing sometimes clients... apply to all simply print their pictures GREEN or something. More of who we met, some... didn't us. There is an interesting variety of brain and eyes on the planet...

    My experience is that just do my best, it looks pretty darn good on TVs and computers to my client. Some go one-way or another a bit, but in general, it works fine. And check if you have a setting in the system controls or controls Qt & VLC for color managed system.

    Neil

  • Best approach for the transmission of data and images

    We you write an app that will allow the user to take a picture of a document and enter a few bits of information about the document and then send it to our server. It is a mobile extension to a larger system of document management to back office we develop in-house so the intention of this BB app is not not to distribute to the masses.

    What is the most practical approach to transmit data and images captured on our server?

    -FTP - fooled with it some and a pain

    -WebService - did not attempt

    -Send an email with the picture attached - seems to work very well

    Is there another approach, should I consider?

    If you do not already things that communicates to the Server backend, e-mail is probably the easiest way.  Crosses all the issues of the segmentation of the image that you would have to do with the Web Service or FTP.

  • Only one Integrator for export csv to table and update the table?

    Hello
    I have a requirement where I need to create a single Integrator for export data in the CSV file into a custom oracle table and also use the same Integrator to download and update the custom table data. Is it possible to do this in a single Integrator.

    Thank you
    Kishore

    Yes you can do it.

    You must create a type of UPDATE metadata Integrator.

    First time:

    Custom table is empty.

    WEB ADI will download a blank Excel sheet. Copy the data from the CSV file and paste this Excel.Then download this file that will update the Integrator.

    A sample example is as follows:

    web_adi_pkg.main (param_1, param_2,... param_n)
    download_data;
    upload_data;

    Download data-> select query to download the data (select * from custom_table)
    Download the data-> insert into custom_table where NOT EXISTS (select 1 from custom_table where primary_key = primary_key_col_from_csv)
    update of custom_table where there are (select 1 from custom_table where primary_key = primary_key_col_from_csv)

    Please try above logic.

  • SQL Loader for single registration repetitive data reading

    Hello

    I have my incoming data as follows:
    NAME, ID, Date1, Date2, Date3 Date4
    AST1_IDX1_EXCH_SERIES1, TD234512, (20070314,130000,112.5), (20070313,120000,112), (20070312,130000,116), (20070309,130000,115)
    AST2_IDX2_EXCH_SERIES2, TD234524, (20070314,130000,123.5), (20070313,120000,120.9), (20070312,130000,126.1), (20070309,130000,135.2)

    I have my DB such as:
    Create table (FACTOR)
    NAME VARCHAR2 (50).
    ID VARCHAR2 (20).
    DATE OF CLOSE_DATE,
    NUMBER OF CLOSE_TIME
    CLOSE_VALUE NUMBER (20,10)
    )

    I want to load the data so that the first two values go in columns (NAME, ID) and the other triplets go to the fields (CLOSE_DATE, CLOSE_TIME, CLOSE_VALUE) several times depending on the number of those present triplets. Is it possible to do so using SQL Loader?

    I'm trying to load this file (containing approximately 40000 these records) using SQL loader and tried options using CONTINUEIF, OBJECT of COLUMN, etc. but nothing works for me. Guidance in this regard will be highly appreciated.

    Thank you
    POOJA
  • R12 Payables: SQL query for the list of invoices and their status of Validation

    Hi all

    I am looking for a SQL query that gives me the list of all invoices of AP and their Validation status.

    Thank you
    Anil

    Select invoice_id, invoice_num, invoice_amount, invoice_currency_code, AP_INVOICES_V approval_status_lookup_code;

    Prasanna-

  • How can I get details about my windows license key or the pc that I use it, for example the purchase date and the name of the seller. ?

    I had the laptop as a gift. The update they ask me for the date I bought the laptop and the seller. These two details, I don't know. Is there anyway that I can get these details, if I have the windows license key and product key.

    Press Windows key + R

    Type: cmd

    Press enter

    At the command prompt, type:

    SystemInfo

    Press enter on your keyboard

    This should give you all the details you need.

  • Page looks different in preview and browser

    I use the Acordion Widget on the left side of my page and left a video from a third party on the right side.

    When I click on 'PREVIEW', I see the page appear in the top image. When I click on"PREVIEW in BROWSER", it appears as in the image background, which, by the way, is the way I designed it to look. Is there a reason for this discrepancy and who should I trust? I'm not ready for release yet, so, how do I check in a real world environment?

    Muse problem.jpg

    I lose the top and bottom of the images 'bookend' around the Acordion Widget as well as the button at the bottom. And the video window and the text are spread out to the wide to the right.

    Help, please.

    Louis

    I changed the video I decided to show in the page and when I checked the PREVIEW, it displayed correctly. I don't know if the embed code had nothing to do with the problem or not, but it seems to be fixed. Thanks for your help.

    Louis

  • How to make it so that the DAY OF THE WEEK looks with the date and time?

    I had the day of the week, introduce yourself on XP, but it is a feature that they took off with Windows 7?  Does anyone know how to make it stay there permanently?

    Thank you

    Time, day and date will appear on the taskbar if you double its height. Unlock the taskbar and drag it up a notch with the mouse cursor...

  • Identify the weekend and the days of the week a date and update the empty column

    Hi, I look at previous posts that are similar to my question, but nothing helps.

    I have a column called incident_date that is in this format and comes from the Nov_Final table
    01-JUL-2009 20.10
    04-NOV-2009 17.00
    16-DEC-2009 16.00
    In Nov_Final, I created a column called weekend

    What I want to do is to perform an update, something like this:
    Update Nov_Final
    
    SET Weekend=(case when Incident_date ='WEEKEND' THEN 'Y' ELSE 'N' END)
    Banner:
    Oracle Database 11 g Release 11.2.0.2.0 - 64 bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    "CORE 11.2.0.2.0 Production."
    AMT for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    Weekend would be Saturday or Sunday. 
    In short I need to find out if the incident_date falls on a weekend and if it does update the weekend column as 'Y' else 'N' if it's not.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

    You can use TO_CHAR function with a format mask as "fmDAY" to your needs:

    with t_data
    as
    (
    select sysdate + level as col1 from dual connect by level <= 7
    )
    SELECT
        col1,
        TO_CHAR(col1,'fmDAY') col_day,
        CASE
            WHEN TO_CHAR(col1,'fmDAY') IN ('SATURDAY','SUNDAY')
            THEN 'Y'
            ELSE 'N'
        END AS weekend_ind
    FROM
        t_data;
    
    COL1                      COL_DAY                     WEEKEND_IND
    ------------------------- --------------------------- -----------
    08-NOV-11 07:54:12        TUESDAY                     N
    09-NOV-11 07:54:12        WEDNESDAY                   N
    10-NOV-11 07:54:12        THURSDAY                    N
    11-NOV-11 07:54:12        FRIDAY                      N
    12-NOV-11 07:54:12        SATURDAY                    Y
    13-NOV-11 07:54:12        SUNDAY                      Y
    14-NOV-11 07:54:12        MONDAY                      N           
    
    7 rows selected
    
  • Pavilion 15-ab057nr: How can I change for one SSD HARD drive and update my RAM?

    Hi, I would like to change the hard drive of my computer (Pavilion 15-ab057nr) for one ssd and also add another module of RAM. The problem is that I've never opened a laptop before, and I don't know where to start, or what should I do after I opened the computer. I don't know if anyone could help me by giving me a guide on how to perform these upgrades, every little detail would be useful. Thank you.

    Hi @IYMF,

    Thank you for visiting the HP Forums! A place where you can find solutions for your problems with the help of the community!

    I stumbled upon your post on the HP Pavilion Notebook - 15-ab057nr and tried to help you! I looked in your question about upgrading the internal hardware. I understand that you are looking to upgrade your hard drive to a Solid State Drive, as well as adding another module of RAM.

    Here is a link to your Service Manual. You can find the specifications for compatible discs on page 49. Please note that this laptop model doesn't support that type hybrid Solid State Drives.

    Maintenance manual, page 55, there will be a list of the size of RAM supported, but also a guide on the replacement of the RAM. Up to 16 GB of RAM may be supported in a 8GB x 2 configuration.

    On pages 46 to 50 of your maintenance manual, you will find instructions on how to remove the rear panel of the laptop, as well as, instructions on the removal of the original hard drive.

    I also found this Vidéo Guide giving visual aid on the replacement of the hard disk. The model of laptop in the video is not exactly the same as the model that you have, but it can provide assistance, however.

    Please let me know how it goes.

    You can say thanks for trying to help by clicking on the Thumbs Up below! .

    Thank you.

  • XY graph, initialize multiple groups of data and update a single set of data

    Hello

    I have developed a VI to control the coordinates XY of a platform using two engines. A version a little kwicks xy plotter.

    The detail that I could use help in is the following:

    1. I have 469 (or 400 ~ ish, there are two modes) of the discrete points to be initialized/connected to a XY graph such that a cursor on the XY graph can break discrete points. It's well done.

    2. I have to keep track of the current position of XY. It's also well done

    3. I have to keep track of the former x - y positions, where I was able to extract the data correctly. This is done by a switch.

    4. almost all VI has an a giant loop, although sequenced by 0 of the past a structure of case to another until you reach the final "global dummy.

    Now, signals which are processed to the engine through a USB digital signal generator, I think not that the specifications are necessary. Essentially I needed bitmask each individual movement, so the 'engine of movement' part is embedded in the giant of while loop. This means that whenever I have add a new feature to my VI, engine movements slow down, each time that the operating system on the computer decides to run an automatic update, drivers slow down. I do not have the luxury of multi-threading or a microcontroller immediately.

    At this point, my engines are terribly slowly, and I'll try to find a way to make them run faster. I am sure that the bottleneck is actually treatment for my data XY graph.

    My XY graph manages 3 sets of data,

    a. 469 discrete points (table 2 x 469) or 400 ~ ish discrete points (2 x 400 ~ table)

    position current c. (x, y)

    d. "rescued/captured" (2xincreasing up to table 469) positions

    everything has, b, c are inside the while loop. A switch determines the 'a' is used.

    the berries are grouped and then sent in the graph xy inside the while loop. I need the graph to be interactive to the cursor and data.

    Now, is that I wish to run things.

    1. selection from either a or b is responsible to the xy chart (by a switch).

    2 c is updated constantly.

    3 d is updated whenever the data was captured (by a switch).

    Basically, I need a and or b to run only ONCE at initialization of the (and when I decide to swtich from one to the other) and remains constant. In the same way D updates only when a switch has been pressed.

    I failed to find resources too tracing data to the xygraph, and drawing a live data on top selectively.

    I have attached an outdated version of my front as reference. I would like suggestions. Thank you in advance.

    -JLS


  • Problem with the date and update form (show 1970-01-01)

    Hi, I have an update form (php/mysql) with several date entry field. When my date is 000-00-00 I show 1970-01-01. Why?

    This is the code:

    label for = "data_chiusura" > < strong > data chiusura < facilities > < / label >

    < input type = "text" name = "Data_chiusura" value = "<?" PHP echo $string = $row_Recordset1 ["data_chiusura"];

    If ($string = ' 0000-00-00') {}

    $string = ";

    } else {}

    $string = date ("d-m-Y", strtotime ($string));

    } ; ? ">" id = "Data_chiusura" >

    Thank you

    k

    Try this-

    "id ="Data_chiusura">"

Maybe you are looking for