Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > Oracle Database

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-24-2008, 10:01 AM
mark.fergel@bankofamerica.com
 
Posts: n/a
Default Following code works on one database but not another

We have a development and production oracle database. The following
code works on the development database but not on the production
database. If I replace the date variable with a hardcoded date, it
works fine. Something in the I_STDT is causing a problem. Is there a
problem with my code is there a possible difference in the databases?

-- Training Days


CREATE OR REPLACE PACKAGE PG_TRDAYS AS
TYPE cdcur IS REF CURSOR;
PROCEDURE SP_TRDAYS(TandO OUT cdcur, I_RORG IN VARCHAR2, I_STDT IN
VARCHAR2);
END PG_TRDAYS;
/

CREATE OR REPLACE PACKAGE BODY PG_TRDAYS AS
PROCEDURE SP_TRDAYS(TandO OUT cdcur, I_RORG IN VARCHAR2, I_STDT IN
VARCHAR2) IS

v_hiercd cdcur;

BEGIN

OPEN v_hiercd FOR

SELECT
CRSE.CRSE_TTL "Course Title",
CRSE_SESSION.ATTENDEE_NUM_CT "Num. Attend",
CRSE.DAYS_IN_CLASS "Days in Class",
CRSE_SESSION.END_DT "End Date",
UPPER(HIER.TTL) "Organization",
LOOKUP_STRINGS.TTL "Locations",
CRSE_SESSION.SITE_CD "Site Code",
CRSE_SESSION.CRSE_SESSION_STATUS_CD "Session Status",
UPPER(CRSE.LOCAL_CRSE_PREFIX_CD) || UPPER(CRSE.LOCAL_CRSE_CD) "Course
Code"
FROM
CRSE CRSE,
CRSE_SESSION CRSE_SESSION,
HIER HIER,
LOOKUP_STRINGS LOOKUP_STRINGS,
(SELECT STRING_CD, VALUE_CD FROM LOOKUP WHERE CD=25) LOOKUP
WHERE
CRSE.CRSE_CD=CRSE_SESSION.CRSE_CD
AND
CRSE.SESSION_PROVIDER_CD=HIER.CD (+)
AND
CRSE_SESSION.SITE_CD=LOOKUP.VALUE_CD (+)
AND
LOOKUP.STRING_CD=LOOKUP_STRINGS.STRING_CD (+)
AND
CRSE_SESSION.END_DT IS NOT NULL
AND
CRSE_SESSION.ATTENDEE_NUM_CT>0
AND
CRSE_SESSION.CRSE_SESSION_STATUS_CD='O'
AND
UPPER(HIER.TTL) LIKE UPPER(I_RORG) || '%'
AND
CRSE_SESSION.END_DT BETWEEN TO_DATE(I_STDT, 'MM/DD/YYYY') AND SYSDATE

ORDER BY HIER.TTL, LOOKUP_STRINGS.TTL;
TandO := v_hiercd;

END SP_TRDAYS;

END PG_TRDAYS;

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-24-2008, 10:01 AM
hpuxrac
 
Posts: n/a
Default Re: Following code works on one database but not another

snip

> works fine. Something in the I_STDT is causing a problem. Is there

a
> problem with my code is there a possible difference in the databases?


The oracle supplied routines in the package dbms_output or perhaps
utl_file can be used here, try putting in some debugging in both places
and narrow down where your problem lies.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-24-2008, 10:01 AM
mark.fergel@bankofamerica.com
 
Posts: n/a
Default Re: Following code works on one database but not another

Gotta be honest, at this point, I barely understand Oracle let along
how to do a debug. I've tried getting a straight answer from the dba
as to why the code works on one database and not the other, but they've
been less than helpful.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-24-2008, 10:01 AM
Sybrand Bakker
 
Posts: n/a
Default Re: Following code works on one database but not another

On 3 Jan 2005 12:43:36 -0800, mark.fergel@bankofamerica.com wrote:

>If I replace the date variable with a hardcoded date, it
>works fine. Something in the I_STDT is causing a problem. Is there a
>problem with my code is there a possible difference in the databases?


