Works with tables/columns of the lines and the parameter names... syntax help

I am trying to create a function that returns the distinct value and counts of a user defined schema/table/column.

The code below defines a [stats_on_column_obj] object type and creates a single table of this type [stats_on_column_tab].

The function is supposed to take three input variables: p_schema_name, nom_table_p, p_column_name and return an array (above).

I can hardcode a select into (the)... but once I try to convert it into settings & immediate exec I'm stuck. The red section is where the problem is (I think).

Oracle 10g.

Stats_on_column_obj CREATE TYPE IS OBJECT (

COL_VAL VARCHAR2 (500),

NUMBER OF COL_VAL_CNT (7)

);

CREATE TYPE Stats_on_column_tab IS TABLE OF stats_on_column_obj;


FUNCTION to CREATE or REPLACE get_STATS_ON_COLUMN

(

p_schema_name IN varchar2,

nom_table_p IN varchar2,

p_column_name IN varchar2

)

RETURN STATS_ON_COLUMN_tab

IS

l_STATS_ON_COLUMN_tab STATS_ON_COLUMN_tab: = STATS_ON_COLUMN_tab ();

n INTEGER: = 0;

str_select_tbl varchar2 (5000);

BEGIN

str_select_tbl: = 'SELECT'. p_column_name |' as col_val, count (*) as col_val_cnt FROM ' | p_schema_name |'. ' || nom_table_p: ' group of ' | p_column_name;

FOR r IN (str_select_tbl)

LOOP

l_STATS_ON_COLUMN_tab. EXTEND;

n: = n + 1;

l_STATS_ON_COLUMN_tab (n): = STATS_ON_COLUMN_obj (r.col_val, r.col_val_cnt);

END LOOP;

RETURN l_STATS_ON_COLUMN_tab;

END;

/

[Error] PLS-00103 (124:4): PLS-00103: encountered the symbol "LOOP" when expecting one of the following numbers: * & - + / at rem rest mod.. < an exponent (*) > | multiset year DAY_

[Error] PLS-00103 (126:9): PLS-00103: encountered the symbol "=" when expected in the following way: constant exception < an ID > < a between double quote delimited identifiers > double Ref table Fedya Chariot of time timestam

[Error] PLS-00103 (127:29): PLS-00103: encountered the symbol "

[Error] PLS-00103 (128:4): PLS-00103: encountered the symbol "END" when waiting for one of the following numbers: begin function package pragma procedure subtype type use < an ID > < a double quote delimited identifier > form

SELECT * FROM TABLE (get_STATS_ON_COLUMN ('SCHEMAS_X', 'TABLE_X', 'COLUMN_X'));

Scott@ORCL > CREATE OR REPLACE
FUNCTION get_STATS_ON_COLUMN () 2
3 p_schema_name IN varchar2,
4 nom_table_p IN varchar2,
5 p_column_name IN varchar2
6                                )
7 STATS_ON_COLUMN_tab of RETURN
8 EAST
9 v_STATS_ON_COLUMN_tab STATS_ON_COLUMN_tab: = STATS_ON_COLUMN_tab ();
10 v_n INTEGER: = 0;
11 v_str_select_tbl VARCHAR2 (5000);
BEGIN 12
13 v_str_select_tbl: = ' SELECT stats_on_column_obj (' | p_column_name |) ', Count OF ' |
14 p_schema_name | '.' || nom_table_p | "Group of" | p_column_name;
15 v_str_select_tbl EXECUTE IMMEDIATE
COLLECTION IN BULK 16
17 IN v_STATS_ON_COLUMN_tab;
18 RETURN v_STATS_ON_COLUMN_tab;
END 19;
20.

The function is created.

Scott@ORCL > select *.
2 from table)
(3 get_STATS_ON_COLUMN)
4                                            'SCOTT',
5                                            'EMP',
6                                            'JOB'
7                                           )
8                       )
9.

COL_VAL COL_VAL_CNT
-------------------- -----------
CLERK                          4
SELLER 4
PRESIDENT 1
MANAGER 3
ANALYST 2

Scott@ORCL >

Or better change function in the pipeline.

SY.

Tags: Database

Similar Questions

  • Working with table gross typed the parameter of the procedure.

    I have a table defined as


    CREATE TABLE 'JOBS '.
    ("JOB_ID' VARCHAR2 (200 BYTE),
    'FUNCTION' RAW (16).
    NUMBER OF "MIN_SALARY."
    NUMBER OF "MAX_SALARY.
    )



    Defined as package

    create or replace package associative_array as
    type t_job_id is table of index jobs.job_id%type by pls_integer;
    type t_job_title is table of index jobs.job_title%type by pls_integer;
    type t_min_salary is table of index jobs.min_salary%type by pls_integer;
    type t_max_salary is table of index jobs.max_salary%type by pls_integer;

    procedure array_insert (p_job_id in t_job_id,
    p_job_title in t_job_title,
    p_min_salary in t_min_salary,
    p_max_salary to t_max_salary);
    end associative_array;
    /


    create or replace package body associative_array as
    procedure array_insert (p_job_id in t_job_id,
    p_job_title in t_job_title,
    p_min_salary in t_min_salary,
    p_max_salary to t_max_salary) is
    Start
    ForAll i in p_job_id.first... p_job_id. Last
    insert into jobs (job_id,
    function,
    min_salary,
    max_salary)
    values (p_job_id (i),
    p_job_title (i),
    p_min_salary (i),
    p_max_salary (i));
    end array_insert;
    end associative_array;
    /

    The client code is

    String s = "UserID = system; password = system; data source = ORCL; enlist = true; layout common = true ";

    create and open the connection object
    Con OracleConnection = new OracleConnection (constr.);
    con. Open();
    OracleCommand cmd = con. CreateCommand();
    cmd.CommandText = "associative_array.array_insert";
    cmd.CommandType = CommandType.StoredProcedure;

    create objects for each parameter setting
    OracleParameter p_job_id = new OracleParameter();
    OracleParameter p_job_title = new OracleParameter();
    OracleParameter p_min_salary = new OracleParameter();
    OracleParameter p_max_salary = new OracleParameter();

    set the type parameter for each parameter
    p_job_id. OracleDbType is OracleDbType.Varchar2.;
    p_job_title. OracleDbType = OracleDbType.Raw;
    p_min_salary. OracleDbType = OracleDbType.Decimal;
    p_max_salary. OracleDbType = OracleDbType.Decimal;

    Set the type of collection for each parameter
    p_job_id CollectionType in the Group OracleCollectionType.PLSQLAssociativeArray;
    p_job_title. CollectionType = OracleCollectionType.PLSQLAssociativeArray;
    p_min_salary. CollectionType = OracleCollectionType.PLSQLAssociativeArray;
    p_max_salary. CollectionType = OracleCollectionType.PLSQLAssociativeArray;

    Set the parameter values
    p_job_id. value = new string [3] {"IT_DBA", "IT_MAN", "IT_VP"};
    p_job_title. Value = new Guid [1] {Guid.NewGuid ()};
    p_min_salary. Value = new decimal [3] {8000, 12000, 18000};
    p_max_salary. Value = new decimal [3] {16000, 24000, 36000};

    set the size for each table
    p_job_id. size = 3;
    p_job_title. Size = 1;
    p_min_salary. Size = 3;
    p_max_salary. Size = 3;

    p_job_id. ParameterName = "p_job_id";
    p_min_salary. ParameterName = "p_min_salary";
    p_max_salary. ParameterName = "p_max_salary";
    p_job_title. ParameterName = "p_job_title";

    Add parameters to the collection of command objects
    cmd. Parameters.Add (p_job_id);
    cmd. Parameters.Add (p_job_title);
    cmd. Parameters.Add (p_min_salary);
    cmd. Parameters.Add (p_max_salary);

    BindByName. cmd = true;
    run the insert
    cmd ExecuteNonQuery());

    Error occurred during execution of the customer.

    Unhandled exception: System.ArgumentException: invalid parameter binding
    Parameter name: p_job_title
    at Oracle.DataAccess.Client.OracleParameter.GetBindingSize_Raw (Int32 idx)
    at Oracle.DataAccess.Client.OracleParameter.PreBind_Raw)
    to Oracle.DataAccess.Client.OracleParameter.PreBind (OracleConnection conn, IntPtr errCtx, Int32 arraySize)
    at Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery)

    But if I change jobs. P_job_title varchar2 and change function. Value and p_job_title. Therefore, any OracleDbType is fine.

    Following me is at fault-
    p_job_title. Value = new Guid [1] {Guid.NewGuid ()};

    Since you have already said-
    p_job_title. OracleDbType = OracleDbType.Raw;

    You must have 'p_job_title. Value' as 'Byte' or 'OracleBinary.

    It will be useful.

  • Sometimes the audio does not work and another day, everything is ok. What can this be? IK have an Asus laptop and I work with windows 7. The melody of the beginning when I put on my laptop is ok

    Sometimes the audio does not work and another day, everything is ok. What can this be?  IK have an Asus laptop and I work with windows 7. The melody of the beginning when I put on my laptop is ok

    Hello Ronald.

    A problem are not uncommon. Something for you to try:

    http://Windows.Microsoft.com/en-in/Windows/no-sound-help#no-sound=Windows-7&V1H=win8tab1&V2H=win7tab1&V3H=winvistatab1&v4h=winxptab1

    Let me know if this solves the problem for you.

    Kind regards

    BearPup

  • Recently I install Adobe Pagemaker 7.0, but it is not my system hindi font visible just like the series Devi ismayl, KBC Serise etc. these fonts are is visible and working with Adobe photoshop, corel, office etc. and works well. Veuileez solve this proble

    Recently I install Adobe Pagemaker 7.0, but it is not my system hindi font visible just like the series Devi ismayl, KBC Serise etc. these fonts are is visible and working with Adobe photoshop, corel, office etc. and works well. Veuileez solve this problem as soon as possible.

    Can you also please check whether this version is still appropriate for your operating system?

    See: Adobe - Pagemaker 7: System requirements

    The system configuration required

    Windows

    • Microsoft® Windows NT® 4.0 with Service Pack 6, Windows® 2000 Professional with Service Pack 2, Windows XP Professional or home edition

    It is not recommended to run this software on any Mac modern like Windows 7 or 10.

    Good luck!

  • I can not open my Raw files from my new Nikon 810. With my Nikon 800 I use Bridge to select and then it opens to the PS CS5. To make it work with 810 I download the DNG Converter, but I still can't open the files.

    I can't open my Raw files from my new Nikon 810. With my Nikon 800 I use Bridge to select and then it opens to the PS CS5. To make it work with 810 I download the DNG Converter, but I still can't open the files. What can I do?

    Hi ulcabeek,

    Greetings!

    What version of DNG converter that you use?

    You need DNG converter 8.6 for this: 8.6 camera Raw and DNG Converter 8.6 now available

    Concerning

    Jitendra

  • How to get the names of the table columns in the quick dashboard

    How to get the names of the table columns in the quick dashboard


    Thanks and greetings
    ------------------------
    Kishore P

    Make a prompt like:

    SELECT case when 1 = 0 then 'D0 time. " "" T02 by month name "other" 'D2 market' '. "" M04 region' ' the end 'Sample Sales' UNION ALL SELECT case when 1 = 0 then 'D0 Time. " "" T02 by month name ' else ' 'Time D0. "" T02 by month name ' ' the end 'Sample Sales.

    Put the name of column in single quotes.

    Make your rank as a function:
    Rank ('F1 income'. "" Recipes 1-01 (after all) "by @{pColumn} {'D0 time'. ({"" T05 annually name '})

    It works fine for me

    concerning

    John

    http://obiee101.blogspot.com

  • My speakers Altec Lansing ADA745 will work with my 530 s the new Dell Inspiron PC?

    My speakers Altec Lansing ADA745 will work with my 530 s the new Dell Inspiron PC?

    I watched updates of the audio driver for my pc and am not sure which one I need or you can even use it.

    Although "4.1" speaker systems are very common, the ADA745 should work without problems on a new system.  I have no connection to the ADA745 info but I guess it would connect everything as you are currently connected to the old PC.  New systems PC audio supports up to 7.1 speaker (with the most common 2.1 or 5.1) systems.  There is no drivers for speakers, however, you need to define the types of speakers in the control panel (e.g. article 4.1, and if this isn't an option, try the 5.1 and see if works well).   Printed with the new PC installation worksheet should detail the audio connections and if not, there is a copy of the Dell manual loaded on your PC and it has the details on the back panel connections.

    In Vista, the sound control panel is accessible by Start/Control Panel/hardware and sound/Sound.

  • My Vaio gesture control does not work with MO Pro 2013 Power Point and 14 Ultra CyberlinkPDVD

    My Vaio gesture control does not work with MO Pro 2013 Power Point and 14 Ultra CyberlinkPDVD

    Original title: control sign Vaio

    Hello

    According to my research, the actions must be enabled for individual applications. Check out the following link and activate the gesture for Power Point and Cyberlink PDVD.

    https://us.en.kb.sony.com/app/answers/detail/a_id/36487/~/how-to-configure-vaio-gesture-control-settings.

    For more help, you can contact Sony support.

    https://community.Sony.com/?XID=M:kb_header:eSupport

    Hope that the information provided is useful. Do not respond if you need more help.

  • Work with Chinese characters: how to paste and edit them like sentences; not as individual images?

    Work with Chinese characters: how to paste and edit them like sentences; not as individual images?

    In 2004, it's far more detailed response, I could find: http://en.allexperts.com/q/Adobe-Illustrator-1027/FONTS-display-problem-Adobe.htm, but it is this solution really even more up to date?

    Is it possible at all to work with Chinese characters, if I don't have the Chinese version of Illustrator? (http://www.proz.com/forum/dtp_desktop_publishing/221125-chinese_in_indesign.html)

    The police you see that is applied when you paste? It seems, by default, illustrator assigns Kosuka Gothic Pr6N. try a different font as Adobe Heiti Std R.

  • Insert as select on a table with 759 columns, including the Vitrual columns

    Dear people,

    DB version: 11.2.0.3.4
    Quality: Production
    Type: 2 node RAC

    Description of the problem: we meet with repeated ORA-00600 when we tried expdp a table as part of the application process. This has later been explored as a logical corruption on the primary key index. Request team works on the deletion and re-creation of the index according to the suggestion of support oracle.
    In the meantime, I tried to copy the table data affected with insert that choose, since exp pump/classic/ETG work or meet the requirement.

    The affected table contains more than 255 columns, to be precise - 757 normal columns and 2 virtual columns, these 2 virtual columns to create a composite subpartition on the table. Subparts are compressed BASIC.

    Since we cannot load the data in a virtual column, I exclude these 2 virtual columns and load data on to rest columns, virtual columns are filled based on the opinions of other 2 columns. The number of columns to select in the insert that is greater than 255, I am not able to load data using sql * more and sql developer, because they cannot manage this huge list of selection.

    SQL * Plus fails with the error "too Long".
    Developer SQL fails with "left/right parenthesis not found."
    I failed to Toad, so I have not tried the same thing, don't know if the TOAD can handle this huge list of selection either.

    My insert would look like below...

    Insert into the target (t1, t2, t3... t757) select (t1, t2, t3... t757) source;

    Can someone give me some directions please?

    Thanks and greetings
    Raja

    You sure have a closing parenthesis at the end of the select statement? This seems to reproduce the error:

    SQL> insert into t1 ( id,
      2  descr,
      3  name)
      4  select (id,
      5  descr,
      6  name
      7* from t
    SQL> /
    select (id,
              *
    ERROR at line 4:
    ORA-00907: missing right parenthesis
    

    You can also remove the opening parens of the select statement, because it is not really necessary.

    John

  • Selection of parts and columns, or entire lines and apply the character style

    I am trying to apply character styles to certain parts/whole rows and columns.

    I can change individual cells with the following code...

    table = app.selection[0];
    if (table.hasOwnProperty("baseline")) table = table.parent;
    if (table instanceof Cell) table = table.parent;
    if (table instanceof Column) table = table.parent;
    if (table instanceof Row) table = table.parent;
    if (table instanceof Table)
    
    {
     table.rows[0].cells[6].texts[0].appliedCharacterStyle = "none report";
     }
    

    ... but when I try to select an entire line, I get the error 'Object does not support property or method' texts. "" "When I try one of the following two codes.

    {
     table.rows[0].cells.texts.appliedCharacterStyle = "none report";
     }
    

    {
     table.rows[0].cells.appliedCharacterStyle = "none report";
     }
    

    Anyone know how I can do the following?

    1. Select any row (or column) and apply the character style

    2. Select the last line (regardless of the number of rows in the table) and apply the character style

    3. apply the character style to specific columns (with theexception of the cells of two albums)

    Thank you!

    Hello

    Change this line:

    table.columns[a].cells.itemByRange(2,-1).texts.everyItem().appliedCharacterStyle = "chart orange";
    

    for the first 2 rows in each column

    Jarek

  • I'm trying to print using my own profile and no color management.   I have found a lead to the Adobe Color Print Utility but reached a point where he declared that she would not work with future versions of the Mac operating system.   I have Mac OS 10,11,

    I have been printing PSD images with my own profiles and color management using an Epson R2880.

    I've now changed to a Mac with OO 10.11.3 and unable to replace the color management.   I found a lead on the Adobe Color printer utility but failed and got a message saying that the utility has only worked with an earlier version of the OS 10.   Is there a way to turn this problem?

    GHK

    You don't want or need to use the old setting 'No Color Management'. Is no longer the right way to print with a custom printer profile, in the current versions of Photoshop and OS X.

    To use a custom profile to print, use the attached picture settings:

    • In the print dialog box, set the Photoshop color management menu manages colors.
    • Select your profile to the printer in the printer profile menu.
    • In the settings of printer driver Epson (under Printer Setup button) make sure that the Epson printer driver is set to the color - off management.

    I don't know why Adobe Color Printer Utility works in 10.11.3, because I can throw on OS X 10.10 and 10.11. But in the end, it doesn't matter, because you don't want to use it for this purpose Adobe Color Printer Utility is only to print a profiling target, no images. And it won't let you print using your custom printer profile, because the whole point of the utility is to print with no discoloration whatsoever.

  • ADE 2.0 and 4.0 do not work with Windows 10. The next problem is generated when you try to download a book from the public library.    Error getting License Server Communication problem E_ADEPT_DOCUMENT_OPEN_ERROR.

    The next problem is generated when you try to download a book from the public library.

    Error getting License Server Communication problem E_ADEPT_DOCUMENT_OPEN_ERROR.

    The work around works of Jean.  It would be nice if Adobe provided a real difficulty however.

    I have ADE installed 4.03.  The problem will occur as soon as that ADE is closed and reopened.    It takes so the patch every time allows you to download a book ADE.

    1. for Overdrive - select a book and click Download. -pop - up - select - Save file. - under the open with select - acsm_auto_file - download the file of social mobilization in your download directory.

    2. expand the Explorer open the file - go up to the OS (c)-

    -go to Program files (x 86) - enlarge

    -to enlarge Adobe

    -go to Adobe Digital Editions and the left click.

    -On the right part of the screen right click on Digitaleditions.exe.

    -Pop - up menu - on the left, click PROPERTIES

    -Pop up to select COMPATIBILITY

    -at the top of the menu compatibility, choose the resolution of compatibility issues run

    -Pop up to select the troubleshooting program

    -Pop up choose the program worked in earlier versions of windows, etc.

    -on the left, click NEXT

    -POP up - which version etc? Choose that I don't KNOW

    -on the left, click NEXT

    -POP - up - left click Test Program-

    -AT THE TOOL Avantek of window screen, a FLASHING ICON will appear - left-click on the icon - a pop-up will ask you if you want this program to change etc. On the left, click Yes.

    3. ADE open - make sure ADE is in library view.

    -Left click on FILE and then select Add to LIBRARY from the menu drop down.

    -POP UP - down to the right to choose the type of file of social mobilization

    -left side of the pop up to choose the directory where you downloaded the file of the CMHA.

    -Select the file of the CMHA in the right side of the window and on the left, click OPEN

    -It should work, but you have to go through the whole routine if you close ADE.

    I HOPE ADOBE will solve this problem. With each update of Windows 10 ADE seems crumbles a bit more.

  • the list with table.column package

    Hello

    How to know if a package of database uses table.column.
    Ex: list of all packages that use emp.ename



    Thank you
    Sandy

    Sandy,

    Try this

    select * from user_source
    where upper(text) like '%COL_NAME%'
    

    Maybe it's not 100% way to get your results, given that the procedure might have select * from table_name, otherwise you could get lines, which are similar column name.

    SS

  • How to work with tables (or lists) in the responses of WebService?

    Good evening!

    In a BPEL process, I invoked a certain Webservice that return me a list of people. Like this:

    < response >
    < personList >
    < person > Person1 < / person >
    < person > Person2 < / person >
    < person > channels3 < / person >
    < / people >
    < / respons >

    Now I need to do something with each returned item (like to call another Web service with the parameter 'person' (so I need to call a Web service for a 3 times))

    How can I do this?

    In the Assign CopyRules element, I see only:
    response | _
    personList | _
    Nobody

    As a person is a simple element, not a list.


    Can I use one for each element? And what next?

    Thank you.

    http://download.Oracle.com/docs/CD/E12483_01/integrate.1013/b28981/manipdoc.htm#BABCHBFB
    http://clemensblog.blogspot.com/2006/03/BPEL-looping-over-arrays-Collections.html
    http://oraclebpelindepth.blogspot.com/2008/09/arrays-in-bpel_21.html

    Indeed, you need for each and loop over each item in the person in

    in the loop, you can call the other service with the input of the corresponding person-element-data data

    person [1] / name
    [2] person / name

    etc.

Maybe you are looking for