using the function - how to use the values of the input variables on the table select statement names

Hello community, I have a problem when creating a function. The purpose of this function is to check the table of weather gave yesterday or not. We must check this on different tables on different sachems. We are creating a function with input variables.



in_schema IN VARCHAR2,

in_tablename IN VARCHAR2,

in_datefield IN VARCHAR2,




-Declaring variables

v_is_true INTEGER.




WHEN MAX (in_datefield) = TRUNC(SYSDATE-1)










RETURN v_is_true;



When creating, I got error: [error] ORA-00942 (44:19): PL/SQL: ORA-00942: table or view does not exist

How to use the values of the input variables on the table select statement names?


Here's a way you can use dynamic SQL statements for this task:



in_schema IN VARCHAR2,

in_tablename IN VARCHAR2,

in_datefield IN VARCHAR2,

in_first_date DATE DEFAULT SYSDATE - 1,.

in_last_date DATE by DEFAULT NULL




-IS_YDAYDATA_TO_TABLE returns 1 if in_schema.in_tablename.in_datefield

-contains all the dates in the in_first_date of the range through included in_last_date

- and it returns 0 if there is no such lines.

-If in_last_date is omitted, the search only the data on in_first_date.

-If in_first_date is omitted, it defaults to yesterday.

-Time parts of the in_first_date and in_last_date are ignored.

-Declaring variables

sql_txt VARCHAR2 (1000);

v_is_true INTEGER.


sql_txt: = 'SELECT COUNT (*).

|| 'FROM ' | in_schema | '.' || in_tablename

|| 'WHERE ' | in_datefield | ' > =: d1'

|| «AND» | in_datefield | '< >

|| 'AND ROWNUM = 1';

dbms_output.put_line (sql_txt |) '= sql_txt in IS_YDAYDATA_TO_TABLE");  -For debugging


IN v_is_true

With the HELP of TRUNC (in_first_date) - d1

