Hi
Ihave below query and i want if no record exists then in a variable No value should gets stored else Yes
SELECT 'Invoice',T0."TransId" , T0."DocNum", T0."DocDate",T0."BPLName", T0."CardCode"
FROM OINV T0
INNER JOIN CRD1 T3 ON T0."CardCode" = T3."CardCode"
INNER JOIN INV12 T5 ON T5."DocEntry" = T0."DocEntry"
LEFT JOIN "LIVE"."@EINV" T4 ON T0."DocEntry" = T4."U_UTL_BaseEntry"
where T0."CardCode" = T3."CardCode" and T3."GSTRegnNo" <> ''
and T0."DocEntry" NOT IN (Select A4."U_UTL_BaseEntry" from "LIVE"."@EINV" A4 where A4."U_IST" <> 'F' )
Thanks
Naveen KumarPosted Dec 16, 2024, 10:43 AM
Try below query. You can declare variable to store the result yes or no. You can use IF EXISTS condition to check if the query returns records and then set the variable accordingly.
Jaish MathewsPosted Dec 16, 2024, 3:48 AM
You can achieve your requirement by using a SQL query with a conditional check. You can use a
CASEstatement to set a variable to "No" if no record exists or "Yes" otherwise.Here's how you can modify your SQL query:
Explanation:
EXISTSClause:CASEStatement:EXISTScondition evaluates toTRUE, the variable@Resultis set to "Yes".@ResultVariable:Output:
@Resultis selected to display whether records exist or not.Adjustments:
DECLAREwith the appropriate syntax for your SQL environment if required (e.g., in PL/SQL or T-SQL).Jignesh KumarPosted Dec 15, 2024, 6:03 PM
Hello Ramco,
You can declare one variable and assign values to that variable based on your query result,