Sorry to say so, but your post is very imprecise.
What does 'doesn't work' exactly mean?
Why is the formal parameter i_stdt a varchar2 instead of a date? (What
it should have been in the first place).

One obvious source for problems is your actual parameter (when you
call the procedure) is a varchar2 too, and isn't in the same format as
the 'MM/DD/YYYY' format you seem to expect.
Did you assure the nls_date_format setting (and/or the nls_territory
setting) for both databases is the same?
please run select * from nls_session_parameters on both databases and
compare the results.

Hth


--
Sybrand Bakker, Senior Oracle DBA
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-24-2008, 10:02 AM
DA Morgan
 
Posts: n/a
Default Re: Following code works on one database but not another

mark.fergel@bankofamerica.com wrote:

> We have a development and production oracle database. The following
> code works on the development database but not on the production
> database. If I replace the date variable with a hardcoded date, it
> works fine. Something in the I_STDT is causing a problem. Is there a
> problem with my code is there a possible difference in the databases?
>
> -- Training Days
>
>
> CREATE OR REPLACE PACKAGE PG_TRDAYS AS
> TYPE cdcur IS REF CURSOR;
> PROCEDURE SP_TRDAYS(TandO OUT cdcur, I_RORG IN VARCHAR2, I_STDT IN
> VARCHAR2);
> END PG_TRDAYS;
> /
>
> CREATE OR REPLACE PACKAGE BODY PG_TRDAYS AS
> PROCEDURE SP_TRDAYS(TandO OUT cdcur, I_RORG IN VARCHAR2, I_STDT IN
> VARCHAR2) IS
>
> v_hiercd cdcur;
>
> BEGIN
>
> OPEN v_hiercd FOR
>
> SELECT
> CRSE.CRSE_TTL "Course Title",
> CRSE_SESSION.ATTENDEE_NUM_CT "Num. Attend",
> CRSE.DAYS_IN_CLASS "Days in Class",
> CRSE_SESSION.END_DT "End Date",
> UPPER(HIER.TTL) "Organization",
> LOOKUP_STRINGS.TTL "Locations",
> CRSE_SESSION.SITE_CD "Site Code",
> CRSE_SESSION.CRSE_SESSION_STATUS_CD "Session Status",
> UPPER(CRSE.LOCAL_CRSE_PREFIX_CD) || UPPER(CRSE.LOCAL_CRSE_CD) "Course
> Code"
> FROM
> CRSE CRSE,
> CRSE_SESSION CRSE_SESSION,
> HIER HIER,
> LOOKUP_STRINGS LOOKUP_STRINGS,
> (SELECT STRING_CD, VALUE_CD FROM LOOKUP WHERE CD=25) LOOKUP
> WHERE
> CRSE.CRSE_CD=CRSE_SESSION.CRSE_CD
> AND
> CRSE.SESSION_PROVIDER_CD=HIER.CD (+)
> AND
> CRSE_SESSION.SITE_CD=LOOKUP.VALUE_CD (+)
> AND
> LOOKUP.STRING_CD=LOOKUP_STRINGS.STRING_CD (+)
> AND
> CRSE_SESSION.END_DT IS NOT NULL
> AND
> CRSE_SESSION.ATTENDEE_NUM_CT>0
> AND
> CRSE_SESSION.CRSE_SESSION_STATUS_CD='O'
> AND
> UPPER(HIER.TTL) LIKE UPPER(I_RORG) || '%'
> AND
> CRSE_SESSION.END_DT BETWEEN TO_DATE(I_STDT, 'MM/DD/YYYY') AND SYSDATE
>
> ORDER BY HIER.TTL, LOOKUP_STRINGS.TTL;
> TandO := v_hiercd;
>
> END SP_TRDAYS;
>
> END PG_TRDAYS;


Just a couple of quick comments on your code. They won't solve
the immediate problem but ....

1. Why alias tables to themselves? It accomplishes nothing but
make your code harder to read.

