Skip to Main Content

ORDS, SODA & JSON in the Database

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Nice URL's or DADs

SeBasTiaanSep 15 2010 — edited Sep 15 2010
Hi,

I was used to Oracle Apex embedded PL/SQL gateway, but since the Apex Listener, I use the listener.

I'm not exactly sure anymore how I've created nice url's to applications, it had something to do with dads (DBMS_EPG.create_dad etc.), but I've managed to create urls like this: http://servername/application

Does anyone know how to create those URL's in combination of the Apex Listener? I didn't install the embedded PL/SQL gateway because that's not neccecary with the listener.

Thanks!

Regards, Bas

Comments

cormaco

This is not related to your problem but you probably wanted to write hh:mi or even hh24:mi in your second format model.

However in your case the time part will always be zero.

mathguy

What kind of variable is :Effective_date?

Written with colon like you have, it would be a bind variable, and it should not be enclosed in single-quotes.

Did you mean to use a SUBSTITUTION variable, in SQL*Plus or something that understands substitution variables (like SQL Developer)? That may need to be in single quotes, but the notation is &Effective_date (with an ampersand, not a colon).

If Effective_date is not a variable at all, but the name of a column in a table, then it should appear as is (no colon, no ampersand), but not in single quotes.

After you fix this problem you will find at least one more: in the format model you can't just have hh. It should either be hh24 or hh... AM (it's 22:30 or 10:30 PM). And then a mistake that won't throw an error but will give you wrong results: you use mm for minutes; that should be mi,   mm means month.

RogerT

So the problem is not to_char (even if the result would not be what you are expecting) it is the to_date function.

So the questions you have to answer are:

  • what datatype is :effective_date ?
    • if it is a date then get rid of th to_date function
    • if it is a string then provide the correct format the date is stored in that string
  • what is the format of the result string you would like to have?
    • dd/mm/yyyy hh:mm means dayday/monthmonth/yearyearyearyear hour12hour12:monthmonth
  • what do you think will the time portion be, if it is not provided in the input?
Abhijit2610

effective date is in the format of dd/mm/yyyy

mathguy

The error the OP reported has nothing to do with any of the questions you suggest. (We may still need to come back and ask those questions; they are just unrelated to the OP's current error.)

As I pointed out in Reply 2:

The error he is getting is thrown by finding the literal string   ':Effective_date'  as the first character of TO_DATE. It's a string literal, because it is ENCLOSED IN SINGLE-QUOTES. Within single quotes, the leading colon has no particular meaning.  The single-quotes should be removed, and then let's see what else happens. Perhaps the OP's variable is already in the correct format.

mathguy

  

effective date is in the format of dd/mm/yyyy

Did you mean that as a reply to Roger T?   I didn't ask you anything about the format of the variable. I asked you about the kind of variable (bind variable vs. substitution variable).

chris227

Abhijit2610 wrote:


select to_char(to_date(':Effective_date', 'dd/mm/yyyy'), 'yyyy-mm-dd hh:mm') from dual

If you want to use Effective_date as a bind varaible just write :Effective_date without single quotes.

Abhijit2610

Below is the sql query and

:Effective_date = 01/01/2019 datatype varchar2

EFFECTIVEDTM = 2019-01-01 00:00

EXPIRATIONDTM = 2019-01-01 00:00

SELECT

   EXTPROCESSORNM

FROM EXTPROCESSOR PR

INNER JOIN EXTPROCSREMPMM PRA

    ON PR.EXTPROCESSORID = PRA.EXTPROCESSORID

INNER JOIN VP_EMPLOYEEV42 EMP

    ON PRA.EMPLOYEEID = EMP.EMPLOYEEID

WHERE PR.EXTPROCESSORDSC = 'Fixed Percent Allocation Employee Rule'

AND to_char(to_date(:EFFECTIVE_DATE, 'dd/mm/yyyy'), 'yyyy-mm-dd hh:mm')

BETWEEN EFFECTIVEDTM AND EXPIRATIONDTM

AND EMP.PERSONNUM = ':EMPLOYEE_ID'

AND ROWNUM = 1;

Solomon Yakobson

Are you saying EFFECTIVEDTM and EXPIRATIONDTM datatype is VARCHAR2? If so, you have serious design flaw. They should be defined as DATE.

Anyway, look at:

AND to_char(to_date(:EFFECTIVE_DATE, 'dd/mm/yyyy'), 'yyyy-mm-dd hh:mm')

Format mm is month while you are looking for mi - minutes:

AND to_char(to_date(:EFFECTIVE_DATE, 'dd/mm/yyyy'), 'yyyy-mm-dd hh:mi')

Another issue is hh which is 12 hour clock with AM/PM. Based on EFFECTIVEDTM and EXPIRATIONDTM values you need 24 hour clock:

AND to_char(to_date(:EFFECTIVE_DATE, 'dd/mm/yyyy'), 'yyyy-mm-dd hh24:mi')

SY.

mathguy

I don't understand.

In the original post you had this:

select to_char(to_date(':Effective_date', 'dd/mm/yyyy'), 'yyyy-mm-dd hh:mm') from dual

In the code you posted in Reply 8 you have this:

to_char(to_date(:EFFECTIVE_DATE, 'dd/mm/yyyy'), 'yyyy-mm-dd hh:mm') BETWEEN EFFECTIVEDTM AND EXPIRATIONDTM

In the code, :EFFECTIVE_DATE is not enclosed in single quotes, so why did you enclose it in single quotes in your original question?

On the other hand, in the code you posted you also have

AND EMP.PERSONNUM = ':EMPLOYEE_ID'

Here you have the bind variable in single quotes. This is what is throwing the error, not the :EFFECTIVE_DATE thing. Remove the single quotes from around :EMPLOYEE_ID.

BluShadow

We have a lovely (if I say so myself) community document about Substitution and Bind Variables...

If you can't get it working after reading that, show us exactly what you're doing, and tell us what tool you are using to execute your code (SQL*Plus?, SQL*Developer?, TOAD? etc.)

mathguy

BluShadow wrote:

We have a lovely (if I say so myself) community document about Substitution and Bind Variables...

PL/SQL 101 : Substitution vs. Bind Variables

If you can't get it working after reading that, show us exactly what you're doing, and tell us what tool you are using to execute your code (SQL*Plus?, SQL*Developer?, TOAD? etc.)

This may confuse the OP more than it helps him.

He posted his code already. He is clearly using two BIND variables - no substitution variables in sight.

He is enclosing his bind variables within single quotes. I told him several times to fix that.

I assume he fixed it for the :EFFECTIVE_DATE variable, but then he had the same mistake with :EMPLOYEE_ID. By know, I believe he must have fixed that too, and he is hitting even more errors - because the code is full of mistakes. This is probably going to go nowhere; but it won't be about substitution vs. bind variables.

1 - 12
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 13 2010
Added on Sep 15 2010
1 comment
623 views