Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 2803

Re: Manage multi-table insert using OData Service

$
0
0

Hi Srihari,

 

1)===>>>Multiple table CRUD operations are not possible, but we can give read operations for UI5 and we can able to create multiple table by using NAVIGATE and ASSOCIATION........and i was refer many blocks for CRUD operations but no solutions so i decided and created one procedure which is for CREATE / UPDATE procedure .the given procedure is execute both CREATE and UPDATE

operations i was tested in ODATA its working fine but conditions should be based on primary keys and related bussiness logic.

 

 

2) CREATE/UPDATE Procedure for ODATA SERVICES?????

Pr_Create_Update procedure

 

PROCEDURE"shema"."folder.subfolder.procedures::prcedurename_create_update" (

INrow"catalog table which you want",

              OUTerror"table_type for error message::error")

       LANGUAGESQLSCRIPT

       SQLSECURITYINVOKER

       DEFAULTSCHEMA"schema name"

AS   

BEGIN

 

/*****************************

     

       Description : This proc will be called from the OData to

                                  Update Master Vehicle Details from UI

     

      

*****************************/

 

DECLARE i_aNVARCHAR(20);

        DECLARE i_b  NVARCHAR(20);

        DECLARE i_cNVARCHAR(30);

        DECLAREi_dNVARCHAR(3);

        DECLAREi_eNVARCHAR(3);

        DECLAREI_fNVARCHAR(3);

     

      

        DECLARE i_a_COUNTnvarchar;

        DECLAREi_b_COUNTnvarchar;

 

      

        DECLAREEXITHANDLERFORSQLEXCEPTION

       BEGIN

                     error = select ::SQL_ERROR_CODEashttp_status_code,

                  ::SQL_ERROR_MESSAGEaserror_message,

                        'SQL EXCEPTION' asdetailfromdummy;

       END;

     

       SELECTa,b,c,d,e,f into i_a,i_b,i_c,i_d,i_e,i_f FROM :row;

     

       selectcount(*) into i_a_COUNTfrom  "table name"wherea = :i_a;

     

       selectcount(*) into i_b_COUNTfrom  "table name"whereb = :i_b;

     

       if( (:i_a_COUNT = 0 and :I_b_COUNT> 0) or (:I_a_COUNT> 0 and :I_b_COUNT = 0)) then

     

         error = select 500 ashttp_status_code,

                   'Invalid Input' aserror_message,

                         'Invalid a number/b Number' asdetailfromdummy;

                       

       elseif(:I_a_COUNT = 0 and :I_b_COUNT = 0) then

     

               INSERTINTO"table name "

               ("a","b","c","d","e","f")VALUES

               (I_a, i_b,i_c,i_d,i_e,i_f);

      

       elseif( :I_a_count> 0 and :I_b_COUNT> 0) then

      

              UPDATE"schema name"."folder.subfolder::table name"SET"a" =:i_a,i_b,i_c,i_d,i_e,i_fWHEREa = :I_aANDb = :I_b;

             

       endif

END;

 

 



thanks & regards,

SUNNY


Viewing all articles
Browse latest Browse all 2803

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>