2. You might want to consider bind variables in your WHERE clause

3. You must SELECT INTO in PL/SQL so I can't believe it works anywhere
in any database ... at least not an Oracle database.

No version, no error message, no specific help is possible. But I like
#3 for being the real problem.
--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace 'x' with 'u' to respond)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-24-2008, 10:02 AM
fitzjarrell@cox.net
 
Posts: n/a
Default Re: Following code works on one database but not another

Comments embedded.

DA Morgan wrote:
> mark.fergel@bankofamerica.com wrote:
>
> > We have a development and production oracle database. The

following
> > code works on the development database but not on the production
> > database. If I replace the date variable with a hardcoded date, it
> > works fine. Something in the I_STDT is causing a problem. Is

there a
> > problem with my code is there a possible difference in the

databases?
> >
> > -- Training Days
> >
> >
> > CREATE OR REPLACE PACKAGE PG_TRDAYS AS
> > TYPE cdcur IS REF CURSOR;
> > PROCEDURE SP_TRDAYS(TandO OUT cdcur, I_RORG IN VARCHAR2, I_STDT IN
> > VARCHAR2);
> > END PG_TRDAYS;
> > /
> >
> > CREATE OR REPLACE PACKAGE BODY PG_TRDAYS AS
> > PROCEDURE SP_TRDAYS(TandO OUT cdcur, I_RORG IN VARCHAR2, I_STDT IN
> > VARCHAR2) IS
> >
> > v_hiercd cdcur;
> >
> > BEGIN
> >
> > OPEN v_hiercd FOR
> >
> > SELECT
> > CRSE.CRSE_TTL "Course Title",
> > CRSE_SESSION.ATTENDEE_NUM_CT "Num. Attend",
> > CRSE.DAYS_IN_CLASS "Days in Class",
> > CRSE_SESSION.END_DT "End Date",
> > UPPER(HIER.TTL) "Organization",
> > LOOKUP_STRINGS.TTL "Locations",
> > CRSE_SESSION.SITE_CD "Site Code",
> > CRSE_SESSION.CRSE_SESSION_STATUS_CD "Session Status",
> > UPPER(CRSE.LOCAL_CRSE_PREFIX_CD) || UPPER(CRSE.LOCAL_CRSE_CD)

"Course
> > Code"
> > FROM
> > CRSE CRSE,
> > CRSE_SESSION CRSE_SESSION,
> > HIER HIER,
> > LOOKUP_STRINGS LOOKUP_STRINGS,
> > (SELECT STRING_CD, VALUE_CD FROM LOOKUP WHERE CD=25) LOOKUP
> > WHERE
> > CRSE.CRSE_CD=CRSE_SESSION.CRSE_CD
> > AND
> > CRSE.SESSION_PROVIDER_CD=HIER.CD (+)
> > AND
> > CRSE_SESSION.SITE_CD=LOOKUP.VALUE_CD (+)
> > AND
> > LOOKUP.STRING_CD=LOOKUP_STRINGS.STRING_CD (+)
> > AND
> > CRSE_SESSION.END_DT IS NOT NULL
> > AND
> > CRSE_SESSION.ATTENDEE_NUM_CT>0
> > AND
> > CRSE_SESSION.CRSE_SESSION_STATUS_CD='O'
> > AND
> > UPPER(HIER.TTL) LIKE UPPER(I_RORG) || '%'
> > AND
> > CRSE_SESSION.END_DT BETWEEN TO_DATE(I_STDT, 'MM/DD/YYYY') AND

SYSDATE
> >
> > ORDER BY HIER.TTL, LOOKUP_STRINGS.TTL;
> > TandO := v_hiercd;
> >
> > END SP_TRDAYS;
> >
> > END PG_TRDAYS;

>
> Just a couple of quick comments on your code. They won't solve
> the immediate problem but ....
>
> 1. Why alias tables to themselves? It accomplishes nothing but
> make your code harder to read.
>
> 2. You might want to consider bind variables in your WHERE clause
>
> 3. You must SELECT INTO in PL/SQL so I can't believe it works

