json_list to varchar/string to use in the virtual column

Hello Experts,

Environment:

Database Oracle 12 c Enterprise Edition Release 12.1.0.2.0 - 64 bit Production

PL/SQL Release 12.1.0.2.0 - Production

I have the following function that returns JSON_LIST.

{code}

CREATE OR REPLACE FUNCTION GENERATE_JSON (STRING2CONVERT IN VARCHAR2)

RETURN JSON_LIST

DETERMINISTIC

IS

RET json_list;

V_ERROR VARCHAR2 (31000);

BEGIN

RET: = json_dyn.executeList (STRING2CONVERT);

RET. Print;

RETURN RET;

EXCEPTION WHEN OTHERS THEN

V_ERROR: = SQLERRM;

RETURNS A NULL VALUE.

END;

-test the query see the output in the output of DBMS

SELECT GENERATE_JSON (' select ' |) Chr (39) | ' AJ' | Chr (39) |' like c_name,' | Chr (39) | ' BOY ' | Chr (39): ' c_type, like '

|| Chr (39) | ' HUMAN '. Chr (39): ' as c_category,' | Chr (39) | ' TEST SUBJECT ' | Chr (39) | 'as c_desc from dual')

FROM DUAL;


{code}


The SQL query above in the DBMS output output

[{

"C_NAME": "AJ."

"C_TYPE": "BOY."

"C_CATEGORY": "HUMAN."

'C_DESC': 'GUINEA PIG '.

}]


Question: How can I have it return the same structure of String (varchar).


Why would I want to convert JSON_LIST to string?

So that I can use this call to service as part of a virtual column in a table to store Json and have a constraint to enforce structureof Json.


If this is not the right way?

Kindly share how I can take a few columns in the same table, convert to json format and store in a virtual column in the same table and enforce the Json structure?


Thank you

AJ



with

data in the form of

(select q'~ select "AJ" as c_name, 'BOY' as c_type, 'HUMAN' as c_category, 'SUBJECT of TEST' as the double c_desc ~' source)

of the double

),

Converter (SRC, res, Step) as

(select regexp_replace (ltrim (upper (substr (source, 1, instr (upper (source), "FROM") - 1)), "SELECT"), '\s+AS\s+',': ') |) ',', null, 1

from the data

Union of all the

Select substr (src, instr(src,',') + 1)

'"' || substr (substr (SRC, 1, InStr (CBC, ',') - 1), instr (substr (src, 1, instr (CBC, ',') - 1),': ') + 1) | '" : ' ||

Replace (substr (substr (SRC, 1, InStr (CBC, ',') - 1), 1, instr (substr (src, 1, instr (CBC, ',') - 1),': ')-1), "','" ' "),

Step + 1

converter

where the CBC is not null

)

Select the source'[{' | listagg(res,',') Group (order by step) |}] '] "converted

data converter

SOURCE CONVERTED
Select "AJ" as c_name, 'BOY' as c_type, 'HUMAN' as c_category, 'SUBJECT of TEST' as double c_desc [{'C_NAME': 'AJ', 'C_TYPE': 'BOY', 'C_CATEGORY': 'HUMAN', 'C_DESC': 'GUINEA PIG'}]

Concerning

Etbin

Tags: Database