TRUNC (NVL (in_last_date



) + 1                -- d2


RETURN v_is_true;

END is_ydaydata_to_table;



If you must use dynamic SQL statements, put all the SQL statement in a single string variable, such as sql_txt in the example above.  In this way, you can easily see exactly what will be executed.  Comment out the call to dbms_output under test is completed.

Try to write functions that will address not only the question that you have now, but similar questions that you may have in the future.  For example, now that interest you only to the verification of the data of yesterday, but later, you might want to check another day or range of days.  The above function combines the convenience of a function simple (looks like yesterday data if you don't tell him otherwise) with the power of a more complex function (you can use the same function to check any day or range of days).

Tags: Database

Similar Questions

  • What is the sql SELECT statement to list all service names in the database?

    What is the sql SELECT statement to list all service names in the database?

    I tried
    SELECT name FROM dba_services
    But a long with valid service, he list also some other documents that are not the names of services.


    You can try this query:

    select name, value from v$parameter where name = 'service_names';

    Hope this helps.
    Best regards
    Jean Valentine

  • How to model in OWB, if you have a subquery in your select statement? (11.2)

    What operator (ie the Table operator) to use if I have a subquery as part of my select statement? (As I do works, but is not elegant. What I do is to create a table for the subquery, and join with other sources to point to my goal.) But, would appreciate the best way with the characteristics of OWB.

    Here is the entire SQL (including the subquery):

    SELECT to_numbe (null), course_id
    at. Book, lp.NAME,
    (by selecting b.pricing in qp_pricing_attributes b
    where b.list_id = ll.list_id and b.product = at.product) sign.
    LL. Operand price, lhb.comments
    pricing_attribs to,.
    He's list_lines,
    list_h lp,
    Lhb Liste_B
    WHERE 1 = 1
    and ll.list_line_id = atrib.list_line_id
    AND ll.list_header_id = lp.list_header_id
    AND lp.list_header_id = lhb.list_header_id

    Thank you.


    Didn't need to be a table in the target. A very simple example, let's say you wanted to do the following:
    Select ename, (select dname dept d where d.deptno = e.deptno) of emp e

    Then DEPT is the table of your choice and EMP is your table of conduct.

    1. Add EMP on the canvas.
    2. Add to the search operator
    3 link research DEPT
    4. tap on finish
    5 card EMP. Department at the Dept. INGRP1 (search operator)
    6. change the search operator, on tab Lookup Conditions for lookup column DEPTNO and DEPTNO of entry attribute
    7. Search full now

    You can add to a table operator target and map of the EMP source table and attributes for release of the search operator. You can change the step 4 to complete the wizard and define the list of choices, but I chose to do 5, to automatically get the names and the data types of the inputs. There are many other options currently in GR 11, 2 in the search.

    Hope it makes sense.

    See you soon

  • How to use a value of a string variable as a sound (like an audio file link name) class?


    I need to use the value of a string variable as a binding name of any sound in the library, I have this code:

    var SoundArray:Array = new Array;
    SoundArray [0] = "S1";
    SoundArray [1] = 'S2 ';
    SoundArray [2] = "S3".
    var MySound = new SoundArray [0];
    B1.addEventListener (MouseEvent.Click, PlaySound);
    function PlaySound(event:MouseEvent) {} (0,0);

    where S1, S2, S3 is the name of the class in the name of link for 3 audio files in the library.

    I get this error for the line of code:

    TypeError: Error #1007: instantiation attempted on a non-constructeur.
    at Untitled_fla::MainTimeline/frame1()

    Sorry, sorry, sorry
    the error was not from your code, I had fixed and it is the right code:

    var soundClass = flash.utils.getDefinitionByName (this.) V_Source) as class;
    var currentlyPlayingSound = new soundClass();
    var currentSoundChannel = new Object;
    MovieClip (parent) [this. V_Button] .addEventListener (MouseEvent.Click, PlaySound);
    function PlaySound(event:MouseEvent) {}
    currentSoundChannel = ();

    Thank you very much

  • How to reset the table selection



    I displays a table with the unique selection of lines. The first line is selected by default. I would like to reset this selection, so no row is selected. I wrote that code but it does not work:

    RKS RowKeySet = table.getSelectedRowKeys (); ("RKS" + rks.getSize ());

    rks.removeAll (); ("RKS" + rks.getSize ());

    RKS. Clear(); ("RKS" + rks.getSize ());

    table.setSelectedRowKeys (rks);

    Whenever rks.getSize () returns the value 1. It seems the removeAll or clear do not work.

    I also try to the current line of the null value, but it does not work either.

    Thank you

    The first line is selected by default. I would like to reset this selection, so no row is selected.

    Well, components interface user are related to the default line set so they will always be 'select' some row.

    You can try to remove selectedRowKeys property of your table (so this should remove selection effect), but the iterator will probably continue to point to the first line in all lines.


  • How to set multiple values clustered with local variable?

    Hi all

    Okay, I made my way through Labview for everyone and have some basic concepts down. I can see with a cluster, if acting directly on it, you can ungroup, change values, rebundle, etc..

    I try something a little more complex... and just do not know how to start on this.

    I have a menu menu ring set. I created this with a typedef, with 4 values.  I used this typedef 7 times, more a few LED bool, in a cluster. I made this cluster a typedef.

    Therefore, in my main vi, I started designing, I put an example posted here... and inside, I have two instantiations of the typedef cluster commands selection of left and right.

    I dropped in this vi, a copy of the menu ring typedef (same typedef as in clusters, values) called reset all tubes.

    Now, I am trying to understand how, with an event to change the value to 'reset all the tubes'... that I can start with the left switch and change all tubes (here is the menu ring selector) to the same value as what has been selected with the ring of menu 'Reset all the tubes'.

    I created a local variable for the selector on the left. It is configured to read values. (I'll be doing the same thing with the right too, but just to start with the left).

    In the examples I've seen where access to a cluster, you could ungroup the cluster... browse and change the values... maybe pull out all the "hits" in a table and go through to update the values.  And when you group or ungroup the bunch... you can see the values, etc., when you stretch on the block diagram.

    With the local variable... I do not see to 'stretch' it as I expected... so I can access the values "tubes"... and all at the value of the 'reset all the tubes' ring menu value.

    Someone can put me on the path on the best way to do... or is it a component structure I'm missing here?  Am that I on the right track everything first here?

    It seems pretty basic to me, but miss me just something here on the way to start...

    Thank you in advance,


    You can't do this with a for loop of how the Department is structured, but why make it so complicated?  Just group the new value in the cluster, as shown below:

    If you do not want to use a loop for example, consider the restructuring of your cluster.  Group ring and a Boolean value in a cluster, and then unmold 7 of those in the cluster of selector.  Then you can use 'cluster to the table' and 'picture of cluster' for all elements of the external cluster will be of the same type.

    Also, be careful when using rings in the form of type definitions.  You probably want to use an enumeration instead.  The elements of a ring do not update the when you update the type definition because they are considered to be cosmetics. the elements of a definition of enumeration type update, because the elements of an enumeration are considered as part of the data type.

  • remove the table select row


    I'm trying to find a way to delete a selected line in a text file. You can find a classic text file that join this message.

    I first try to insert the text file in the command using node property value drop-down list box, but I see that the first line. I did the same thing with a command table and it works! Now, I need to select a row and delete it. I try to use the node property of the active cell, but I always get (0,0). Why? Someone knows how to do?

    Better idea to do the same task is also welcome.

    LabVIEW 8.5 windows XP

    Thank you


    Hi Francis,.

    You should try using the attribute SelStart to the table rather than the property of the Active cell.  Active cell is just used to set the active cell.  Here is a quick change that I made to your code that deletes the selected table row when you press the button Delete and resulting out of the table.  I hope that you should get pointed in the right direction.

  • before the "recalled" in the table selected lines

    12.1.3 JDEV

    It is difficult to explain the problem I see. So, I use a page to explain.

    I have a page with a few fields like these. The Magnifier is related to a taskFlowCall.


    When click on the magnifying glass, pilot field, a pop-up screen will appear. The user clicks on search and retrieve a few results. The user selects then a few lines of the output. Click OK to close the pop-up window and return the results selected to pilot field.


    Now, the user clicks the magnifying glass on the field of the expedition. a shortcut for sending screen. Search to retrieve a few lines. Notice: two rows on the result table are highlighted when the first returned search results. They seem to be selected, but not really. Now, if the user selects OK to return, the rows returned are empty. The table of results of research somehow 'remember' the previous index of the selected row.

    If the user selects the other lines of the search results table and click OK, the rows selected by the user are returned correctly.


    These windows two popup called the taskFlowCall even with different input parameter values.

    No idea how to solve this problem?

    Thank you.

    You can try to clear the selected rows from the table in your managed bean and run this code entering into the taskflow.

    RowKeySet ps = this.dynamicTable.getSelectedRowKeys();

    In addition, mention the similar question previously asked: remove highlighting from the selected line in the table

  • Loading data into the table by file name

    Hi all

    I am new to ODI. I have a requirement of loading a flat file in oracle, as well as the name of the file in a single column of the table. This means that, if there are 10 rows of data from this file, then the extra column "FileName" to the table will be the name of the active file written 10 times. Please suggest how this can be achieved. I am able to do half of it but the file name is not filled.

    Thank you.


    See the link below for dynamic fair value can be useful for you

    Thank you

  • Could not commit: ORA-00928: lack of creating the table SELECT keyword

    Hello guys.
    I tried to create the table with web interface on oracle 11g.

    I just follow this path on interface: schema-> table-> create-> standard (lot organized)-> SQl select on (set using the)->
    and I just use these scripts to create the table:

    CREATE TABLE suppliers
    (the number (10) of supplier_id not null,)
    supplier_name varchar2 (50) not null,
    Contact_Name varchar2 (50)

    but this error occurred: failed to commit: ORA-00928: lack of SELECT key word!
    Please lock on this picture for more information:

    could you help me please?
    and I could not find any manual for working with the web interface in oracle 11g.
    Please give me somesources to start.
    Thank you.

    1003778 wrote:
    Thank you sybrand_b
    but I already read this document.
    Unfortunately, there is nothing on the creation of table with sql scripts in this document!

    and I really don't understand how to create table with SQL commands! My question has not yet been answered.
    you please give me little details about it?
    for example, how can create table using this sql command:

    CREATE TABLE suppliers
    (the number (10) of supplier_id not null,)
    supplier_name varchar2 (50) not null,
    Contact_Name varchar2 (50)

    Thank you.

    Edited by: 1003778 may 3, 2013 11:43

    When you got to the CREATE TABLE screen, you have selected "set using the--> SQL.
    Did you notice in the window that appears, just above this entry field is this text: "enter a SQL * select * statement below.» ' + This query results will be used to fill the table with Canada.* + "(underlining)
    And hip, just to the left of this field is this text: «CREATE TABLE AS»

    He tries to build a ' CREATE TABLE AS SELECT... ». Creates a table with the same structure as the table in which you SELECT and fills with the results of this SELECT '. With your entry, you create a CREATE TABLE AS CREATE TABLE to read statement...

    If you want to create your tables with a simple CREATE TABLE command, go to sqlplus and do it. You want to have a graphical interface to help build a simple CREATE table, when you get to the CREATE TABLE page, just to stay there with the default "use Define-> column specification." If you want, after completing "build" your table specification here, you will have a "Show sql" option to show you the actual sql statement that will be executed to create your table.

  • Get the rank of the table selected in DialogOKAction

    I use JDeveloper

    In my example, I have a page fragment that includes a table reading with the button 'Add Row '. When the user clicks on the button 'Add Row', the following will occur:
    1. create the insertion occurs. The KP for this table is generated DB so that it is marked as not necessary in my model.
    2. a popup in windw dialogue form is created asking required data and not need to be completed.

    Now the user enters data and click on the OK button. The OK button calls a method that does the following.
    1 validates the data user and if OK we continue on another that I have send a message to the user to correct the data.
    2. the new line is posted. I must do this so that I can I hope to add value to the PK that is not created by the DB until the validation.

    I have 2 questions:
    1. I need to get this PK value so that I can write a record in a table of audit and also do something else with this value. I can't get that to work.
    2. After all other work, I want to return to the table with the new selected line. I can't get that to work either.

    I have attached the portion of my method in question below this 2 issues. 3 fault code lines are in bold. Could you please provide guidance as what I might want to try.

    BindingContainer lBindings = getBindings();

    now, I'm doing some validation before committing

    Validation of new line... must start now because the primary key is generated DB
    OperationBinding = lOperationBinding
    lBindings.getOperationBinding ("Commit");
    Object lResult = lOperationBinding.execute ();

    Download the new line
    DCIteratorBinding = lIteratorBindings
    (DCIteratorBinding) lBindings.get ("myTable1Iterator");
    ViewObject lVO = lIteratorBindings.getViewObject ();
    VORowImpl Lrowrequired = (VORowImpl) lVO.getCurrentRow ();

    Create and insert the Audit record
    RowIterator lAuditIterator = lRow.getAudit ();
    AuditVORowImpl = lAuditRow
    (AuditVORowImpl) lAuditIterator.createRow ();
    lAuditRow.setId (lRow.getId ()); _*
    set the other fields on the lAuditRow

    Validate the new line of verification
    lOperationBinding = lBindings.getOperationBinding ("Commit");
    lResult = lOperationBinding.execute ();

    refresh the VO
    DCIteratorBinding = lDciter
    (DCIteratorBinding) lBindings.get ("myTable1Iterator");
    Key lCurrentKey = lDciter.getCurrentRow () .getKey (); _*
    lDciter.executeQuery ();

    Define the new line created as the selected line in the table during update
    lDciter.setCurrentRowWithKey (lCurrentKey.toStringFormat (true)); _*

    refresh the page fragment "store Group view.
    AdfFacesContext.getCurrentInstance () .addPartialTarget (this.getTable ());

    I see two possible things to try.
    1. check the entity behind the new line and make the key attribute "update after inserting" to ensure that you get the key based on the sex of the db.
    2 use a sequence of db and you get the key before inserting the row into the db. Then you know the key.

    One last thing, you should check for errors after executing an operation...


  • Problem with the simple Select statements

    Hi experts,

    I have with SQL Server and I'm going to hurt when I use the similar syntax in sqlplus to query an Oracle table.

    For example... my table contains column SCHID SET in the numeric form. Table has thousands of lines and the SCHID column is filled.


    Get the "Word FROM key not found where expected" error


    Download "no selected lines.

    Can someone help me please?

    Thank you, John

    Can someone tell me how to find the names of the 20 largest tables (bigger which means that most of the files)?

    Once you have updated statistics on the table, you can query the DataDictionary: USER_TABLES/ALL_TABLES/DBA_TABLES.
    I'm assuming that user_tables will do:

    select *
    from ( select table_name
           ,      num_rows
           from   user_tables
           order by num_rows desc nulls last
    where rownum <= 20; 

    You can find more explanations about the DataDictionary in the Oracle Online Documentation.
    Just do a quick and easy search
    Depending on your version of the database.

  • With the help of inplace column number of the column name in the SQL Select statement

    Is it possible to execute instructions select sql with the number of columns in
    place names of columns?

    Run SQL
    select AddressId,Name,City from Address
    Is it possible
    select 1,2,5 from Address
    Thanks in advance

    You can extract the names of the columns for user_tab_columns

    SELECT Column_name
    FROM user_tab_columns
    where table_name = 'MY_TABLE'
    and Column_id in (1,2,5)

    Use dynamic SQL and then the result to get the values.

    But as others already mentioned, this wil it be given incorrect if your table is changed.

  • automatic refresh of the secondary table ADF on the main record in the table selection

    I use adf table for all master detail.
    My requiremant is as such when I select any master record its coresponding details should auto refresh in the secondary table
    PL. help if you have any solution for it.

    Thanks in advance.


    You use what version of jdeveloper?

    Why you cannot create the component master table table-details directly by drag and drop from the data control palette. If you want to continue cannot achieve this goal, and then set the property autosubmit to the option button in a master table to true. give the name of id in the table msater. And for the details table, set the property partialtrigger to the id of the main table.


  • name of the table of registered name

    Hi experts,
    I have a field name. I have hundreds of tables in
    my database. Can you please tell me how I can retrieve the name of the table of the domain name.




    SELECT table_name
     WHERE column_name = 'col_name';

Maybe you are looking for