anywhere
> in any database ... at least not an Oracle database.
>


Not with the OPEN <cursorname> FOR syntax, which is what he's written.
This works quite well. Had he not opened a cursor for the select I
would have agreed.

> No version, no error message, no specific help is possible. But I

like
> #3 for being the real problem.
> --
> Daniel A. Morgan
> University of Washington
> damorgan@x.washington.edu
> (replace 'x' with 'u' to respond)


My thoughts tend to side with Sybrand Bakker; I_STDT should be a DATE,
not a VARCHAR2, or TO_DATE() should be used to convert the value with a
constant date mask. It would appear, as Sybrand has already stated,
that the OP is expecting the same default date format between
databases, something one shouldn't be expecting. Using TO_DATE() or
declaring I_STDT as a DATE would probably clear up the entire issue, or
at least throw an error for an improperly formatted date string.
David Fitzjarrell

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-24-2008, 10:02 AM
fitzjarrell@cox.net
 
Posts: n/a
Default Re: Following code works on one database but not another

Comments embedded.

DA Morgan wrote:
> mark.fergel@bankofamerica.com wrote:
>
> > We have a development and production oracle database. The

following
> > code works on the development database but not on the production
> > database. If I replace the date variable with a hardcoded date, it
> > works fine. Something in the I_STDT is causing a problem. Is

there a
> > problem with my code is there a possible difference in the

databases?
> >
> > -- Training Days
> >
> >
> > CREATE OR REPLACE PACKAGE PG_TRDAYS AS
> > TYPE cdcur IS REF CURSOR;
> > PROCEDURE SP_TRDAYS(TandO OUT cdcur, I_RORG IN VARCHAR2, I_STDT IN
> > VARCHAR2);
> > END PG_TRDAYS;
> > /
> >
> > CREATE OR REPLACE PACKAGE BODY PG_TRDAYS AS
> > PROCEDURE SP_TRDAYS(TandO OUT cdcur, I_RORG IN VARCHAR2, I_STDT IN
> > VARCHAR2) IS
> >
> > v_hiercd cdcur;
> >
> > BEGIN
> >
> > OPEN v_hiercd FOR
> >
> > SELECT
> > CRSE.CRSE_TTL "Course Title",
> > CRSE_SESSION.ATTENDEE_NUM_CT "Num. Attend",
> > CRSE.DAYS_IN_CLASS "Days in Class",
> > CRSE_SESSION.END_DT "End Date",
> > UPPER(HIER.TTL) "Organization",
> > LOOKUP_STRINGS.TTL "Locations",
> > CRSE_SESSION.SITE_CD "Site Code",
> > CRSE_SESSION.CRSE_SESSION_STATUS_CD "Session Status",
> > UPPER(CRSE.LOCAL_CRSE_PREFIX_CD) || UPPER(CRSE.LOCAL_CRSE_CD)

"Course
> > Code"
> > FROM
> > CRSE CRSE,
> > CRSE_SESSION CRSE_SESSION,
> > HIER HIER,
> > LOOKUP_STRINGS LOOKUP_STRINGS,
> > (SELECT STRING_CD, VALUE_CD FROM LOOKUP WHERE CD=25) LOOKUP
> > WHERE
> > CRSE.CRSE_CD=CRSE_SESSION.CRSE_CD
> > AND
> > CRSE.SESSION_PROVIDER_CD=HIER.CD (+)
> > AND
> > CRSE_SESSION.SITE_CD=LOOKUP.VALUE_CD (+)
> > AND
> > LOOKUP.STRING_CD=LOOKUP_STRINGS.STRING_CD (+)
> > AND
> > CRSE_SESSION.END_DT IS NOT NULL
> > AND
> > CRSE_SESSION.ATTENDEE_NUM_CT>0
> > AND
> > CRSE_SESSION.CRSE_SESSION_STATUS_CD='O'
> > AND
> > UPPER(HIER.TTL) LIKE UPPER(I_RORG) || '%'
> > AND
> > CRSE_SESSION.END_DT BETWEEN TO_DATE(I_STDT, 'MM/DD/YYYY') AND