Similar Questions

  • Interval partitioning using the key of the virtual column

    Hi guys

    I have a series of tables that I propose to the partition.

    Each table has a year and a period (equivalent to a month) and I intend using those as my partition keys - year as the partition and the period as the subpartition.

    The distribution will be actually:

    2015

    001

    002

    ...

    012

    2016

    001

    002

    ...

    012

    etc...

    I would use range partitioning for the year, because it would make the maintenance of the partition a breeze.  Only one problem - the field is of type varchar, and is not modifiable as its legacy applications that have become bigger than Ben Hurr and more tangled than a Ben Hurr size flat spaghetti.

    It is hence the idea of virtual column between in game - I could create a virtual column in these tables to convert the field to digital and then partition on it instead.

    My question-if the year of origin varchar column is included in the where clause of a query, is the optimizer based on CSSTidy smart enough to realize that the virtual column used for the partition key is based on this column and use pruning of partition to improve performance?  Or queries must refer to the virtual column to make it work?  Also, the virtual column should be indexed to make it work?

    Thanks in advance.


    Simon

    orclz >

    orclz > create table pt (v1 varchar2 (1) c1 as (to_number (v1)), number of c2)

    2 partition by range (c1) interval (1)

    subpartition by hash (c2) subpartitions 4 3

    4 (partition p1 values less than (1))

    5.

    Table created.

    orclz > set autot on explain

    orclz > select * PT where v1 = '0';

    no selected line

    Execution plan

    ----------------------------------------------------------

    Hash value of plan: 711571056

    --------------------------------------------------------------------------------------------

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time | Pstart. Pstop |

    --------------------------------------------------------------------------------------------

    |  0 | SELECT STATEMENT |      |    82.  2296 |    29 (0) | 00:00:01 |      |      |

    |  1.  RANGE OF PARTITION ALL THE |      |    82.  2296 |    29 (0) | 00:00:01 |    1. 1048575.

    |  2.  HASH PARTITION ALL |      |    82.  2296 |    29 (0) | 00:00:01 |    1.    4.

    |*  3 |    TABLE ACCESS FULL | PT |    82.  2296 |    29 (0) | 00:00:01 |    1. 1048575.

    --------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    3 - filter ("V1" = '0')

    orclz > select * PT where c1 = 0;

    no selected line

    Execution plan

    ----------------------------------------------------------

    Hash value of plan: 1726115854

    -----------------------------------------------------------------------------------------------

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time | Pstart. Pstop |

    -----------------------------------------------------------------------------------------------

    |  0 | SELECT STATEMENT |      |    82.  2296 |    29 (0) | 00:00:01 |      |      |

    |  1.  RANGE OF SINGLE PARTITION |      |    82.  2296 |    29 (0) | 00:00:01 |    1.    1.

    |  2.  HASH PARTITION ALL |      |    82.  2296 |    29 (0) | 00:00:01 |    1.    4.

    |*  3 |    TABLE ACCESS FULL | PT |    82.  2296 |    29 (0) | 00:00:01 |    1.    4.

    -----------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    3 - filter ("C1" = 0)

    --

    John Watson

    Oracle Certified Master s/n

  • Alarms / opinion on the use of the virtual machine JAVA Perm Gen

    Hi team,

    I need to configure alarms / Notification each time that the use of the virtual machine JAVA Perm Gen is greater than a threshold value. I don't see all the default rules / corresponding to Perm Gen registry variables.

    Could you please enlighten us in how I can achieve... ?

    A screenshot is attached for your reference.

    Kind regards

    Arun

    I tested it after the previous message which was released indicating that you have an error, the nice thing about Foglight is that it allows to see the measures that exist (as you noted the names are a bit different in this case as the example of the JVM) and it also gives you a test button to validate the expression) , don't forget to make sure that she only appliese to the things that have names like Perm if you want it calculated only for generations of perm.

    Can you please define this thread as answered.

    Thank you

    Golan

  • Use of the virtual machine / machine is safe?

    I have windows 8.1 pro I want to use operating systems diferrent/test I use virtual box to install the OS on my laptop, it will be useful for me to install os without data lost, but I noticed that when I run the VM my system's struggle

    can I use the virtual machine on my laptop without care or stop using it please help

    Hello

    It is very good for the material.

    But follow the steps above, then you don't take too much of your main operating system resources when you install virtualbox.

    Checkurtech

  • ADF and the use of the XMLType columns

    After discovering the Jdeveloper 11 g was able to generate business components/data controls for complex web services (see this tutorial excellet http://www.oracle.com/technology/tech/fmw4apps/agile/pdf/adf11g-agile.pdf), I assumed that jdev 11 g should now have the same capacity on XMLtype columns with a registered scheme, and was therefore a good match for our enforcement objectives be able to edit
    parts of an XML document to aid in the face of components and Assembly/store the document in a way centic document in a relational/XML database XMLType column hybrid.

    I tested this point, has created a table with an XMLType column binary, saved the schema in database (11g) and jdev(11g) and generated my components.


    I was very disappointed at the discovery of the structure of data controls stops at the level of the attribute in the table (ie the XMLType column), so none of the structure of the XML document is revealed or can be used in a meaningful way through data control.

    Am I missing something here? should not control data generated reveal the XML structure and allow the use of components of forms/table faces on some parts of the structure of the document? I'm not a java programmer, so was really hoping to do this with data not generated controls beans not.

    If it is just to treat it as a CLOB, what's the point of registered xsd schemas?

    Yes, it is through java. Sorry

  • Disk space used by the Virtual Machine

    I'm under VMWare Fusion worm / 3.1.4 on a MacBookPro 2010 with Windows XP Pro installed.  In My Documents, there is a folder called "Virtual Machines".  It has a file in it, "Windows XP Pro 2.vmwarevm".

    The problem is that this file is 121,95 gigabytes!  Nearly half of the size of my hard drive.


    Question 1.  Does this make any sense?

    Question 2.  This file size can be reduced to something reasonable?


    Thank you!


    IdahoBob

    According to the information of the beam support Virtual Machine has 8, not 7, Snapshots.

    Without a support package for now present the only other suggestion is to delete all the snapshots, and then reduce the virtual hard disk of the applet of control panel of VMware Tools in Windows, and then Clean Up drive from the drives Panel in the settings of the Virtual Machine.

  • details of the virtual columns and deterministic function

    Hello

    First time that I post a question after the migration of the Forums. So please excuse me if you see errors in format.

    Below, I have created a function as deterministic and a table with a virtual column (column refers to the function)

    Here are my questions

    (1) if I run SELECT * FROM t whenever Oracle will perform the function add_fn?

    (2) what is the advantage of DETERMINISTIC? (Documentation says that if we declare a function as deterministic he will attempt to use previously caluculated results for the same set of values. So, when I ever I run SELECT * FROM t oracle executes add_fn only once and it will use the result for the next time. Is my understanding correct.)

    Here's the code.

    SQL> create or replace function add_fn ( p_n1 in number
      2                                                   ,p_n2 in number )
      3  return number deterministic
      4  is
      5  begin
      6      return p_n1+p_n2;
      7  end;
      8  /
    Function created
    SQL> create table t ( n1 number
      2                       ,n2 number
      3         ,n3 number generated always as (add_fn(n1,n2)) virtual
      4         );
    Table created
    SQL> insert into t (n1,n2) values (10,20);
    1 row inserted
    SQL> select * from t;
            N1         N2         N3
    ---------- ---------- ----------
            10         20         30
    SQL> select * from t;
            N1         N2         N3
    ---------- ---------- ----------
            10         20         30
    SQL>
    

    Hello

    ...
    (1) if I run SELECT * FROM t whenever Oracle will perform the function add_fn?

    (2) what is the advantage of DETERMINISTIC? (Documentation says that if we declare a function as deterministic he will attempt to use previously caluculated results for the same set of values. So, when I ever I run SELECT * FROM t oracle executes add_fn only once and it will use the result for the next time. Is my understanding correct.)

    ...

    (1) oracle will have to evaluate the function.  Because only deterministic functions are allowed, this means that it will not necessarily perform the function again; He can get the value cached from a previous call.

    I think that the indexed values are actually stored in the index.  "SELECT * FROM t;" do not use an index, but if you make another request, then you should be able to get the value of the virtual table of the index, without calling the function or obtaining the value of a cache.

    (2) If a function is DETERMINISTIC, the optimizer may decide whether to actually call the function each time, or the cache for better performance results.  There is no guarantee that it will always be one or the other.  Replace "will be" in your description "may", and then what you say is correct.

  • I want to change the table with the expression of dangerousness of the virtual columns with her, need advice

    Hi all

    Here is the structure of the table with two expression of virtual columns associated highlighted, now I want to delete these expressions with virtual columns (but must keep my VIRTUAL columns as it is).

    Is it possible the alter or I need to raise the table, make a new structure and copy content back to newly structured table... Pleae help!

    CREATE TABLE TEST_COL)

    SAGE_TRADE_TYPE VARCHAR2 (50 BYTE),

    LOCAL_TZ VARCHAR2 (20 BYTE),

    ACE GMT_CONV_ENTERED_DT_TS (SAGEDBO. FN_CONVERT_TIMEZONE (LOCAL_TZ, ENTERED_DT_TS)) VIRTUAL,.

    ACE GMT_CONV_EXECUTION_DT_TS (SAGEDBO. FN_CONVERT_TIMEZONE (LOCAL_TZ, UPSTREAM_EXECUTION_TS)) VIRTUAL,.

    EOD_IND VARCHAR2 (10 BYTE)

    );

    Thank you very much

    Arpit

    Try this

    ALTER table test_col change gmt_conv_entered_dt_ts (0) virtual;

    ALTER table test_col change gmt_conv_execution_dt_ts (1) virtual;

  • Request for use of the virtual computer RAM

    Hi all

    I have 3 x VM running to work in a box, each machine was given to 16 GB RAM allocated.
    My confusion is when a virtual machine starts and become inactive, the memory usage levels out and remains the same (as you know).  However when an application is launched, and the memory usage is used, it is never 'product' when the application closes.  So finally, during the day the memory used displays 99% and will never fall.  There are never problems with caution and no request may not work, but I found this strange behavior...
    Is this a normal behavior?  Can someone explain the logic behind this?
    Thanks :)

    Given that most of the individuals are not running Virtual Machines, I would say that your question belongs better in the IT Pro community:

    http://social.technet.Microsoft.com/forums/en-us/categories

  • Reason: The called function can only be performed on partial strings. Please open the virtual disk parent.

    I have a problem in which a snapshot has become corrupted, so I had followed the instructions through this forum to point her load the file to the correct file.  However, once I restarted the operating system virtual weeks later I now get this error.  I have attached the log.  Any help?  I think that eventually I want to reinstall the boot camp because she does not need to be run in parallel with the mac operating system.

    Check that the basic disk "Windows Vista.vmdk" is not elsewhere on the host before you delete.  Using the following command in a Terminal.

    mdfind "Windows Vista.vmdk"
    

    With regard to the installation of Windows natively in Boot Camp, which is not something Apple VMware so take a look at the Boot Camp Assistant documentation.

    / Applications/utilities/Boot Camp Assistant.app

    / Applications/utilities/Boot Camp Assistant.app/Contents/Resources/English.lproj/Documentation.pdf

  • What is the use of the associated columns?

    In the model business, logical columns are associated with a dimension level. But the columns are nether primary key or used for display. What is the purpose of these related columns?

    To expand our example a little more.

    You have one day sun, as well as a month Dim. Your month logical name column is mapped to two tables through sources different logical table. Your levels of content is defined accordingly for these LTS.

    You have a grain day fact table and a grain months aggregated fact table. You have a measure ($ quantity, no matter) mapped to two physical tables through two LTS with levels of content defined (as the time Dimension).

    So when you query the name of the month and in Dollars, the BI server uses the global table as it can serve both the attribute of the dimension and the measure of the global table. He knows its more effective because the ratio between the number of items that you have defined in the hierarchy told him about 30 times less data on the whole of the month, by the ratio of 365 days 12 months ago.

    So far so good.

    Allows to introduce more dimensions, a.n.other dimension is attached to the base of fact table but NOT in the whole month. You model everything as per normal, when you drop this dimension in your report, the BI server recognizes that there is no comprehensive source that can give the right answer in all the areas required in the report falls to the next best form requested in the report, grain in this case simple, it would default to the base's table because it is only capable of serving the month and all fact table the attributes of the other dimension. In more complex models, you may have a few tables of aggregation with two more high grain (high) or less dimensionality (fewer lines). Setting levels LTS the existence of physical layer Joins tell the BI server which can be attached to the dimensioning, it tells what tables of aggregation would be more effective.
    Not to be confused with the establishment of a limit on a measure - it's something different (level total function, % of the year etc etc.)

    I have it?

    These might help:
    http://gerardnico.com/wiki/dat/OBIEE/fragmentation_level_based
    http://www.rittmanmead.com/2006/11/aggregate-navigation-using-Oracle-BI-server/
    http://obiee101.blogspot.com/2008/11/OBIEE-making-it-aggregate-aware.html

    Let us know if any more Q

  • # used in the name column in DB

    I'm working with a pre-existing database in which many of the column names contain a sign #. Someone at - it a good solution for this scenario outside of rename column?

    Example of name of column: Last_CTR #.

    One option is to use an alias.



    SELECT [Last_CTR #] AS AliasForBadColumnName
    FROM SomeTable

  • Is it possible to get use of the virtual machine Nic cards?

    Hi all

    I would like to know if there is possible to get the nic card (objectNetworkAdapterImpl ) send/receive rates of VM through the cmd-lets get-stat statistical data?

    Concerning

    Danny

    I decided to do a blog on it.

    See vNIC send and receive rates

  • What vmnic driver to use for the spine of 10g

    Hi any recommendation on what vmnic driver to use for the virtual machine if I have a spine of 10g? I use Vcentre 4.1 U2

    Hello.

    This will depend on the guest OS, but if you just want pure performance then VMXNET 3 would be the one to try. Also check out the kb VMware "choose one network adapter for your virtual machine.

    Good luck!

  • Generate the CSV file to the virtual machine by using get-stat statistics

    Hi all

    I put my VC for taking samples every 5 minutes for 3 days.

    I would create a PowerCLI script that I can then run on an ad hoc basis to connect to my VC and to get the details for ALL of the virtual machines that are managed by this CR and fill in a CSV (c:\foo.csv):

    • Name of the virtual machine

    • The ESX VM host is currently sitting

    • total number of virtual processors assigned to VM

    • total memory allocated to the VM

    • memory active average used by the virtual machine in the 3 days using samples of 5 minutes

    • average mhz CPU used by VM spent 3 days using samples of 5 minutes

    I have attached a sample file XLS of CSV output should look like.

    If anyone can give me a code to achieve or get on well on my way, I would appreciate it a lot.

    Kind regards

    Alex

    OK, so what you want is something like this then?

    Get-VM | Where {$_.PowerState -eq "PoweredOn"} |
     Select Name, Host, NumCpu, MemoryMB,
               @{N="Cpu.UsageMhz.Average";E={[Math]::Round((($_ | Get-Stat -Stat cpu.usagemhz.average -Start (Get-Date).AddHours(-72) -IntervalMins 5 -MaxSamples (12) | Measure-Object Value -Average).Average),2)}},
               @{N="Mem.Usage.Average";E={[Math]::Round((($_ | Get-Stat -Stat mem.usage.average -Start (Get-Date).AddHours(-72) -IntervalMins 5 -MaxSamples (12) | Measure-Object Value -Average).Average),2)}}
    

    I think that the issue that you have with the missing stat might be to do with your logging levels in VC, if these are not set correctly it will not save these stats for this period of time.

    What do you get if you do a simple:

    get-vm "SingleVM" | Get-Stat -Stat cpu.usagemhz.average
    

    If you found this information useful, please consider the allocation of points for correct or helpful.

    Alan Renouf

    http://Virtu-al.NET

Maybe you are looking for

  • Qosmio Player download

    Where can I download a copy of the Qosmio Player for the F20? Thank you.

  • How to configure FireFox pages in English? Now, it's in Dutch!

    I just installed Firefox. It comes with all of the information in Dutch (I live in Belgium) I want information in English. How?

  • Re: Recovery problem Satellite L305D-S5892

    Well, here's the problem: I tried unsuccesfuly for recover my top lapt to the standarts of the factory Here is what I tried: -J' read the manual and he said I'd get a disk with software already installed in the computer of mi in: creator of menu/tosh

  • Double screen

    I have a hp pavlion p6310f and have installed a 1 GB video card is it possible to run both onboard and the dedicated card? EDTII

  • Replacement of blackBerry Z10

    Hello people I have a Z10, however I was not able to use it to its fullest because he literally had a bath in a beacth, I was able to restore it, however, little time spent and the heating of the phone reached dangerous levels for me, I suspect that