Re: fun debugging stuff on a friday

  • From: Bradd Piontek <piontekdd@xxxxxxxxx>
  • To: TESTAJ3@xxxxxxxxxxxxxx
  • Date: Fri, 10 Apr 2009 09:50:44 -0500

What datatype in EFFECTIVE_DATE for the table SECURITY_DETAILS?
I'm guessing it is a VARCHAR2, which would explain why you get no rows back
in the first query.

Comparing VARCHAR2 to DATE can be problematic if you don't explicitly
convert one of the datatypes to the other.

Bradd Piontek
  "Next to doing a good job yourself,
        the greatest joy is in having someone
        else do a first-class job under your
        direction."
 -- William Feather


On Fri, Apr 10, 2009 at 9:47 AM, <TESTAJ3@xxxxxxxxxxxxxx> wrote:

>
> I get this code below, first glance says, this should work,   Oracle is so
> much like C, gives you a gun, ammo, takes off the safety and has the trigger
> most of the way pulled while pointing the gun at your foot and assists you
> in pulling the trigger the rest of the way.
>
>
>
>
> declare
> current_date date;
> ctr number;
>
> begin
>
> current_date:='30-OCT-07';
>
>
> SELECT count(distinct SECURITY_ALIAS)
> into ctr
> FROM DATAMARTDBO.SECURITY_DETAILS
> WHERE EFFECTIVE_DATE = current_date;
>
> dbms_output.put_line('CTR1:'||ctr);
>
>
>
> SELECT count(distinct SECURITY_ALIAS)
> into ctr
> FROM DATAMARTDBO.SECURITY_DETAILS
> WHERE EFFECTIVE_DATE = '30-OCT-07';
>
> dbms_output.put_line('CTR2:'||ctr);
>
> end;
> /
>
> CTR1: 0
> CTR2: 35178
>
>
> _______________________________________
> Joe Testa, Oracle Certified Professional
> Senior Consultant
> Data Engineering and Administration
> Nationwide Investments
>
> (Work) 614-677-1668
> (Cell) 614-312-6715
>
> Interested in helping out your marriage?
> Ask me about "Weekend to Remember"
> Dec 11-13, 2009 here in Columbus.
>

Other related posts: