using the date of today as default for this function in the package

Hello all;

Please find attached the sample data and syntax
create table tbl_one
(
  id varchar2(200),
  place varchar2(300),
  create_date date
);

insert into tbl_one
  (id, place, create_date)
values
  ('D', 'MN', to_date('3/3/2011', 'MM/DD/YYYY'));


insert into tbl_one
  (id, place, create_date)
values
  ('X', 'DC', to_date('3/4/2011', 'MM/DD/YYYY'));
  

insert into tbl_one
  (id, place, create_date)
values
  ('A', 'NY', to_date('3/31/2011', 'MM/DD/YYYY'));
PL/SQL Developer package
 body ----------

create or replace package P_test is
 
  -- Public type declarations
type cur is ref cursor;
function test_fn
(
 from_period in varchar2,
 to_period in varchar2
) return cur;

end P_test;

spec ----------------------

create or replace package body P_test is

function test_fn
(
 from_period in varchar2,
 to_period in varchar2
) return cur as

my_cur cur;
Begin
  open my_cur for 
  
  select p.id,
         p.place 
  from tbl_one p
  where trunc(p.create_date) >= to_date(from_period, 'MM-DD-YYYY')
  and trunc(p.create_date) <= to_date(to_period, 'MM-DD-YYYY');
return my_cur;
end test_fn;

end P_test;
now, I'm just wondering how to make the to_period to have a default value of today's date

user13328581 wrote:
I've tried, but it does not work it shows unfortunately no display... the only other way I can think is to use multiple if statement to check and then make a select in... but I just feel it is a better way to do.

Published by: user13328581 on March 31, 2011 13:09

It does not define it.

SQL> CREATE PROCEDURE dt_test (p_start_dt IN VARCHAR2,
  2                            p_end_dt   IN VARCHAR2 DEFAULT TO_CHAR(sysdate, 'MM-DD-YYYY')) AS
  3  BEGIN
  4     DBMS_OUTPUT.Put_Line ('Start is: '||p_start_dt);
  5     DBMS_OUTPUT.Put_Line ('End is: '||p_end_dt);
  6  END;
  7  /

Procedure created.

SQL> exec dt_test('01-01-2011', '02-28-2011');
Start is: 01-01-2011
End is: 02-28-2011

PL/SQL procedure successfully completed.

SQL> exec dt_test('01-01-2011');
Start is: 01-01-2011
End is: 03-31-2011

Or are you still passing two parameters with the possibly due date null like this:

SQL> exec dt_test('01-01-2011', null);
Start is: 01-01-2011
End is:

PL/SQL procedure successfully completed.

If you is the case then you can do something like:

SQL> CREATE OR REPLACE PROCEDURE dt_test (p_start_dt IN VARCHAR2,
  2                                       p_end_dt   IN VARCHAR2) AS
  3  BEGIN
  4     DBMS_OUTPUT.Put_Line ('Start is: '||p_start_dt);
  5     DBMS_OUTPUT.Put_Line ('End is: '||COALESCE(p_end_dt, sysdate));
  6  END;
  7  /

Procedure created.

SQL> exec dt_test('01-01-2011', null)
Start is: 01-01-2011
End is: 31-MAR-2011

PL/SQL procedure successfully completed.

If your predicate would become more like:

