1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
| <html>
<head>
<title>Connexion Gest</title>
</head>
<body>
<?php
//
//***************
//Connexion ODBC
//***************
$connexion = "*****";
$user = "******";
$passw = "*****";
$cx = odbc_connect($connexion,$user,$passw) or die ("Erreur de connexion ! ".odbc_error());
echo "Connexion a la base = "; // me renvoie Connexion a la base = resource(2) of type (odbc link)
var_dump($cx);
echo "<pre>";
echo "</pre>";
echo "<pre>";
echo "</pre>";
//
//*************************************************************************
/* Description de la fonction "SP_GET_SALPRICE"
//*************************************************************************
01 IN as_cust varchar(10)
02 IN as_item varchar(12)
03 IN as_curr char(3)
04 IN adec_currconv numeric(10,6)
05 IN adt_datereq timestamp
06 IN as_directsal char(1)
07 IN adec_qty numeric(10,3)
08 IN Session_name varchar(30)
//
01 OUT PriceTyp CHAR(1)
02 OUT rate numeric(5,0)
03 OUT PriceOrigin char(1)
04 OUT baseprice numeric(10,4)
05 OUT ratedisc numeric(5,2)
06 OUT originprice_withoutlogistique numeric(10,4)
07 OUT OriginPrice numeric(10,4)
08 OUT RealPrice numeric(10,4)
09 OUT DirectSalRate char(1)
10 OUT pcdisc numeric(20,10)
11 OUT qtydisc numeric(20,10)
12 OUT logistpcdisc numeric(10,4)) */
//
//*********************************************
//appel à la procédure stockée sp_get_salprice
//*********************************************
//Paramètres IN
//
$as_cust = "'V00754'";
$as_item = "'77082'";
$as_curr = "'EUR'";
$adec_currconv = 1;
$adt_datereq = "'2014/09/30'";
$as_directsal= "'Y'";
$adec_qty = 1;
$Session_name = $user;
//
//Paramètres OUT
//
$P1 = "@PriceTyp CHAR(1)";
$P2 = "@rate numeric(5,0)";
$P3 = "@PriceOrigin char(1)";
$P4 = "@baseprice numeric(10,4)";
$P5 = "@ratedisc numeric(5,2)";
$P6 = "@originprice_withoutlogistique numeric(10,4)";
$P7 = "@OriginPrice numeric(10,4)";
$P8 = "@RealPrice numeric(10,4)";
$P9 = "@DirectSalRate char(1)";
$P10 = "@pcdisc numeric(20,10)";
$P11 = "@qtydisc numeric(20,10)";
$P12 = "@logistpcdisc numeric(10,4)";
//
//Requête
//
$execsql = "declare $P1,$P2,$P3,$P4,$P5,$P6,$P7,$P8,$P9,$P10,$P11,$P12; exec dba.sp_get_salprice $as_cust, $as_item, $as_curr, $adec_currconv, $adt_datereq, $as_directsal, $adec_qty, $Session_name,@PriceTyp,@Rate, P@riceOrigin, @BasePrice, @RateDIsc, @OriginPrice_WithoutLogistique, @OriginPrice, @RealPrice, @DirectSalRate, @PcDisc output; select @PriceTyp,@Rate, @PriceOrigin, @BasePrice, @RateDIsc, @OriginPrice_WithoutLogistique, @OriginPrice, @RealPrice, @DirectSalRate, @PcDisc";
//
$sql = $execsql;
echo "Requete Sql = ";
echo "$sql\n";
try
{
//
//Préparation
//
$stmt = odbc_prepare($cx,$sql)or die (odbc_error());
echo "Resultats preparation = "; // me renvoie Resultats preparation = resource(3) of type (odbc result)
var_dump($stmt);
//
//Exécution
//
$res = odbc_execute($stmt) or die (odbc_error());
echo "\n Resultat execute = "; //me renvoie Resultat execute = bool(true) 1
var_dump($res);
//
//Lecture des résultats
//
$result = odbc_result_all($res);
echo "Valeur de retour = "; //me renvoie Valeur de retour = NULL
print_r($result);
}
catch (PDOException $e)
{
$p_retour= $e->getMessage();
echo 'catch';
}
// disconnect from database
odbc_close($sql);
odbc_close($cx);
?>
</body>
</html> |
Partager