pastebin - collaborative debugging tool
kpaste.net RSS


20211014mgh
Posted by Anonymous on Thu 14th Oct 2021 09:29
raw | new post

  1.  
  2.  
  3.  
  4. CREATE TABLE T AS
  5.  
  6. SELECT 'PD01' STK_ID,'SERIE_NO' FIELD,'=' RELATION,'07' F_VALUE ,'J002' branch_no FROM dual
  7. UNION ALL
  8. SELECT 'PG01' STK_ID,'SERIE_NO' FIELD,'=' RELATION,'07' F_VALUE ,'J002' branch_no FROM dual
  9. UNION ALL
  10. SELECT 'PD01' STK_ID,'SERIE_NO' FIELD,'<>' RELATION,'07' F_VALUE ,'J001' branch_no FROM dual
  11. UNION ALL
  12. SELECT 'PG01' STK_ID,'SERIE_NO' FIELD,'<>' RELATION,'07' F_VALUE ,'J001' branch_no FROM dual;
  13.  
  14.  
  15.  
  16.  
  17. DECLARE
  18.   V_P VARCHAR2(200) := 'PD01\06';
  19.  
  20.   V_P1    VARCHAR2(200);
  21.   V_P2    VARCHAR2(200);
  22.   V_VALUE VARCHAR2(200);
  23. BEGIN
  24.   V_P1 := REGEXP_SUBSTR(V_P, '[^\]+', 1, 1);
  25.   V_P2 := REGEXP_SUBSTR(V_P, '[^\]+', 1, 2);
  26.  
  27.   EXECUTE IMMEDIATE
  28.  
  29.   '
  30. SELECT F_VALUE FROM T
  31. WHERE STK_ID=''' || V_P1 || '''
  32. AND  (
  33. (T.RELATION = ''='' AND F_VALUE = '''||v_p2||''')
  34. OR
  35. (T.RELATION = ''<>'' AND F_VALUE <> '''||v_p2||''')
  36. )
  37. '
  38.     INTO V_VALUE;
  39.    
  40.    
  41.    
  42.   DBMS_OUTPUT.PUT_LINE (V_VALUE);
  43. END;
  44.  
  45.  
  46.  
  47.  
  48.  
  49. SELECT * FROM T
  50. WHERE STK_ID='PD01'
  51. AND  (
  52. (T.RELATION = '=' AND F_VALUE = '06')
  53. OR
  54. (T.RELATION = '<>' AND F_VALUE <> '06')
  55. )

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at