SYSDATE
> >
> > ORDER BY HIER.TTL, LOOKUP_STRINGS.TTL;
> > TandO := v_hiercd;
> >
> > END SP_TRDAYS;
> >
> > END PG_TRDAYS;

>
> Just a couple of quick comments on your code. They won't solve
> the immediate problem but ....
>
> 1. Why alias tables to themselves? It accomplishes nothing but
> make your code harder to read.
>
> 2. You might want to consider bind variables in your WHERE clause
>
> 3. You must SELECT INTO in PL/SQL so I can't believe it works

anywhere
> in any database ... at least not an Oracle database.
>


Not with the OPEN <cursorname> FOR syntax, which is what he's written.
This works quite well. Had he not opened a cursor for the select I
would have agreed.

> No version, no error message, no specific help is possible. But I

like
> #3 for being the real problem.
> --
> Daniel A. Morgan
> University of Washington
> damorgan@x.washington.edu
> (replace 'x' with 'u' to respond)


My thoughts tend to side with Sybrand Bakker; I_STDT should be a DATE,
not a VARCHAR2, or TO_DATE() should be used to convert the value with a
constant date mask. It would appear, as Sybrand has already stated,
that the OP is expecting the same default date format between
databases, something one shouldn't be expecting. Using TO_DATE() or
declaring I_STDT as a DATE would probably clear up the entire issue, or
at least throw an error for an improperly formatted date string.
David Fitzjarrell

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 02-24-2008, 10:03 AM
mark.fergel@bankofamerica.com
 
Posts: n/a
Default Re: Following code works on one database but not another

I ran nls_session_parameters on both databases and they came back with
the exact same info:

PARAMETER VALUE
------------------------------ ----------------------------------------
NLS_LANGUAGE AMERICAN
NLS_TERRITORY AMERICA
NLS_CURRENCY $
NLS_ISO_CURRENCY AMERICA
NLS_NUMERIC_CHARACTERS .,
NLS_CALENDAR GREGORIAN
NLS_DATE_FORMAT DD-MON-RR
NLS_DATE_LANGUAGE AMERICAN
NLS_SORT BINARY
NLS_TIME_FORMAT HH.MI.SSXFF AM
NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
NLS_DUAL_CURRENCY $
NLS_COMP BINARY
NLS_LENGTH_SEMANTICS BYTE
NLS_NCHAR_CONV_EXCP FALSE

My biggest reason for having the to_char on the date is that the
package is based on the packages created by the adminstrative group.
While I'm not positive, I believe it is being done because the package
is used in the creation of a crystal report and then accessed (with
parameters passed) via an ASP page.

My issue with it not working is that when I try and create a crystal
report against the package, it works fine in development but production
is throwing me an empty rowset error and not bring in the tables. I've
verified that there data exists for the values I am trying to pass by
hard coding in the dates. What doesn't work is that even though I've
hard coded the dates, etc., if I try to write the report against that
(which I know has records), it still comes back with the empty rowset
error.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 02-24-2008, 10:03 AM
mark.fergel@bankofamerica.com
 
Posts: n/a
Default Re: Following code works on one database but not another

I did switch the I_STDT IN VARCHAR2 to DATE instead. Doing so does
work. I tried various combinations that I can get to work. I really
would prefer in Crystal to be able to type my date string out as
01/01/2004, which was the format I had specified. By changing it to
DATE, Crystal automatically engages it's mini calendar instead of the
string parameter box.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 02-24-2008, 10:04 AM
DA Morgan
 
Posts: n/a
Default Re: Following code works on one database but not another

fitzjarrell@cox.net wrote:

> Not with the OPEN <cursorname> FOR syntax, which is what he's written.
> This works quite well. Had he not opened a cursor for the select I
> would have agreed.


Darn! Missed that. Thanks for pointing it out.

--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace 'x' with 'u' to respond)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:20 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
UnixAdminTalk.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493