trunc(p.create_date) <= COALESCE(to_date(to_period, 'MM-DD-YYYY'), TRUNC(sysdate);

John

Tags: Database

Similar Questions

  • Member of the invalid Custom4 specified for this function

    Hello

    I use HFM 11.1.1.3 version. I've added new Member account and the Custom4TopMember as "Substitution" in the Member attribute. Override is a dimension of Custom4 and I two members under Override: USD & USDAdj.  When running consolidation, I get error "Invalid Custom4 member specified for this function".

    If <>pov_entity "[None]" AND pov_value = "Currency Entity of <>" then


    HS = DestCurs. Custom4.list ("override", "[base]")
    HS = HistAccts. Account.List ("OVERRIDES", "[Basic]")

    For i = LBound (HistAccts) to UBound (HistAccts)
    HAcct = HistAccts (i)
    DestA = Right (HAcct, Len (Hacct) - 2)

    For y = LBound (DestCurs) to UBound (DestCurs)
    DestCur = DestCurs (y)

    I am getting error on the syntax - DestCur = DestCurs (y). Please can you help me solve this problem. When I tried to print the value of DestCur, only USD value is printed and the USDAdj is not printing.

    Thank you

    Michel K

    Hello

    I am able to solve the problem. I can't explain everything in the thread. Because according to the requirement of the enterprise, I define the properties and problems solved. The new Member account overrides the value of the existing account member. For example: the newest member is X_1000. The existing Member is 1000. I changed the attribute Custom4TopMember from 1000 to CTA_STAT and run the consolidation. Now it works fine.

    Thank you

    Michel K

  • If I subscribe to the applications Adobe CC everyone (students and teachers), how many computers can I use the package on?

    If I subscribe to the applications Adobe CC all (students and teachers).

    How many computers can I use the package?

    Please check the FAQ - Licensing FAQ: can I install Creative Cloud on several computers?

    Thank you

    Bev

  • When we use the package start the game?

    Guys, I would like to know when we use this part of the package. I mean, because start part runs only those and never running again in this session. So why we use this part?
    create or replace
    package body my_pack
    is
      num number;
      str varchar2(50);
    begin
    
      So when should we use this part of packages?????
    
      dbms_output.put_line(Why we use this part??????');
    
    end;
    Thank you

    Hello

    I use this section to initialize variables, global temporary tables and package SYS_CONTEXT variables. If there is information stored in regular tables which I am sure you need when you use the package, I could query the tables once, when I all call the package first and save the results in variables SYS_CONTEXT or package, or global temporary tables, where I can get results quickly and easily.

    Most packages you use probably not need this item.

  • 'Invalid destination specified for this function' (HFM rules)

    Hello

    I'm stuck with an expression of the simple rule, and I get the following error:

    Invalid destination specified for this function: a #A39725. E #E051_OVAxxx.I #[ICP None]. C1 #S101_000.C2 #L980. C3 #GuarReclassNCI.C4 #EndBal.V # < entity motto >. W #YTD.

    Here's the complete rule:

    If povScenario = 'Act' and povYear > 2011 Then

    vBS_Guar_Tar = '. '. I have #[ICP no]. C1 #S101_000.C2 #L980. C3 #GuarReclassNCI.C4 #EndBal.V # < entity motto >. W #YTD ".

    vBS_Guar_Src = '. '. I have #[high PEAK]. C1 #TotalC1.C2 #TotalC2.C3 #UsGAAP_Alloc.C4 #TotalC4.V # < entity Curr Total >. W #YTD ".

    'Guarantor check - Reclass NCI

    Hs.Exp ' a #A39725.» E #E051_OVAxxx"& vBS_Guar_Tar &" = a #A39725.» E #OVA *-1 '& vBS_Guar_Src '.

    Hs.Exp 'a #ME. E #E051_OVAxxx"& vBS_Guar_Tar &" = a #A39725.» E #OVA *-1 '& vBS_Guar_Src '.

    End If ' if povScenario = 'Act' and povYear > 2011 Then

    Clues as to why it does not work?

    Thank you!

    Entity (with dimensions scenario, year, length and value) may not be specified on the left side of a HS. Equation of the exp.  These dimensions are considered in the calculation/consolidation "block" and are determined by the current point of view.

    If you want this logic runs only on specific entities, and you have more than one, I suggest to use a UDA on the entity.  Then you can do something like (written in pseudocode):

    If the entity currenty uda is RECLASSNCI then

  • Can I use the package of photography for my business?

    I have a question. Can I use the beam of photography (listed here: en Photoshop Lightroom |) Adobe Creative Cloud Fotografielidmaatschap ) for my own business?

    providing you pay the monthly subscription you can use in all cases please. The only condition is that it is loaded on not more than two computers per subscription, and only one of these computers is used at a given time.

  • Help with fft vibrations without using the package of noise and vibrations

    I'm looking for help in the analysis of vibrations. I use an example updated NI 9233 VI, to get a signal from the accelerometer for display using a FFT power spectrum. I'm not entirely sure if it works, because it's the first time I've ever done vibration analysis on LabView. So if you could explain a thing or two about vibrations or TFF, I'd be more than willing to hear from you. I have included my code along with a photo of an analysis of vibration of the computer, I work with. (even when I don't know if his work that I just thought it would be good to show an output)

    Brandon

    Data sheet:

    I have LabView 2011

    I FPGA, real-time

    I have a model of research of Wilcoxon accelerometer 797-33

    With an NI 9233

    On a cRio-9012

    Hi Brandon,.

    You can use the FFT Complex (photo attached) to calculate the magnitude of the acceleration at different frequencies. You will need to take a little further to build a new waveform with this release, which includes d0, df and the output of the FFT. In order to calculate the df, please refer to the user manual on page 10-3. With respect to the scale that is output by the FFT, it must be same as input. Hope this helps to answer your questions. Thank you!

    See you soon,.

    CARISA Leal

  • "I use CS2 in Windows XP sp2, 32-bit, interested in CS3 &amp; tried to download &amp; install, giving message" "code error 1720" problem with a script required for this installation and windows package install ".

    Currently I am interested in CS3 & CS2 user, so I doenloaded CS3 but gives the time installation message "Error 1720, there is a problem with this windows package install." A script is required for this installation to complete, contact technical support.

    Google search for help with the problem of Windows...

    https://www.Google.com/search?q=Error+1720&SourceID=IE7&RLS=com.Microsoft: en - US: IE - address & ie = & oe = & gws_rd = ssl

  • Can I use the packages with compilation errors

    Hello

    I try to use procedures in a package that includes compilation errors. I wonder whether the remaining procedures within this package is usable or not?

    Or is there a way to only compile the correct procedure within this package?

    Thank you very much

    Murat

    user13795669 wrote:
    Not even Possible, I use execute commands as below

    run immediately "@/ var/mcp/loadUtlPkg.sql';" or with another way?

    No, you can not use as you wrote.
    @ - is a special, synonymous with start , sign command SQL * more.
    You cannot use it with the PL/SQL constructor.

    The only way that you can use the body to package not valid with valid package spec - compile another package, dependent on the subject. Not running - compile.

  • using the package DBMS_CRYPTO in reports

    Hi all

    I want to encrypt and decrypt the parameter used in the report.

    to encrypt that I use;
    l_encrypted_raw: = dbms_crypto.encrypt (src = > my_parameter,)
    Typ = > dbms_crypto.des_cbc_pkcs5, key = > l_key);

    to decipher;
    l_decrypted_raw: = dbms_crypto.decrypt (src = > l_encrypted_raw,)
    Typ = > dbms_crypto.des_cbc_pkcs5, key = > l_key);

    in sql developer, these codes are running. I can encrypt and decrypt
    but when I want to decrypt in the reports, it gives an error like this:

    restriction of implementing: ' DBMS_CRYPTO. DES_CBC_PKCS5': cannot directly access the slider or the package variable remote

    How can I convey this?
    Thank you...

    Hello

    You must create a "wrapper" function

    Create a function in the database that calls dbms_crypto.encrypt / dbms_crypto.decrypt and call this function in reports.

    (Here, the problem seems to be the reference to dbms_crypto.des_cbc_pkcs5)

    Concerning

  • Using the package Photography - Photoshop Lightroom problem

    Hello Adobe Community,

    I have to pay a monthly subscription for all photography and I adobe applications like photoshop and Lightroom 6 I used on my laptop without a problem until 2 days ago, but now my phone is completely dead. I have a windows Tablet and that you have installed applications. My problem/question is, I tried to open the Lightroom Catalog. How do I get 6 Lightroom on the Tablet I can get with my editing. It is v5.7.1 the latest version on my tablet at the moment. My deadline to the Faculty is a week away!

    Thanks if read you and respond to my question. Any help appreciated.

    Download & install instructions https://forums.adobe.com/thread/2003339 can help

    -includes a way to go to a page to download the Adobe programs if you do not have a disk or drive

    -you will need to enter your original serial number during the installation for non-Cloud programs

    -Cloud desktop http://helpx.adobe.com/creative-cloud/help/creative-cloud-desktop.html

    -Cloud Getting Started https://helpx.adobe.com/creative-cloud.html

    - or kglad links in response to #1 here can help https://forums.adobe.com/thread/2081216

    Also go to https://forums.adobe.com/community/creative_cloud/creative_cloud_faq

  • HP Pavilion dv7-4080us is not using the default f, how to change keys?

    Hey all,.

    in windows 7 64 I try to use the f keys but he used as volume and light by default. for the f keys, I need to push the func key.

    I want to use as keys f by defauls, how to change?

    Thank you

    Thank you very much. It's worked.

  • Does anyone have an example VI for using the SendInput function in User32.dll?

    Hi all

    I am creating a VI that creates a click of the mouse.  I looked at the MSDN Web site and found that I need to use the SendInput function in User32.dll.  The problem is that some of the parameters for this function are nested structures.  How to use this function in a call library function node?  Is there already a LabVIEW wrapper for this function?

    Thank you

    MechEman

    I would use rather MouseEvent.  I looked at my VI and it can be cleaned up a bit, but it works for what you want to do.

  • Flash website using the conversion (Greensock/Starling/Away3D libraries) to HTML5. Is there an efficient workflow for this kind of mass conversion?

    Hello!

    I read that demoralize him articles everywhere on the great navigators pushing Flash to the side and supporting the HTML5 for awhile now. I have a personal site that I keep and put a decent amount of work using the design. At the heart of the site is driven by external classfiles AS3 using Greensock libraries. Also, I went 3D with 2D content content using the Framework Starling and Away3D libraries. I am researching the possibilities of creating the same types of drawings in HTML5, if possible. Greensock already fully supports HTML5 with its new libraries GSAP. Starling and Away3D I'm not so sure...

    I would love to continue to grow in the same method, using FlashCC, but this is already limited to only desktop browsers. That's fine with me, if it remains bearable on workstations, but at this point I don't really know how well supported Flash will remain same in desktop browsers. I must admit that my real job keeps me pretty busy that my search time is quite limited, so I might be way off the coast.

    Is there any known and efficient workflow for the transition from a site that only uses external AS3 classFiles and 2D or 3D to the HTML5 canvas content? Is this even worth it if I'm comfortable with only to have the support of desktop browser? It seems to me that, at least in the office environment, Flash will retain a strong foot.

    I use the package full creative suite + FlashDevelop as my toolkit and have been reading upward on the discussion of FlashCC targeting HTML5 canvas. It's really interesting to me, but at the same time it seems to work with SWF movies which contain all their ActionScript. It is not the structure that I followed at all, and it wouldn't really work-able at the port just the classFiles external back into SWF movies since not all the .as files has a SWF that is directly related. In other words, I wonder if it is still possible for me to consider a transitional workflow to HTML5 canvas? It seems at some point I might have to bite the bullet and refactor everything from the beginning, which I must admit is not an appetizing idea.

    I just want to start a discussion with Adobe and other creators out there using entirely external .as files and juggle several libraries in their Flash projects for the future. I want to see what workflows are out there to conquer this kind of problem and if supported in the desktop browser environment is even really a problem.

    -Cheers and sorry for the wall of text

    I think you should read more and worry less. Microsoft include Flash Player in IE and Edge. Google include Flash player in Chrome. Firefox Announces recently committed to the development of a Flash plugin, even if they cease to support other plugins. I don't think that Apple will stop supporting plugins at all.

    Thus, all current users of your will see your site for at least the next few years.

  • Can I use the data dictionary tables based on RLS policy?

    Hello guys, I use the package level security line to limit certain lines to some users.

    I created several roles, I want to just enable certain roles to see all the columns, but the other roles, I'm not that they see all the lines. I mean to do this I use the session_roles table data dictionary however it did not work.

    What to do in order to not allow rows of user roles?
    Can I use the data dictionary tables in RLS?


    Thank you very much.

    Polat says:
    What to do in order to not allow rows of user roles?
    Can I use the data dictionary tables in RLS?

    Ensure that:

    SQL> CREATE OR REPLACE
      2    FUNCTION no_sal_access(
      3                           p_owner IN VARCHAR2,
      4                           p_name IN VARCHAR2
      5                          )
      6      RETURN VARCHAR2 AS
      7      BEGIN
      8          RETURN '''NO_SAL_ACCESS'' NOT IN (SELECT * FROM SESSION_ROLES)';
      9  END;
     10  /
    
    Function created.
    
    SQL> BEGIN
      2    DBMS_RLS.ADD_POLICY (
      3                         object_schema         => 'scott',
      4                         object_name           => 'emp',
      5                         policy_name           => 'no_sal_access',
      6                         function_schema       => 'scott',
      7                         policy_function       => 'no_sal_access',
      8                         policy_type           => DBMS_RLS.STATIC,
      9                         sec_relevant_cols     => 'sal',
     10                         sec_relevant_cols_opt => DBMS_RLS.ALL_ROWS);
     11  END;
     12  /
    
    PL/SQL procedure successfully completed.
    
    SQL> GRANT EXECUTE ON no_sal_access TO PUBLIC
      2  /
    
    Grant succeeded.
    
    SQL> CREATE ROLE NO_SAL_ACCESS
      2  /
    
    Role created.
    
    SQL> GRANT SELECT ON EMP TO U1
      2  /
    
    Grant succeeded.
    
    SQL> CONNECT u1@orcl/u1
    Connected.
    SQL> select ename,sal FROM scott.emp
      2  /
    
    ENAME             SAL
    ---------- ----------
    SMITH             800
    ALLEN            1600
    WARD             1250
    JONES            2975
    MARTIN           1250
    BLAKE            2850
    CLARK            2450
    SCOTT            3000
    KING             5000
    TURNER           1500
    ADAMS            1100
    
    ENAME             SAL
    ---------- ----------
    JAMES             950
    FORD             3000
    MILLER           1300
    
    14 rows selected.
    
    SQL> connect scott@orcl
    Enter password: *****
    Connected.
    SQL> GRANT NO_SAL_ACCESS TO U1
      2  /
    
    Grant succeeded.
    
    SQL> connect u1@orcl/u1
    Connected.
    SQL> select ename,sal FROM scott.emp
      2  /
    
    ENAME             SAL
    ---------- ----------
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    
    ENAME             SAL
    ---------- ----------
    JAMES
    FORD
    MILLER
    
    14 rows selected.
    
    SQL> 
    

    SY.

Maybe you are looking for