Difficulty loading oracle data with js(jquery and ajax) function

Asked

Viewed 63 times

1

This is my scenario: I have two pages (A and B). In B I load a variable with data coming from Oracle. In B I also mount my table that will be displayed in A with this data. On page A I have my function js(jquery and ajax), which takes this table already loaded and mounted in B and downloads one or other thing. Oracle is returning an error to me, but I’m sure the way it’s done is wrong, hence the error. Here I load the Oracle variable:

set rsPesquisa = rsCursorOracle( CStr(Session("ace_usuario")),_
                                 CStr(Session("ace_senha")),_
                                 CStr(Session("ace_ip")),_
                                 CStr(Session("ace_sistema")),_
                                 CStr(Session("ace_modulo")),_
                                 "prs_rcs_gestao.get_prestador_tipo", _
                                 vetPL, _
                                 false )  

Now comes the part that is keeping me awake, one of them, by the way. Where I assemble the table. I only made an example with one. NOTE: In the code was removed a part that filled a component called Ebagrid, this is the reason of this table, replace Ebagrid, because it does not run in Chrome.

if ucase(origem) = "CONSULTA" then
        Do While Not rsPesquisa.eof

            if IsNull(rsPesquisa("cod_prestador_ts")) then
                ind_selecionado = "N"
            else
                ind_selecionado = "S"
            end if

            if ind_selecionado = "S" then 
                ind_internacao      = lerCampo(rsPesquisa("ind_internacao"))
                ind_emergencia      = lerCampo(rsPesquisa("ind_emergencia"))
                ind_day_hospital    = lerCampo(rsPesquisa("ind_day_hospital"))

                sRetorno = "<tr>"
                sRetorno = sRetorno & "<td>"&ind_internacao&"</td>" 
                sRetorno = sRetorno & "<td>"&ind_emergencia&"</td>" 

                sRetorno = sRetorno & "</tr>"
            end if 
            rsPesquisa.movenext
        loop   
            Response.write sRetorno
    else
        Do While Not rsPesquisa.eof

            if IsNull(rsPesquisa("cod_prestador_ts")) then
                ind_selecionado = "N"
            else
                ind_selecionado = "S"
            end if

            ind_internacao      = lerCampo(rsPesquisa("ind_internacao"))
            ind_emergencia      = lerCampo(rsPesquisa("ind_emergencia"))
            ind_day_hospital    = lerCampo(rsPesquisa("ind_day_hospital"))          

            sRetorno = "<tr>"
            sRetorno = sRetorno & "<td>"&ind_internacao&"</td>" 
            sRetorno = sRetorno & "<td>"&ind_emergencia&"</td>" 

            sRetorno = sRetorno & "</tr>"

            rsPesquisa.movenext
        loop   

    end if 

    set oPesquisa      = nothing    
    set rsPesquisa     = nothing

These code are on page B. On page B, there are these variables being loaded, which I loaded on page A and tried to pass as parameters. Even if I don’t, it’s still the same mistake:

cod_prestador_ts = Request("cod_prestador_ts")
ind_vinculacao   = Request("ind_vinculacao")
origem           = Request("origem")

Now the code on page A.

    function CarregaTabela() {
       var sUrl     = $('#sUrl').val();
       //var str = "";
       var cod_ts   = '<%= Request.QueryString("cod_prestador_ts")%>';
       var ori      = '<%= Request.QueryString("Origem")%>';
       var ind_vinc = '<%= Request.QueryString("ind_vinculacao")%>';

   alert(cod_ts);

    $.ajax({
        url: sUrl,
        datatype: 'json',
        contentType: 'application/json; charset=utf-8',
        type: 'POST',
        data: JSON.stringify({ cod_prestador_ts: cod_ts, origem: ori, ind_vinculacao: ind_vinc }),
        success: function (data) {

            alert(2);
            alert(data);

            $('#cbxAcao').html(data);

        },
        error: function (error) {

            alert(3);
        }
    })
}

This is the Oracle error:

ORA-20001: Vinculac? o must be informed. ORA-06512: in "TS.PRS_RCS_GESTAO", line 118 ORA-06512: in line 1

1 answer

0

What’s wrong is that mine URL was being mounted in the wrong way.

1) I don’t need path complete, because the file to be called is in the same folder as the caller.

2) I was riding the url wrong way. You should pass the url and more parameters, as it is by querystring which will be passed to the oracle, that’s where I went wrong. See how the function turned out correctly, now enters the ajax Success, IE, I caught the alert(2).

function CarregaTabela() {
       var cod_ts   = '<%= Request.QueryString("cod_prestador_ts")%>';
       var ori      = '<%= Request.QueryString("Origem")%>';
       var ind_vinc = $("#ind_vincul").val();
       var cod_oper = '<%= Request.QueryString("cod_operadora")%>';
       var ind_aut  = '<%= Request.QueryString("ind_autorizacao")%>';

       alert(ind_vinc);

        $.ajax({
            url: 'prs0061b_crossbrowser.asp?cod_prestador_ts=' + cod_ts + '&ind_vinculacao=' + ind_vinc + '&origem=' + ori + '&ind_autorizacao=' + ind_aut + '&cod_operadora_principal=' + cod_oper + '',
            type: 'POST',
            success: function (data) {

                alert(2);

            },
            error: function (error) {

                alert(3);
            }
        })
    }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.