Question

Please tell me whats wrong with the query. I am using Pro C.

EXEC SQL SELECT 1
        INTO    :db_count
        FROM    sachin t
        WHERE   t.serialno =   :serial_no
        AND     t.amount = (:db_inamount - (SELECT NVL(overrun_amount,0)
                                            FROM  sunny tovrun
                                            WHERE tovrun.serialno = :serial_no
                                            AND   tovrun.timestamp = t.timestamp
                                            AND   rownum < 2)
                            )
        AND     t.request_code = 11
        AND     t.reason_code = 0
        AND     t.reversed    = 0
        AND rownum < 2;

And getting the compilation errors

Syntax error at line 4487, column 42, file my_file.pc:
Error at line 4487, column 42 in file my_file.pc            AND             t.amount = (:db_inamount - (SELECT NVL(overrun_amount,0)
Was it helpful?

Solution

Use:

 AND t.amount = (SELECT :db_amount - NVL(overrun_amount, 0) ...

It's a standard computed column, where the value is calculated prior to the comparison to the t.amount value for equality.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top