×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How can I use SQL Expressions to link two tables with different data types

How can I use SQL Expressions to link two tables with different data types

How can I use SQL Expressions to link two tables with different data types

(OP)
Hi and thanks for your help,

How can I use an SQL expression field, inside of Crystal Reports, to link two tables together on a field that is a string in one table and a numeral in the other?

I tried to use an SQL Command, but the thing ran forever.

Thank you,
Will

RE: How can I use SQL Expressions to link two tables with different data types

(OP)
For example: what is wrong with this SQL Expression -- it tells me 'missing expression'

(
CASE WHEN is_numeric("SMRTDTA_ELEM_VALUE"."SMRTDTA_ELEM_VALUE") = 1 AND "SMRTDTA_ELEM_VALUE"."SMRTDTA_ELEM_VALUE" > 0 THEN
SELECT clarity_edg.dx_name
FROM clarity_edg, smrtdta_elem_value
WHERE to_number("SMRTDTA_ELEM_VALUE"."SMRTDTA_ELEM_VALUE") = clarity_edg.dx_id
GROUP BY clarity_edg.dx_name
ELSE return 0;
END;
)

Thanks Will

RE: How can I use SQL Expressions to link two tables with different data types

(OP)
By the way, this is in PL/SQL

Currently, the problem is that there is no "is_numeric" function inside PL/SQL

I am trying to get around this using :

(
SELECT clarity_edg.dx_name
FROM clarity_edg, smrtdta_elem_value
WHERE clarity_edg.dx_id LIKE
CASE WHEN
(to_number("SMRTDTA_ELEM_VALUE"."SMRTDTA_ELEM_VALUE")
return 1
exception when value_error then
return 0) = 1
THEN To_Number("SMRTDTA_ELEM_VALUE"."SMRTDTA_ELEM_VALUE")
ELSE Return 0
END
GROUP BY clarity_edg.dx_name
)


but it fails with: "invalid relational operator"

Any idea guys?

Thanks,
Will

RE: How can I use SQL Expressions to link two tables with different data types

(OP)
Well, I thought this would fix my above problem, but it looks like it returns with no data -- does anyone know why?


SELECT clarity_edg.dx_name
FROM clarity_edg, smrtdta_elem_value
WHERE clarity_edg.dx_id =
CASE WHEN LENGTH(TRIM(TRANSLATE(SMRTDTA_ELEM_VALUE.SMRTDTA_ELEM_VALUE, ' +-.0123456789', ' '))) < 1
THEN To_Number(SMRTDTA_ELEM_VALUE.SMRTDTA_ELEM_VALUE)
END
GROUP BY clarity_edg.dx_name

RE: How can I use SQL Expressions to link two tables with different data types

I had a similar problem and with help of the Oracle forum on this site developed my own IsNumeric Function.

CODE

CREATE OR REPLACE FUNCTION IS_NUMERIC (string_to_check IN VARCHAR2)
RETURN NUMBER
AS

dummy_number NUMBER;

BEGIN

dummy_number := TO_NUMBER(string_to_check);
RETURN 1;

EXCEPTION WHEN OTHERS THEN RETURN 0;

END; 

Ian

RE: How can I use SQL Expressions to link two tables with different data types

(OP)
How do you include a function like this inside a Crystal Expressions Field?

RE: How can I use SQL Expressions to link two tables with different data types

Sorry you can't.

You have to create function on the oracle database.

Then use a Database view or Crystal Command incorporating the new function.

Ian

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close