Write a uniqueIdentifier in SQL DB

Hi, I have a SQL database with multiple tables. The tables are linked each other by ID. The type of the ID is of type UNIQUEIDENTIFIER. I should read the ID of the first array and write the same ID in the second table. Ando so now for each table.

I use LV Database Toolkit and I already did the reading of the ID: 5240A2A6-9453-E011-80CD-406186EDCDB2. In BT, the ID is a Variant, but when I try to write a different value in the 2nd table is written: 02802108-0000-0100-0006-008400010001.

What type of data is the uniqueidentifier in LV? What is a Variant?

Thanks for the support.

Hi, I solved the problem by implementing a StoredProcedure in SQL database. I call the stored procedure in labview and I pass the uniqueidentifier as string.

Thank you Alex.

Tags: NI Software

Similar Questions

  • Need help to write to Oracle and SQL Server in the Oracle triggering

    We have a third which feeds data for us. Their client application feeds directly to some source tables in our Oracle database 10g. We have triggers on those tables that sort and treat lines as they come.

    We have a new operation and try to write some of these incoming data now to a SQL Server database through heterogeneous services - essentially the same exact data in two databases. I have a related database that works very well for the selection, but I've never tried to write Oracle PL/SQL to write in a DB SQL Server 2008. My first attempt was met with the following error: "ORA-02047: impossible to join the current distributed transaction.

    I found another thread where they say that the only way to do it is by using a stand-alone transaction, but they do not give an example. Here is the section of relaxation that I use:
      select to_char(new_date,'MM-DD-YYYY') into sql_txt from dual;
      insert into mancamp_location@sqlweb
           ("UnitID", "ManCampID", "Lat", "Long", "UpdateDT", "VehSpeed", "VehDirection", "Landmark")
        values (v_truck, f_unit, f_lat, f_long, sql_txt, f_spd, f_dir, f_ldmk);
    Can someone point me to a way to accomplish this simple insertion?

    An example of a standalone trigger is:

    Suppose you have a table in Oracle:

    CREATE TABLE emp_sal
    (
    EMPNO NUMBER 4,
    SAL NUMBER (7.2));

    and a similar table in a SQL server:
    SQL Server:

    CREATE TABLE emp_sal
    (
    EMPNO NUMERIC (4).
    SAL NUMERIC (7.2));

    Then, you can create an insert trigger that replicates the data:
    CREATE OR REPLACE TRIGGER dg4odbc_repl AFTER INSERT ON emp_sal
    FOR EACH LINE
    DECLARE
    PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
    INSERT INTO 'emp_sal"@MSODBCSQLSERVER_DG4ODBC_EMGTW_1123_DB '.
    VALUES (: new.empno,: new.sal);
    COMMIT;
    END;
    /

    -Note the validation, otherwise risk of ORA-6519

    When you now insert a record into the Oracle database:
    insert into emp_sal values (1234, '1200,89');
    the trigger is activated and inserts the record in SQL Server:
    Select * from 'emp_sal"@MSODBCSQLSERVER_DG4ODBC_EMGTW_1123_DB;
    EMPNO, SAL
    ----- -------
    1234 1200.89

    It works fine when you post data insert, but as soon as restore you the insert only data Oracle will be cancelled - data will remain as long as the independent transaction dedicated to its SQL Server insert:

    insert into emp_sal values (1384, '1200,89');
    Rollback;
    Select * from emp_sal;
    EMPNO, SAL
    ----- -------
    1234 1200.89

    Select * from 'emp_sal"@MSODBCSQLSERVER_DG4ODBC_EMGTW_1123_DB;
    EMPNO, SAL
    ----- -------
    1234 1200.89
    1384 1200.89

    So I strongly recommend to use the DG4MSQL gateway which is able to participate in distributed transactions and allows validation/restore transactions.

    DG4ODBC lie on OTN (http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html-online check out the "See all" link for your favorite platform), cloud of delivery of software Oracle (https://edelivery.oracle.com/) or "My Oracle Support". My Oracle support welcomes the latest version 11.2.0.3. In My Oracle Support goto patches and updates, then search for 11.2.0.3 data set Patch 10404530patch: 11.2.0.3.0 PATCH SET for ORACLE database SERVER, choose your preferred platform and see the Readme which CD contains the gateway software.

    Published by: kgronau on April 24, 2012 08:44

  • How to write comments in PL/SQL executed inside the app engine.

    Hi all

    Is it possible to write comments inside PL/SQL that is executed using %Execute(/) commnad in Application Engine? I tried "/ * /" to write comments, but the program out errors.

    You are right. I thought that I said that, but now that I look at, I have not. I'm sorry.

  • Way EASIER to write this in a sql or plsql

    I have a select as below where his output can be one line or several lines or lines nil. Select can bring nulls, R, C, O

    (A) in the case of the lines suck, I want ln_status to be «#»

    (B) in case if there is at least one row with O, ln_status should be O

    (C) if the criteria A and B is not filled, in case if there is at least one firm, ln_status has to be C

    (D) if only a single record with R, ln_Status must be 'o'

    is it possible to write more simply without question several times or using plsql. Thank you

    Select the status INTO ln_status

    from TableA

    where col1 = < col1 >

    Frank addresses the point that you wrote that there could be no line and also status is null as a possible outcome.

    Max (Status) has the null value distinguishes but count (*) = 0, because it returns a number greater than 0 in the case of rows returned with the State is set to null.

  • SQL help on records in the range of dates in a month

    Hello

    I have a simple requirement on Sql.

    I have two records in the table of the absence-

    Absence1 January 6, 2015 at 10 January 2015, 5 days

    Absecne2 January 21, 2015 to 31 January 2015, 11 days

    I need to write a Sql to get all the records separate date, as under-

    January 5, 2015, 1 January 2015 days 5 days

    January 6, 2015 at 10 January 2015 5 days of absence

    January 20, 2015, 11 January 2015 10 days working days

    January 21, 2015 to 31 January 2015, 11 days of absence

    Could be for any month, I just have absences stored in a table and will pass the dates of beginning and end of the month.

    I can write this in Pl/Sql, but wanted to see if it's possible in Sql.

    TIA

    Vignesh

    Here's a way to do it.

    with the days as

    (select mstart + lv mdate

    Of

    (select mstart to_date('201501','yyyymm')-1, lv)

    of the double

    cross join

    (select level lv

    of the double

    connect by level<=>

    )

    )

    )

    abs as

    (select 1 anum, to_date ('20150106', 'YYYYMMDD') date_from, to_date ('20150110', 'YYYYMMDD') date_to, 5 days_abs of all double union)

    Select option 2, 5 days_abs of the double to_date ('20150121', 'YYYYMMDD') from_date, to_date ('20150131', 'YYYYMMDD')

    )

    --

    Select min (mdate) date_from, max (mdate) date_to, max (day_type) day_type

    Of

    (select mdate, where anum is null then 'working days' else 'Absence' end day_type, max (rn) on rn (order by mdate))

    Of

    (select mdate, anum, case when row_number() over (order by mdate) = 1 or nvl(anum,0) <> (nvl(anum,0)) (order of mdate) lag then row_number() (any order by mdate) end rn)

    Of

    (select mdate, anum)

    days d

    join left abs one on d.mdate between a.date_from and a.date_to

    )

    )

    )

    Group by rn

    date_from order;

  • What is sql injection?

    Hi all

    I Googled it but couldn't make sure answer. Please someone help me to know about The SQL INJECTION with good example.

    Thank you very much

    Same Questions a few days before

    See this too

    Example of SQL Injection

    I recommend you to study how to write the code evidence sql injection

    http://www.Oracle.com/technetwork/database/features/PLSQL/overview/how-to-write-injection-proof-PLSQL-1-129572.PDF

  • SQL query for the mapping of a set of prizes to a group of classrooms

    Hi all

    I use Oracle database 11g Release 2.

    I have the following data set:

    Classrooms
    ClassId ClassName ability group
    ------ ----------------------------------------------      --------------     -----------
    Babbage/software Engg Lab 1 24 1
    Basement 2 - block PG 63 1
    3 1 56 1 class
    Class 4 1 24 10
    Class 5 1 24 11
    Class 6 1 35 12
    7 13 42 1 class
    8 14 42 1 class
    9 15 42 1 class
    10 2 35 1 class
    11 3 35 1 class
    12 4 35 1 classroom
    13 5 35 1 class
    14 6 25 1 class
    15 7 25 1 class
    16 1 24 8 class
    17 9 24 1 class
    18 control Sys Lab 1 24
    19 dig & Embd Sys Lab 20 1
    20 PSD & Comm 20 1 Lab
    21 electromechanical system Lab 28 1
    Farabi 22/Web Tech Lab 1 36
    23 gen purpose Lab 40 1
    Shirazi/24dB Tech Lab 1 36
    ADV 25 elect Lab 30 2
    26 16 42 2 class
    27 17 49 2 class
    28 18 56 2 class
    29 19 42 2 class
    30 20 49 2 class
    Class 31 21 35 3
    32 22 35 3 class
    33 20 3 MDA lab

    DegreeBatches
    BatchId BatchName force
    ---------------     ----------------------- --------------
    1 BIT - 11 79
    2 BIT - 12 28
    3 BS (CS)-1 35
    4 BS (CS) 78-2
    5 BE (SE)-1 69
    6. BE (SE) 84-2
    7 BE (SE) 64-3
    8 84 BYTČA-7
    9 43 BYTČA-8
    BEE-1 10, 112
    11 151 BEE-2
    BEE-3 12, 157
    13 BEE-4 157

    I want to map a combination of batch of degree for a class rooms group of such distance that they make full use of the maximum capacity of the class rooms within a group (ideally), or as close to this as possible. Can it be done with a SQL query?

    Any response will be appreciated.

    The SQL Scripts to generate the required tables and populate data is less to:
    CREATE TABLE classrooms (ClassId NUMBER, ClassName VARCHAR2 (50), capacity NUMBER, group NUMBER);
    INSERT INTO the classrooms of the VALUES (1, "Babbage/software Engg Lab', 24, 1");
    INSERT INTO the classrooms of the VALUES (2, 'basement - PG block', 63, 1);
    INSERT INTO the classrooms of the VALUES (3, '1 class room', 56, 1);
    INSERT INTO the classrooms of the VALUES (4, '10 class room', 24, 1);
    INSERT INTO the classrooms of the VALUES (5, '11 class room', 24, 1);
    INSERT INTO the classrooms of the VALUES (6, 'class room 12', 35, 1);
    INSERT INTO the classrooms of the VALUES (7, 'class room 13', 42, 1);
    INSERT INTO the classrooms of the VALUES (8, 'class room 14', 42, 1);
    INSERT INTO the classrooms of the VALUES (9, '15 'class, 42, 1);
    INSERT INTO the classrooms of the VALUES (10, 'class 2', 35, 1);
    INSERT INTO the classrooms of the VALUES (11, 'class room 3', 35, 1);
    INSERT INTO the classrooms of the VALUES (12, 'class room 4', 35, 1);
    INSERT INTO the classrooms of the VALUES (13, 'class room 5', 35, 1);
    INSERT INTO the classrooms of the VALUES (14, 'class room 6', 25, 1);
    INSERT INTO the classrooms of the VALUES (15, '7 class room', 25, 1);
    INSERT INTO the classrooms of the VALUES (16, 'class Room 8', 24, 1);
    INSERT INTO the classrooms of the VALUES (17, 'class room 9', 24, 1);
    INSERT INTO the classrooms of the VALUES (18, 'Control Sys Lab', 24, 1);
    INSERT INTO the classrooms of the VALUES (19, 'Dig & Embd Sys Lab', 20, 1);
    INSERT INTO the classrooms of the VALUES (20, 'DSP & Comm Lab', 20, 1);
    INSERT INTO the classrooms of the VALUES (21, 'system ELECTROMECHANICAL Lab', 28, 1);
    INSERT INTO the classrooms of the VALUES (22, ' Farabi/Web Tech Lab', 36, 1);
    INSERT INTO the classrooms of the VALUES (23, 'Gen purpose Lab', 40, 1);
    INSERT INTO the classrooms of the VALUES (24, ' Shirazi/DB Tech Lab', 36, 1);
    INSERT INTO the classrooms of the VALUES (25, 'Elected Adv Lab', 30, 2);
    INSERT INTO the classrooms of the VALUES (26, 'class room 16', 42, 2);
    INSERT INTO the classrooms of the VALUES (27, 'class room 17', 49, 2);
    INSERT INTO the classrooms of the VALUES (28, '18 'class, 56, 2);
    INSERT INTO the classrooms of the VALUES (29, '19 'class, 42, 2);
    INSERT INTO the classrooms of the VALUES (30, 'class room 20', 49, 2);
    INSERT INTO the classrooms of the VALUES (31, 'class room 21', 35, 3);
    INSERT INTO the classrooms of the VALUES (32, 'room 22', 35, 3);
    INSERT INTO the classrooms of the VALUES (33, 'MDA Lab', 20, 3);

    CREATE TABLE DegreeBatches (BatchId NUMBER, BatchName VARCHAR2 (50), membership NUMBER);
    INSERT INTO DegreeBatches VALUES(1,'BIT-11',79);
    INSERT INTO DegreeBatches VALUES(2,'BIT-12',28);
    INSERT INTO DegreeBatches VALUES (3, 'BS (CS) - 1', 35);
    INSERT INTO DegreeBatches VALUES (4, 'BS (CS) - 2', 78);
    INSERT INTO DegreeBatches VALUES (5,'BE (SE) - 1', 69);
    INSERT INTO DegreeBatches VALUES (6,'BE (SE) - 2', 84);
    INSERT INTO DegreeBatches VALUES (7,'BE (SE) - 3', 64);
    INSERT INTO DegreeBatches VALUES(8,'BICSE-7',84);
    INSERT INTO DegreeBatches VALUES(9,'BICSE-8',43);
    INSERT INTO DegreeBatches VALUES(10,'BEE-1',112);
    INSERT INTO DegreeBatches VALUES(11,'BEE-2',151);
    INSERT INTO DegreeBatches VALUES(12,'BEE-3',157);
    INSERT INTO DegreeBatches VALUES(13,'BEE-4',157);

    Best regards
    Bilal

    Published by: Bilal on December 27, 2012 09:52

    Published by: Bilal on December 27, 2012 10:07

    Bilal, thanks for the nice problem! Another possibility to double check is to write a small PL/SQL function that returns 1 if a duplicate id is found, then equate to 0: "NUMBER of RETURN of Duplicate_Token_Found (p_str_main in VARCHAR2, p_str_trial VARCHAR2). It should analyze the second string and could use p_str_main LIKE '%', | l_id | ', %' for each id. In any case, the query complete (without that) is given below:

    Solution with names
    SQL> WITH rsf_itm (con_id, max_weight, nxt_id, lev, tot_weight, tot_profit, path, root_id, lev_1_id) AS (
      2  SELECT c.id,
      3         c.max_weight,
      4         i.id,
      5         0,
      6         i.item_weight,
      7         i.item_profit,
      8         ',' || i.id || ',',
      9         i.id,
     10         0
     11    FROM items i
     12   CROSS JOIN containers c
     13   UNION ALL
     14  SELECT r.con_id,
     15         r.max_weight,
     16         i.id,
     17         r.lev + 1,
     18         r.tot_weight + i.item_weight,
     19         r.tot_profit + i.item_profit,
     20         r.path || i.id || ',',
     21         r.root_id,
     22         CASE WHEN r.lev = 0 THEN i.id ELSE r.nxt_id END
     23    FROM rsf_itm r
     24    JOIN items i
     25      ON i.id > r.nxt_id
     26     AND r.tot_weight + i.item_weight <= r.max_weight
     27   ORDER BY 1, 2
     28  ) SEARCH DEPTH FIRST BY nxt_id SET line_no
     29  , rsf_con (nxt_con_id, nxt_line_no, con_path, itm_path, tot_weight, tot_profit, lev) AS (
     30  SELECT con_id,
     31         line_no,
     32         To_Char(con_id),
     33         ':' || con_id || '-' || (lev + 1) || ':' || path,
     34         tot_weight,
     35         tot_profit,
     36         0
     37    FROM rsf_itm
     38   UNION ALL
     39  SELECT r_i.con_id,
     40         r_i.line_no,
     41         r_c.con_path || ',' || r_i.con_id,
     42         r_c.itm_path ||  ':' || r_i.con_id || '-' || (r_i.lev + 1) || ':' || r_i.path,
     43         r_c.tot_weight + r_i.tot_weight,
     44         r_c.tot_profit + r_i.tot_profit,
     45         r_c.lev + 1
     46    FROM rsf_con r_c
     47    JOIN rsf_itm r_i
     48      ON r_i.con_id > r_c.nxt_con_id
     49   WHERE r_c.itm_path NOT LIKE '%,' || r_i.root_id || ',%'
     50     AND r_c.itm_path NOT LIKE '%,' || r_i.lev_1_id || ',%'
     51     AND r_c.itm_path NOT LIKE '%,' || r_i.nxt_id || ',%'
     52  )
     53  , paths_ranked AS (
     54  SELECT itm_path || ':' itm_path, tot_weight, tot_profit, lev + 1 n_cons,
     55         Rank () OVER (ORDER BY tot_profit DESC) rnk,
     56         Row_Number () OVER (ORDER BY tot_profit DESC) sol_id
     57    FROM rsf_con
     58  ), best_paths AS (
     59  SELECT itm_path, tot_weight, tot_profit, n_cons, sol_id
     60    FROM paths_ranked
     61   WHERE rnk = 1
     62  ), row_gen AS (
     63  SELECT LEVEL lev
     64    FROM DUAL
     65  CONNECT BY LEVEL <= (SELECT Count(*) FROM items)
     66  ), con_v AS (
     67  SELECT  b.itm_path, r.lev con_ind, b.sol_id, b.tot_weight, b.tot_profit,
     68          Substr (b.itm_path, Instr (b.itm_path, ':', 1, 2*r.lev - 1) + 1,
     69            Instr (b.itm_path, ':', 1, 2*r.lev) - Instr (b.itm_path, ':', 1, 2*r.lev - 1) - 1)
     70             con_nit_id,
     71          Substr (b.itm_path, Instr (b.itm_path, ':', 1, 2*r.lev) + 1,
     72            Instr (b.itm_path, ':', 1, 2*r.lev + 1) - Instr (b.itm_path, ':', 1, 2*r.lev) - 1)
     73             itm_str
     74    FROM best_paths b
     75    JOIN row_gen r
     76      ON r.lev <= b.n_cons
     77  ), con_split AS (
     78  SELECT itm_path, con_ind, sol_id, tot_weight, tot_profit,
     79         Substr (con_nit_id, 1, Instr (con_nit_id, '-', 1) - 1) con_id,
     80         Substr (con_nit_id, Instr (con_nit_id, '-', 1) + 1) n_items,
     81         itm_str
     82    FROM con_v
     83  ), itm_v AS (
     84  SELECT  c.itm_path, c.con_ind, c.sol_id, c.con_id, c.tot_weight, c.tot_profit,
     85          Substr (c.itm_str, Instr (c.itm_str, ',', 1, r.lev) + 1,
     86            Instr (c.itm_str, ',', 1, r.lev + 1) - Instr (c.itm_str, ',', 1, r.lev) - 1)
     87             itm_id
     88    FROM con_split c
     89    JOIN row_gen r
     90      ON r.lev <= c.n_items
     91  )
     92  SELECT v.sol_id,
     93         v.tot_weight s_wt, v.tot_profit s_pr, c.id c_id, c.name c_name, c.max_weight m_wt,
     94         Sum (i.item_weight) OVER (PARTITION BY v.sol_id, c.id) c_wt,
     95         i.id i_id, i.name i_name, i.item_weight i_wt, i.item_profit i_pr
     96    FROM itm_v v
     97    JOIN containers c
     98      ON c.id = To_Number (v.con_id)
     99    JOIN items i
    100      ON i.id = To_Number (v.itm_id)
    101   ORDER BY sol_id, con_id, itm_id
    102  /
    
        SOL_ID S_WT S_PR  C_ID C_NAME          M_WT C_WT  I_ID I_NAME     I_WT I_PR
    ---------- ---- ---- ----- --------------- ---- ---- ----- ---------- ---- ----
             1  255  255     1 SEECS UG Block   100  100     1 BIT-10       35   35
                                                             2 BIT-11       40   40
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   70     4 BSCS-3       40   40
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   85     3 BSCS-2       35   35
                                                             5 BEE-4        50   50
             2  255  255     1 SEECS UG Block   100   95     4 BSCS-3       40   40
                                                             6 BICSE-7      25   25
                                                             7 BESE-3       30   30
                             2 IAEC Building     70   70     1 BIT-10       35   35
                                                             3 BSCS-2       35   35
                             3 RIMMS Building    90   90     2 BIT-11       40   40
                                                             5 BEE-4        50   50
             3  255  255     1 SEECS UG Block   100  100     3 BSCS-2       35   35
                                                             4 BSCS-3       40   40
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   65     1 BIT-10       35   35
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   90     2 BIT-11       40   40
                                                             5 BEE-4        50   50
             4  255  255     1 SEECS UG Block   100  100     3 BSCS-2       35   35
                                                             4 BSCS-3       40   40
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   70     2 BIT-11       40   40
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   85     1 BIT-10       35   35
                                                             5 BEE-4        50   50
             5  255  255     1 SEECS UG Block   100   95     2 BIT-11       40   40
                                                             6 BICSE-7      25   25
                                                             7 BESE-3       30   30
                             2 IAEC Building     70   70     1 BIT-10       35   35
                                                             3 BSCS-2       35   35
                             3 RIMMS Building    90   90     4 BSCS-3       40   40
                                                             5 BEE-4        50   50
             6  255  255     1 SEECS UG Block   100  100     2 BIT-11       40   40
                                                             3 BSCS-2       35   35
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   65     1 BIT-10       35   35
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   90     4 BSCS-3       40   40
                                                             5 BEE-4        50   50
             7  255  255     1 SEECS UG Block   100  100     2 BIT-11       40   40
                                                             3 BSCS-2       35   35
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   70     4 BSCS-3       40   40
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   85     1 BIT-10       35   35
                                                             5 BEE-4        50   50
             8  255  255     1 SEECS UG Block   100  100     1 BIT-10       35   35
                                                             4 BSCS-3       40   40
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   70     2 BIT-11       40   40
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   85     3 BSCS-2       35   35
                                                             5 BEE-4        50   50
             9  255  255     1 SEECS UG Block   100  100     1 BIT-10       35   35
                                                             4 BSCS-3       40   40
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   65     3 BSCS-2       35   35
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   90     2 BIT-11       40   40
                                                             5 BEE-4        50   50
            10  255  255     1 SEECS UG Block   100  100     1 BIT-10       35   35
                                                             3 BSCS-2       35   35
                                                             7 BESE-3       30   30
                             2 IAEC Building     70   65     2 BIT-11       40   40
                                                             6 BICSE-7      25   25
                             3 RIMMS Building    90   90     4 BSCS-3       40   40
                                                             5 BEE-4        50   50
            11  255  255     1 SEECS UG Block   100  100     1 BIT-10       35   35
                                                             3 BSCS-2       35   35
                                                             7 BESE-3       30   30
                             2 IAEC Building     70   65     4 BSCS-3       40   40
                                                             6 BICSE-7      25   25
                             3 RIMMS Building    90   90     2 BIT-11       40   40
                                                             5 BEE-4        50   50
            12  255  255     1 SEECS UG Block   100   95     1 BIT-10       35   35
                                                             3 BSCS-2       35   35
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   70     2 BIT-11       40   40
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   90     4 BSCS-3       40   40
                                                             5 BEE-4        50   50
            13  255  255     1 SEECS UG Block   100   95     1 BIT-10       35   35
                                                             3 BSCS-2       35   35
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   70     4 BSCS-3       40   40
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   90     2 BIT-11       40   40
                                                             5 BEE-4        50   50
            14  255  255     1 SEECS UG Block   100  100     1 BIT-10       35   35
                                                             2 BIT-11       40   40
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   65     3 BSCS-2       35   35
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   90     4 BSCS-3       40   40
                                                             5 BEE-4        50   50
    
    98 rows selected.
    
    Elapsed: 00:00:01.42
    

    Published by: BrendanP on January 20, 2013 11:25
    I found the need to deduplicate regular expression:

    AND RegExp_Instr (r_c.itm_path | r_i.path, ',(\d+),.*?,\1,') = 0)

  • conditional statement in sql

    I'm using oracle 11.2.0.3.

    Is is possible to create the table only if it does not exist without the help of pl/sql.

    Hello

    spur230 wrote:
    I'm using oracle 11.2.0.3.

    Is is possible to create the table only if it does not exist without the help of pl/sql.

    Of course; This is in fact how CREATE TABLE always works. The CREATE TABLE statement will trigger an error and does not create anything, if a table with the same name already exists.

    If you are looking for a way to avoid triggering an error, I don't think that there is nothing in SQL.
    In SQL * Plus, you can place the CREATE TABLE statement in a script (let's call it create_table_2.sql) and write another script (create_table_0.sql) that does nothing, or maybe displays a message like "the Table already exists. In another script (create_table.sql), you can detect if the table exists and, depending on the results, call create_table_2 or create_table_0. I know, it's not pretty. See {message identifier: = 4367027} for a somewhat analogous situation.

  • Efficient SQL query

    Hello
    I need to write an efficient query because the query about 4 checks to be made on the lines before you return one row. Here's a sample script in query to create the table:

    CREATE TABLE "myschema". "" Complaint. "
    (
    "Compalint_ID" NUMBER (20.0).
    "ReplyTime' NUMBER,-it would be in a few minutes
    "CREATION_TIME' TIMESTAMP (6).
    NUMBER OF 'STATUS ',.
    "TYPE" NUMBER


    "CH_PKRTBL_Complaint_ID" ("Compalint_ID") PRIMARY KEY CONSTRAINT
    USING INDEX PCTFREE, INITRANS 10 2 MAXTRANS 255 CALCULATES STATISTICS
    STORAGE (INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645)
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 DEFAULT USER_TABLES)
    TABLESPACE 'myspace' ENABLE
    ) PCTFREE, PCTUSED, INITRANS 40 10 1 MAXTRANS 255 NOCOMPRESS SLAUGHTER
    STORAGE (INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645)
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 DEFAULT USER_TABLES)
    TABLESPACE "myspace";

    CREATE UNIQUE INDEX "myschema". "" CH_PKRTBL_Complaint_ID "WE"myschema ". "" Complaint "("Compalint_ID")
    PCTFREE, INITRANS 10 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE (INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645)
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 DEFAULT USER_TABLES)
    TABLESPACE "myspace";

    ALTER TABLE 'myschema. ' ' KEY PRIMARY complaint ' ADD CONSTRAINT 'CH_PKRTBL_TKTID' ('Compalint_ID')
    USING INDEX PCTFREE, INITRANS 10 2 MAXTRANS 255 CALCULATES STATISTICS
    STORAGE (INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645)
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 DEFAULT USER_TABLES)
    TABLESPACE 'myspace' ENABLE;



    I want to write an efficient pl/sql-sql query with the least time to return a row based on four following priorities/controls in the order specified below:

    1 return any line that contains a TYPE = 11

    2. If no line found for 1 check then
    calculate a difference in time for all of the lines as: time_difference (CREATION_TIME - ReplyTime)
    and back to the line that has more big differene in - ve (it is the line which expired first)

    3. If now the found line to check then the 2
    rank next where STATUS = 22

    4. If no line found to check then the 3
    calculate a difference in time for all of the lines as: time_difference (CREATION_TIME - ReplyTime)
    and back to the line that has a smaller difference in + ve (it is the line that will expire then)


    Kindly help me in this task.

    Thank you.

    @1
    I have the suggestion of Daniel while avoiding reserved words and now I see an error in copy/paste complaint_ casetypestatus when 22 then 22 end check3

    @2
    Bilal already you made in the right direction, anyway: as many others pointed out that you can not combine functions of the group the way which you intend to so using functions analytical has been the only issue keeping all lines and the calculation of the required amounts and charges in the query internal to combine in the outer query.
    complaint_type case when 11 11 then end keeps only the 11 complaint_type all other complaint_type null values
    Max (case complaint_type when 11 11 then complete) on check1_max (order by NULL rows between unbounded preceding and following unbounded), calculates the global maximum of the expression (in all the rows of the table)

    @3
    I used systimestamp - (creation_time + reply_time / 60/24) just to produce a positive or negative number as your time_difference (CREATION_TIME - ReplyTime) somehow confused me (timestamp less number gives timestamp if positive or negative is not an appropriate question) so the above expression as used so far is something you know how (re) set. Other required clarification/explanation at this stage.

    @4
    If the fraction of the second precision is not necessary using the date data type should be sufficient (environmental CAR you cannot rule out dealing with the events with the same timestamp) and what is the thrown error using systimestamp

    Concerning

    Etbin

  • Help for writing an extension for SQL Developer

    Hi all
    I want to write an extension for SQL using JDeveloper and Oracle Extension SDK developer and I have a few questions.
    (1) is there some imports I need to sign up for the use of certain classes for SQL Developer?
    (2) how can I do a new item from the context menu in the area of connections in the left?
    (3) is there an example for this, because I have read a few posts of Sue and Kris Rice, but I figured out how to make the extensions only for JDeveloper.

    Thanks in advance!

    SQL Developer Connection browser uses a different site from the JDeveloper Application browser id. The site id OK to use for a listener from context menu is "db_nav". If your listener statement would look like this:


         
              My.listener.Class
         

    Note that a listener can be registered on several sites (if, for example, you wanted as your listener to trigger for publishers, you can use "db_nav; Editor"for the site id.

    You can post questions on the development of SQL Developer extensions on the developer forum SQL: SQL Developer this forum is monitored by the staff of SQL Developer.

    -John McGinnis
    SQL development team

    Published by: John Mcginnis, August 22, 2011 11:34

    Published by: John Mcginnis, August 22, 2011 11:36

  • How to write conditional query?

    I have a use case-

    on the basis of the value of the entry, I need to run the query.

    for example

    Select * from employees where em em. empId =? and em.firstname =? and em.jobid =?
    Select * from employees where em em. empId =? and em.firstname =?

    I need to write a query that is used internally this time condition and return records

    Select * from employees where em
    If (EM.) JobID is nothing)
    {
    Select * from employees where em em. empId =? and em.firstname =?
    }
    on the other
    {
    Select * from employees where em em. empId =? and em.firstname =? and em.jobid =?
    }


    How could I write this problem in sql?

    Hello

    You can try the following:
    Select * from employees where em em. empId =? and em.firstname =? and (em.jobid =? or em.jobid is null).

    Kind regards
    Rommel Pino
    http://soadev.blogspot.com

  • How to write the select query for it

    Hello

    I had an html form and the area I drop down and he needs to select several values in the drop-down box. When I select multiple values then I have to write the query to SQL select statement.

    When I try to write the select statement and trying to run I get the error message.

    Select * from Table

    where emo_no = '1,2,3 '.

    That's how I write the query please suggest me how to write the query to select several values in the drop-down box.

    Thank you

    Use the keyword sql 'in '.  If you don't know how, I've heard good things about the book Teach Yourself SQL in 10 Minutes by Ben Forta.

  • Syntax of PL/SQL without papers. Keyword 'private '.

    Hello
    I'm a PL/SQL-programmer and programmer Ada too. PL/SQL is derived from Ada83. Now since I'm used to Ada sometimes I Ada syntax elements in the PL/SQL code. Normally, the PL/SQL-compiler complains and does not compile. But look at the following example:

    create or replace package privatetest is
    var varchar2 (100): = 'Test ';
    operative;

    private - Word - key undocumented
    PrivateVar varchar2 (100): = 'Test ';
    end privatetest;
    /
    create or replace package body is privatetest
    test procedure
    is
    l_var varchar2 (100);
    Start
    l_var: = privatevar;
    PrivateVar: = l_var;
    end test;
    end privatetest;
    /

    This can be compiled with PL/SQL release 10.2.0.4.0. Private package dry parts are normal in Ada Ada allows the children to packaging and then you need this mechanism of masking. In more complex situations, I met a strange behavior during execution so 'private' is used in PL/SQL.

    Question: Is this a historical vestige that the compiler accepts the keyword or ist it plans to allow the private parts child packing in the future releases from PL/SQL?

    Kind regards
    Frank Piron

    user5200696 wrote:
    I wanted to point to this "feature" without papers because it is a real trap for Ada programmers who write code in PL/SQL too.

    It smells the opportunity to write your ADA-> PL/SQL experiences in a blog or an article - it seems like a shame to your experiences of learning to go not shared.

  • How the sql query to sort the records by variable

    Feel like using PHP to know how to write the query SQL ORDER BY
    value time from list/menu form field ("sort_menu") and the values in the list are the columns of the database

    SELECT *.
    OF rentals_info
    WHERE rentals_info.active = 'yes '.

    Thanks for your help,
    Jim balthrop

    JBWebWorks wrote:
    > Using fault PHP to know how to write the query to sql ORDER BY
    > run time value from list/menu form field ("sort_menu") and the list
    > values of the database columns

    Unfortunately, you can not use the Dreamweaver Recordset dialog box to set
    a column of the table as a variable. You need to adapt the code by hand, and
    Once you do, the recordset can be is no longer recognized by
    Dreamweaver. Thus, you must have first page in case the
    Bindings panel shows more the fields in your recordset.

    Begin by creating the Recordset without the ORDER BY clause and have
    your page as you want it. When everything is done, add the following
    code at the top of the page:

    <>
    create a table of column names that can be used for sorting
    $permitted = array ("price", "space");
    checks if the sort_menu variable contains a valid column name
    If (isset($_GET['sort_menu']) & in_array ($_GET ['sort_menu'], $permitted)) {}
    $sort = $_GET ['sort_menu'];
    } else {}
    the value of a default column for sorting
    $sort = "price".
    }
    ?>

    This assumes that the sort columns are called price and region.
    Change these values according to your configuration.

    You can now add ORDER BY $sort to the SQL of the Recordset.

    --
    David powers
    Adobe, Dreamweaver community expert
    http://foundationphp.com

  • How to convert this SQL PL/SQL query

    Basically, I need to create an anonymous block that will display the name of each student, family name and the number of students who scored less than test 1 that the student.

    So basically you need to find the number of students scoring less than this particular student and we do it for all students of the table.

    So, for this particular query, I designed my code in SQL

    Select g1.gr_fname, g1.gr_lname, count (*)
    grade g1, g2 grade
    where g1.gr_t1 > g2.gr_t1 and
    G1.std_code = g2.std_code
    G1.gr_fname group, g1.gr_lname;

    But I am unable to get the logic of how to run it in PL/SQL, something missing a minor detail to run the same in PL/SQL

    could someone help me please with the logic.

    Thank you

    You can write it in pl/sql like this

    begin
      for i in (
                select g1.gr_fname, g1.gr_lname, count(*) cnt
                  from grade g1,
                       grade g2
                 where g1.gr_t1 > g2.gr_t1
                   and g1.std_code = g2.std_code
                 group by g1.gr_fname, g1.gr_lname;
               )
      loop
        -- I have just wirtern the output into the buffer. You can do what ever you want here.
        dbms_output.put_line(i.gr_fname||'/'||i.gr_lname||'/'||i.cnt);
      end loop;
    end;
    

Maybe you are looking for

  • "Hey Siri" still works on the LockScreen

    Why "Hey Siri" function, now tell me it cannot launch an application when the screen is locked?

  • Satellite A300-1J1 - some FN keys do not work

    My FN key seems to have broken the half. When I press on it that the icons would be usually displayed on top of my screen now it doesn't and all the function keys F1 F2 F3 etc work with key except F4 which hibernates the computer, also light turn on

  • 2 10 tab of yoga - bkc800 keyboard lenovo does not

    Hi guys I'm new here, I just bought the windows tablet 10 2 lenovo yoga 8.1 version, it worked fine with the keyboard, but sometimes the keyboard bkc800 had matching problems, in order to correct them, I had switch of the keyboard/Tablet 'off' and 'o

  • Unable to connect to itunes, iMac

    Afterl ogging on itunes for El Capitan was last updated. I can't not to connect to the itunes store account.

  • Graphic cursor property

    My chart of waveform has two graphs overlaying each other.  The chart has two sliders of mult-land.  Each slider look a different terrain. I tried to use the node property to move the cursor, and it seems that the sliders will go for a fraction of a